当前位置: 首页>>代码示例>>Java>>正文


Java ZkClient.waitUntilConnected方法代码示例

本文整理汇总了Java中org.apache.helix.manager.zk.ZkClient.waitUntilConnected方法的典型用法代码示例。如果您正苦于以下问题:Java ZkClient.waitUntilConnected方法的具体用法?Java ZkClient.waitUntilConnected怎么用?Java ZkClient.waitUntilConnected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.helix.manager.zk.ZkClient的用法示例。


在下文中一共展示了ZkClient.waitUntilConnected方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public void start(ControllerMetrics controllerMetrics) {
  _controllerMetrics = controllerMetrics;

  LOGGER.info("Starting realtime segments manager, adding a listener on the property store table configs path.");
  String zkUrl = _pinotHelixResourceManager.getHelixZkURL();
  _zkClient = new ZkClient(zkUrl, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT);
  _zkClient.setZkSerializer(new ZNRecordSerializer());
  _zkClient.waitUntilConnected();

  // Subscribe to any data/child changes to property
  _zkClient.subscribeChildChanges(_tableConfigPath, this);
  _zkClient.subscribeDataChanges(_tableConfigPath, this);

  // Subscribe to leadership changes
  _pinotHelixResourceManager.getHelixZkManager().addControllerListener(new ControllerChangeListener() {
    @Override
    public void onControllerChange(NotificationContext changeContext) {
      processPropertyStoreChange(CONTROLLER_LEADER_CHANGE);
    }
  });

  // Setup change listeners for already existing tables, if any.
  processPropertyStoreChange(_tableConfigPath);
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:25,代码来源:PinotRealtimeSegmentManager.java

示例2: fromZookeeper

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@Deprecated
public static PinotThirdEyeDataSource fromZookeeper(String controllerHost, int controllerPort, String zkUrl) {
  ZkClient zkClient = new ZkClient(zkUrl);
  zkClient.setZkSerializer(new ZNRecordSerializer());
  zkClient.waitUntilConnected();
  PinotThirdEyeDataSource pinotThirdEyeDataSource = new PinotThirdEyeDataSource(controllerHost, controllerPort);
  LOG.info("Created PinotThirdEyeDataSource to zookeeper: {} controller: {}:{}", zkUrl, controllerHost, controllerPort);
  return pinotThirdEyeDataSource;
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:10,代码来源:PinotThirdEyeDataSource.java

示例3: init

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
/**
 * Initializes the cache loader using the given data source config.
 *
 * @param pinotThirdEyeDataSourceConfig the data source config that provides controller's information.
 *
 * @throws Exception when an error occurs connecting to the Pinot controller.
 */
private void init(PinotThirdEyeDataSourceConfig pinotThirdEyeDataSourceConfig) throws Exception {
  if (pinotThirdEyeDataSourceConfig.getBrokerUrl() != null
      && pinotThirdEyeDataSourceConfig.getBrokerUrl().trim().length() > 0) {
    ZkClient zkClient = new ZkClient(pinotThirdEyeDataSourceConfig.getZookeeperUrl());
    zkClient.setZkSerializer(new ZNRecordSerializer());
    zkClient.waitUntilConnected();
    ZKHelixAdmin helixAdmin = new ZKHelixAdmin(zkClient);
    List<String> thirdeyeBrokerList = helixAdmin.getInstancesInClusterWithTag(
        pinotThirdEyeDataSourceConfig.getClusterName(), pinotThirdEyeDataSourceConfig.getTag());

    String[] thirdeyeBrokers = new String[thirdeyeBrokerList.size()];
    for (int i = 0; i < thirdeyeBrokerList.size(); i++) {
      String instanceName = thirdeyeBrokerList.get(i);
      InstanceConfig instanceConfig =
          helixAdmin.getInstanceConfig(pinotThirdEyeDataSourceConfig.getClusterName(), instanceName);
      thirdeyeBrokers[i] = instanceConfig.getHostName().replaceAll(BROKER_PREFIX, "") + ":"
          + instanceConfig.getPort();
    }
    this.connections = fromHostList(thirdeyeBrokers);
    LOG.info("Created PinotControllerResponseCacheLoader with brokers {}", thirdeyeBrokers);
  } else {
    this.connections = fromZookeeper(pinotThirdEyeDataSourceConfig);
    LOG.info("Created PinotControllerResponseCacheLoader with controller {}:{}",
        pinotThirdEyeDataSourceConfig.getControllerHost(), pinotThirdEyeDataSourceConfig.getControllerPort());
  }
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:34,代码来源:PinotControllerResponseCacheLoader.java

示例4: createHelixClusterIfNeeded

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public static void createHelixClusterIfNeeded(String helixClusterName, String zkPath, boolean isUpdateStateModel) {
  final HelixAdmin admin = new ZKHelixAdmin(zkPath);
  final String segmentStateModelName = PinotHelixSegmentOnlineOfflineStateModelGenerator.PINOT_SEGMENT_ONLINE_OFFLINE_STATE_MODEL;

  if (admin.getClusters().contains(helixClusterName)) {
    LOGGER.info("cluster already exists ********************************************* ");
    if (isUpdateStateModel) {
      final StateModelDefinition curStateModelDef = admin.getStateModelDef(helixClusterName, segmentStateModelName);
      List<String> states = curStateModelDef.getStatesPriorityList();
      if (states.contains(PinotHelixSegmentOnlineOfflineStateModelGenerator.CONSUMING_STATE)) {
        LOGGER.info("State model {} already updated to contain CONSUMING state", segmentStateModelName);
        return;
      } else {
        LOGGER.info("Updating {} to add states for low level kafka consumers", segmentStateModelName);
        StateModelDefinition newStateModelDef = PinotHelixSegmentOnlineOfflineStateModelGenerator.generatePinotStateModelDefinition();
        ZkClient zkClient = new ZkClient(zkPath);
        zkClient.waitUntilConnected(20, TimeUnit.SECONDS);
        zkClient.setZkSerializer(new ZNRecordSerializer());
        HelixDataAccessor accessor = new ZKHelixDataAccessor(helixClusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
        PropertyKey.Builder keyBuilder = accessor.keyBuilder();
        accessor.setProperty(keyBuilder.stateModelDef(segmentStateModelName), newStateModelDef);
        LOGGER.info("Completed updating statemodel {}", segmentStateModelName);
        zkClient.close();
      }
    }
    return;
  }

  LOGGER.info("Creating a new cluster, as the helix cluster : " + helixClusterName
      + " was not found ********************************************* ");
  admin.addCluster(helixClusterName, false);

  LOGGER.info("Enable auto join.");
  final HelixConfigScope scope =
      new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(helixClusterName).build();

  final Map<String, String> props = new HashMap<String, String>();
  props.put(ZKHelixManager.ALLOW_PARTICIPANT_AUTO_JOIN, String.valueOf(true));
  //we need only one segment to be loaded at a time
  props.put(MessageType.STATE_TRANSITION + "." + HelixTaskExecutor.MAX_THREADS, String.valueOf(1));

  admin.setConfig(scope, props);

  LOGGER.info("Adding state model {} (with CONSUMED state) generated using {} **********************************************",
      segmentStateModelName , PinotHelixSegmentOnlineOfflineStateModelGenerator.class.toString());

  // If this is a fresh cluster we are creating, then the cluster will see the CONSUMING state in the
  // state model. But then the servers will never be asked to go to that STATE (whether they have the code
  // to handle it or not) unil we complete the feature using low-level kafka consumers and turn the feature on.
  admin.addStateModelDef(helixClusterName, segmentStateModelName,
      PinotHelixSegmentOnlineOfflineStateModelGenerator.generatePinotStateModelDefinition());

  LOGGER.info("Adding state model definition named : "
      + PinotHelixBrokerResourceOnlineOfflineStateModelGenerator.PINOT_BROKER_RESOURCE_ONLINE_OFFLINE_STATE_MODEL
      + " generated using : " + PinotHelixBrokerResourceOnlineOfflineStateModelGenerator.class.toString()
      + " ********************************************** ");

  admin.addStateModelDef(helixClusterName,
      PinotHelixBrokerResourceOnlineOfflineStateModelGenerator.PINOT_BROKER_RESOURCE_ONLINE_OFFLINE_STATE_MODEL,
      PinotHelixBrokerResourceOnlineOfflineStateModelGenerator.generatePinotStateModelDefinition());

  LOGGER.info("Adding empty ideal state for Broker!");
  HelixHelper.updateResourceConfigsFor(new HashMap<String, String>(), CommonConstants.Helix.BROKER_RESOURCE_INSTANCE,
      helixClusterName, admin);
  IdealState idealState =
      PinotTableIdealStateBuilder.buildEmptyIdealStateForBrokerResource(admin, helixClusterName);
  admin.setResourceIdealState(helixClusterName, CommonConstants.Helix.BROKER_RESOURCE_INSTANCE, idealState);
  initPropertyStorePath(helixClusterName, zkPath);
  LOGGER.info("New Cluster setup completed... ********************************************** ");
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:71,代码来源:HelixSetupUtils.java


注:本文中的org.apache.helix.manager.zk.ZkClient.waitUntilConnected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。