作者热门文章
- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.helix.manager.zk.ZKHelixAdmin.getInstancesInCluster()
方法的一些代码示例,展示了ZKHelixAdmin.getInstancesInCluster()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKHelixAdmin.getInstancesInCluster()
方法的具体详情如下:
包路径:org.apache.helix.manager.zk.ZKHelixAdmin
类名称: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);
}
本文整理了Java中org.apache.helix.manager.zk.ZKHelixAdmin.getInstancesInCluster()方法的一些代码示例,展示了ZKHelixAdmin.
我是一名优秀的程序员,十分优秀!