gpt4 book ai didi

org.apache.helix.manager.zk.ZKHelixAdmin.getInstancesInCluster()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 03:00:49 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.helix.manager.zk.ZKHelixAdmin.getInstancesInCluster()方法的一些代码示例,展示了ZKHelixAdmin.getInstancesInCluster()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKHelixAdmin.getInstancesInCluster()方法的具体详情如下:
包路径:org.apache.helix.manager.zk.ZKHelixAdmin
类名称:ZKHelixAdmin
方法名:getInstancesInCluster

ZKHelixAdmin.getInstancesInCluster介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-pinot

List<String> instancesInCluster = zkHelixAdmin.getInstancesInCluster(_clusterName);
List<String> tables = zkHelixAdmin.getResourcesInCluster(_clusterName);

代码示例来源:origin: org.apache.helix/helix-core

@Override
public void rebalance(String clusterName, String resourceName, int replica,
  String keyPrefix, String group) {
 List<String> instanceNames = new LinkedList<String>();
 if (keyPrefix == null || keyPrefix.length() == 0) {
  keyPrefix = resourceName;
 }
 if (group != null && group.length() > 0) {
  instanceNames = getInstancesInClusterWithTag(clusterName, group);
 }
 if (instanceNames.size() == 0) {
  logger.info("No tags found for resource " + resourceName + ", use all instances");
  instanceNames = getInstancesInCluster(clusterName);
  group = "";
 } else {
  logger.info("Found instances with tag for " + resourceName + " " + instanceNames);
 }
 rebalance(clusterName, resourceName, replica, keyPrefix, instanceNames, group);
}

代码示例来源:origin: apache/helix

/**
 * Configure the instance, the configuration of each node is available to
 * other nodes.
 * @param instanceName
 */
private void configureInstance(String instanceName) {
 ZKHelixAdmin helixAdmin = new ZKHelixAdmin(zkAddress);
 List<String> instancesInCluster = helixAdmin.getInstancesInCluster(clusterName);
 if (instancesInCluster == null || !instancesInCluster.contains(instanceName)) {
  InstanceConfig config = new InstanceConfig(instanceName);
  config.setHostName("localhost");
  config.setPort("12000");
  helixAdmin.addInstance(clusterName, config);
 }
}

代码示例来源:origin: apache/helix

@Override
public void rebalance(String clusterName, String resourceName, int replica, String keyPrefix,
  String group) {
 List<String> instanceNames = new LinkedList<String>();
 if (keyPrefix == null || keyPrefix.length() == 0) {
  keyPrefix = resourceName;
 }
 if (group != null && group.length() > 0) {
  instanceNames = getInstancesInClusterWithTag(clusterName, group);
 }
 if (instanceNames.size() == 0) {
  logger.info("No tags found for resource " + resourceName + ", use all instances");
  instanceNames = getInstancesInCluster(clusterName);
  group = "";
 } else {
  logger.info("Found instances with tag for " + resourceName + " " + instanceNames);
 }
 rebalance(clusterName, resourceName, replica, keyPrefix, instanceNames, group);
}

代码示例来源:origin: apache/helix

ZKHelixAdmin admin = new ZKHelixAdmin(zkclient);
List<String> nodes = admin.getInstancesInCluster(clusterName);
if (!nodes.contains("consumer_" + consumerId)) {
 InstanceConfig config = new InstanceConfig("consumer_" + consumerId);

代码示例来源:origin: apache/helix

@Override
public void addClusterToGrandCluster(String clusterName, String grandCluster) {
 logger.info("Add cluster {} to grand cluster {}.", clusterName, grandCluster);
 if (!ZKUtil.isClusterSetup(grandCluster, _zkClient)) {
  throw new HelixException("Grand cluster " + grandCluster + " is not setup yet");
 }
 if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
  throw new HelixException("Cluster " + clusterName + " is not setup yet");
 }
 IdealState idealState = new IdealState(clusterName);
 idealState.setNumPartitions(1);
 idealState.setStateModelDefRef("LeaderStandby");
 List<String> controllers = getInstancesInCluster(grandCluster);
 if (controllers.size() == 0) {
  throw new HelixException("Grand cluster " + grandCluster + " has no instances");
 }
 idealState.setReplicas(Integer.toString(controllers.size()));
 Collections.shuffle(controllers);
 idealState.getRecord().setListField(clusterName, controllers);
 idealState.setPartitionState(clusterName, controllers.get(0), "LEADER");
 for (int i = 1; i < controllers.size(); i++) {
  idealState.setPartitionState(clusterName, controllers.get(i), "STANDBY");
 }
 ZKHelixDataAccessor accessor =
   new ZKHelixDataAccessor(grandCluster, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
 Builder keyBuilder = accessor.keyBuilder();
 accessor.setProperty(keyBuilder.idealStates(idealState.getResourceName()), idealState);
}

代码示例来源:origin: org.apache.helix/helix-core

@Override
public void addClusterToGrandCluster(String clusterName, String grandCluster) {
 logger.info("Add cluster {} to grand cluster {}.", clusterName, grandCluster);
 if (!ZKUtil.isClusterSetup(grandCluster, _zkClient)) {
  throw new HelixException("Grand cluster " + grandCluster + " is not setup yet");
 }
 if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
  throw new HelixException("Cluster " + clusterName + " is not setup yet");
 }
 IdealState idealState = new IdealState(clusterName);
 idealState.setNumPartitions(1);
 idealState.setStateModelDefRef("LeaderStandby");
 List<String> controllers = getInstancesInCluster(grandCluster);
 if (controllers.size() == 0) {
  throw new HelixException("Grand cluster " + grandCluster + " has no instances");
 }
 idealState.setReplicas(Integer.toString(controllers.size()));
 Collections.shuffle(controllers);
 idealState.getRecord().setListField(clusterName, controllers);
 idealState.setPartitionState(clusterName, controllers.get(0), "LEADER");
 for (int i = 1; i < controllers.size(); i++) {
  idealState.setPartitionState(clusterName, controllers.get(i), "STANDBY");
 }
 ZKHelixDataAccessor accessor =
   new ZKHelixDataAccessor(grandCluster, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
 Builder keyBuilder = accessor.keyBuilder();
 accessor.setProperty(keyBuilder.idealStates(idealState.getResourceName()), idealState);
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com