HelixManager buildZKHelixManager(String clusterName, String instanceName, InstanceType instanceType, String zkAddr
  , ClusterMapConfig clusterMapConfig) {
    HelixManager helixManager;
    if (clusterMapConfig != null && clusterMapConfig.clusterMapAutoRegistrationEnabled) {
      LOGGER.info("Autoregistration enabled for cluster {} with instanceName {} and instanceType {}", clusterName, instanceName, instanceType);

      String port = getPortFromInstanceName(instanceName);

      InstanceConfig.Builder instanceConfigBuilder = new InstanceConfig.Builder().setInstanceOperation(InstanceConstants.InstanceOperation.UNKNOWN);
      if (port != null && !port.isEmpty()) {
        instanceConfigBuilder.setPort(port);
      }

      HelixManagerProperty participantHelixProperty = new HelixManagerProperty.Builder().setDefaultInstanceConfigBuilder(instanceConfigBuilder).build();
      HelixManagerProperty defaultHelixManagerProperty = new HelixManagerProperty.Builder().setDefaultInstanceConfigBuilder(new InstanceConfig.Builder()).build();

      helixManager = new ZKHelixManager(clusterName, instanceName, instanceType, zkAddr, null,
          instanceType == InstanceType.PARTICIPANT ?  participantHelixProperty : defaultHelixManagerProperty);
      LOGGER.info("Created HelixManager for cluster {} with instanceName {} and instanceType {}", clusterName, instanceName, instanceType);

    } else {
      helixManager =  HelixManagerFactory.getZKHelixManager(clusterName, instanceName, instanceType, zkAddr);
    }


    return helixManager;
  }
Construct a new instance of {@link HelixManager}. Exposed so that tests can override if needed.
@param clusterName the name of the cluster for the manager.
@param instanceName the name of the instance for the manager.
@param instanceType the {@link InstanceType} of the requester.
@param zkAddr the address identifying the zk service to which this request is to be made.
@return a new instance of {@link HelixManager}.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/HelixFactory.java