private void getClusterId(int index) {
    ServerName server = bootstrapServers.get(index);
    LOG.debug("Going to request {} for getting cluster id", server);
    // user and rpcTimeout are both not important here, as we will not actually send any rpc calls
    // out, only a preamble connection header, but if we pass null as user, there will be NPE in
    // some code paths...
    RpcChannel channel = rpcClient.createRpcChannel(server, user, 0);
    ConnectionRegistryService.Interface stub = ConnectionRegistryService.newStub(channel);
    HBaseRpcController controller = rpcControllerFactory.newController();
    stub.getConnectionRegistry(controller, GetConnectionRegistryRequest.getDefaultInstance(),
      new RpcCallback<GetConnectionRegistryResponse>() {

        @Override
        public void run(GetConnectionRegistryResponse resp) {
          if (!controller.failed()) {
            LOG.debug("Got connection registry info: {}", resp);
            future.complete(resp.getClusterId());
            return;
          }
          if (ConnectionUtils.isUnexpectedPreambleHeaderException(controller.getFailed())) {
            // this means we have connected to an old server where it does not support passing
            // cluster id through preamble connnection header, so we fallback to use null
            // cluster id, which is the old behavior
            LOG.debug("Failed to get connection registry info, should be an old server,"
              + " fallback to use null cluster id", controller.getFailed());
            future.complete(null);
          } else {
            LOG.debug("Failed to get connection registry info", controller.getFailed());
            if (index == bootstrapServers.size() - 1) {
              future.completeExceptionally(controller.getFailed());
            } else {
              // try next bootstrap server
              getClusterId(index + 1);
            }
          }
        }
      });

  }
Try get cluster id from the server with the given {@code index} in {@link #bootstrapServers}.
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClusterIdFetcher.java