private LockInfo findLock() throws LockException, InterruptedException {
    Preconditions.checkArgument(
            HiveVersion.min(HiveVersion.HIVE_2),
            "Minimally Hive 2 HMS client is needed to find the Lock using the showLocks API call");
    ShowLocksRequest showLocksRequest = new ShowLocksRequest();
    showLocksRequest.setDbname(databaseName);
    showLocksRequest.setTablename(tableName);
    ShowLocksResponse response;
    try {
      response = metaClients.run(client -> client.showLocks(showLocksRequest));
    } catch (TException e) {
      throw new LockException(e, "Failed to find lock for table %s.%s", databaseName, tableName);
    }
    for (ShowLocksResponseElement lock : response.getLocks()) {
      if (lock.getAgentInfo().equals(agentInfo)) {
        // We found our lock
        return new LockInfo(lock.getLockid(), lock.getState());
      }
    }

    // Not found anything
    return null;
  }
Search for the locks using HMSClient.showLocks identified by the agentInfo. If the lock is
there, then a {@link LockInfo} object is returned. If the lock is not found <code>null</code>
is returned.

@return The {@link LockInfo} for the found lock, or <code>null</code> if nothing found
iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/MetastoreLock.java