@SuppressWarnings("unchecked")
  private static ThriftClientPool<OptimizingService.Client> buildClient(String url) {
    PoolConfig<OptimizingService.Client> poolConfig =
        (PoolConfig<OptimizingService.Client>) PoolConfig.forUrl(url);
    poolConfig.setMaxTotal(-1);
    return new ThriftClientPool<>(
        url,
        s ->
            new OptimizingService.Client(
                new TMultiplexedProtocol(
                    new TBinaryProtocol(s), Constants.THRIFT_OPTIMIZING_SERVICE_NAME)),
        c -> {
          try {
            ((OptimizingService.Client) c).ping();
          } catch (TException e) {
            return false;
          }
          return true;
        },
        poolConfig,
        Constants.THRIFT_OPTIMIZING_SERVICE_NAME);
  }
Client pool cache for different ams optimize server, sharing in jvm.
amoro-common/src/main/java/org/apache/amoro/client/OptimizingClientPools.java