private void setClientCache(ClientCache clientCache) {
    DistributionConfig config;
    ClusterManagementServiceInfo cmsInfo;

    List<InetSocketAddress> locators = clientCache.getDefaultPool().getLocators();

    if (locators.size() == 0) {
      throw new IllegalStateException(
          "the client needs to have a client pool connected with a locator.");
    }
    config = ((GemFireCacheImpl) clientCache).getSystem().getConfig();
    SocketCreatorFactory.setDistributionConfig(config);
    TcpClient client =
        new TcpClient(SocketCreatorFactory
            .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR),
            InternalDataSerializer.getDSFIDSerializer().getObjectSerializer(),
            InternalDataSerializer.getDSFIDSerializer().getObjectDeserializer(),
            TcpSocketFactory.DEFAULT);
    cmsInfo = null;
    for (InetSocketAddress locator : locators) {
      try {
        cmsInfo = (ClusterManagementServiceInfo) client.requestToServer(
            new HostAndPort(locator.getHostString(), locator.getPort()),
            new ClusterManagementServiceInfoRequest(), 1000, true);

        // do not try anymore if we found one that has cms running
        if (cmsInfo.isRunning()) {
          break;
        }
      } catch (Exception e) {
        logger.warn(
            "unable to discover the ClusterManagementService on locator " + locator.toString());
      }
    }

    // if cmsInfo is still null at this point, i.e. we failed to retrieve the cms information from
    // any locator
    if (cmsInfo == null || !cmsInfo.isRunning()) {
      throw new IllegalStateException(
          "Unable to discover a locator that has ClusterManagementService running.");
    }

    configureBuilder(config, cmsInfo);
  }
Concrete implementation of {@link ConnectionConfig} which can be used to derive most (if not all)
of the connection properties from an existing {@link Cache} or {@link ClientCache}.

@see ClusterManagementServiceBuilder
geode-core/src/main/java/org/apache/geode/management/internal/api/GeodeConnectionConfig.java