public String forServerTenantCreate() {
   return StringUtil.join("/", StringUtils.chomp(_baseUrl, "/"), "tenants?type=server");
 }
 public String forInstanceBulkCreate() {
   return StringUtil.join("/", StringUtils.chomp(_baseUrl, "/"), "instances", "bulkAdd");
 }
 // V2 API started
 public String forTenantCreate() {
   return StringUtil.join("/", StringUtils.chomp(_baseUrl, "/"), "tenants/");
 }
 public String forInstanceCreate() {
   return StringUtil.join("/", StringUtils.chomp(_baseUrl, "/"), "instances/");
 }
 public String forInstanceEnable(String instanceName) {
   return StringUtil.join(
       "/", StringUtils.chomp(_baseUrl, "/"), "instances", instanceName, "?state=enable");
 }
 public String forBrokerTenantGet(String tenantName) {
   return StringUtil.join(
       "/", StringUtils.chomp(_baseUrl, "/"), "tenants", tenantName, "?type=broker");
 }
 public String forDataFileUpload() {
   return StringUtil.join("/", StringUtils.chomp(_baseUrl, "/"), "segments");
 }
 public String forTableDelete(String tableName) {
   return StringUtil.join("/", StringUtils.chomp(_baseUrl, "/"), "tables", tableName);
 }
 public String forResourceCreate() {
   return StringUtil.join("/", StringUtils.chomp(_baseUrl, "/"), "dataresources");
 }
 public String forTableGetBrokerInstances(String tableName) {
   return StringUtil.join(
       "/", StringUtils.chomp(_baseUrl, "/"), "tables", tableName, "instances?type=broker");
 }
 public String forTableGet(String tableName) {
   return StringUtil.join("/", StringUtils.chomp(_baseUrl, "/"), "tables", tableName, "instances");
 }
 public String forTableGetConfig(String tableName) {
   return StringUtil.join("/", StringUtils.chomp(_baseUrl, "/"), "tables", tableName, "configs");
 }
 public String forTableCreate() {
   return StringUtil.join("/", StringUtils.chomp(_baseUrl, "/"), "tables");
 }
 public String forServerTenantDelete(String tenantName) {
   return StringUtil.join(
       "/", StringUtils.chomp(_baseUrl, "/"), "tenants", tenantName, "?type=server");
 }
 public String forBrokerTenantCreate(String tenantName) {
   return StringUtil.join(
       "/", StringUtils.chomp(_baseUrl, "/"), "tenants", tenantName, "instances?type=broker");
 }
 public String forResourceGet(String resourceName) {
   return StringUtil.join("/", StringUtils.chomp(_baseUrl, "/"), "dataresources", resourceName);
 }
 public String forTenantGet(String tenantName) {
   return StringUtil.join("/", StringUtils.chomp(_baseUrl, "/"), "tenants", tenantName);
 }
  public HelixBrokerStarter(
      String helixClusterName, String zkServer, Configuration pinotHelixProperties)
      throws Exception {
    _liveInstancesListener = new LiveInstancesChangeListenerImpl(helixClusterName);

    _pinotHelixProperties = DefaultHelixBrokerConfig.getDefaultBrokerConf(pinotHelixProperties);
    final String brokerId =
        _pinotHelixProperties.getString(
            "instanceId",
            CommonConstants.Helix.PREFIX_OF_BROKER_INSTANCE
                + NetUtil.getHostAddress()
                + "_"
                + _pinotHelixProperties.getInt(
                    CommonConstants.Helix.KEY_OF_BROKER_QUERY_PORT,
                    CommonConstants.Helix.DEFAULT_BROKER_QUERY_PORT));

    _pinotHelixProperties.addProperty("pinot.broker.id", brokerId);
    RoutingTableBuilder defaultOfflineRoutingTableBuilder =
        getRoutingTableBuilder(
            _pinotHelixProperties.subset(DEFAULT_OFFLINE_ROUTING_TABLE_BUILDER_KEY));
    RoutingTableBuilder defaultRealtimeRoutingTableBuilder =
        getRoutingTableBuilder(
            _pinotHelixProperties.subset(DEFAULT_REALTIME_ROUTING_TABLE_BUILDER_KEY));
    Map<String, RoutingTableBuilder> tableToRoutingTableBuilderMap =
        getTableToRoutingTableBuilderMap(_pinotHelixProperties.subset(ROUTING_TABLE_BUILDER_KEY));
    ZkClient zkClient =
        new ZkClient(
            StringUtil.join(
                "/", StringUtils.chomp(zkServer, "/"), helixClusterName, "PROPERTYSTORE"),
            ZkClient.DEFAULT_SESSION_TIMEOUT,
            ZkClient.DEFAULT_CONNECTION_TIMEOUT,
            new ZNRecordSerializer());
    _propertyStore =
        new ZkHelixPropertyStore<ZNRecord>(new ZkBaseDataAccessor<ZNRecord>(zkClient), "/", null);
    _helixExternalViewBasedRouting =
        new HelixExternalViewBasedRouting(
            defaultOfflineRoutingTableBuilder,
            defaultRealtimeRoutingTableBuilder,
            tableToRoutingTableBuilderMap,
            _propertyStore);

    // _brokerServerBuilder = startBroker();
    _brokerServerBuilder = startBroker(_pinotHelixProperties);
    _helixManager =
        HelixManagerFactory.getZKHelixManager(
            helixClusterName, brokerId, InstanceType.PARTICIPANT, zkServer);
    final StateMachineEngine stateMachineEngine = _helixManager.getStateMachineEngine();
    final StateModelFactory<?> stateModelFactory =
        new BrokerResourceOnlineOfflineStateModelFactory(
            _helixManager, _helixExternalViewBasedRouting);
    stateMachineEngine.registerStateModelFactory(
        BrokerResourceOnlineOfflineStateModelFactory.getStateModelDef(), stateModelFactory);
    _helixManager.connect();
    _helixAdmin = _helixManager.getClusterManagmentTool();
    _helixBrokerRoutingTable =
        new HelixBrokerRoutingTable(_helixExternalViewBasedRouting, brokerId, _helixManager);
    addInstanceTagIfNeeded(helixClusterName, brokerId);
    _helixManager.addExternalViewChangeListener(_helixBrokerRoutingTable);
    _helixManager.addInstanceConfigChangeListener(_helixBrokerRoutingTable);
    _helixManager.addLiveInstanceChangeListener(_liveInstancesListener);
  }