本文整理了Java中org.apache.helix.manager.zk.ZKUtil.isClusterSetup()
方法的一些代码示例,展示了ZKUtil.isClusterSetup()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil.isClusterSetup()
方法的具体详情如下:
包路径:org.apache.helix.manager.zk.ZKUtil
类名称:ZKUtil
方法名:isClusterSetup
暂无
代码示例来源:origin: org.apache.helix/helix-core
@Override
public List<String> getClusters() {
List<String> zkToplevelPathes = _zkClient.getChildren("/");
List<String> result = new ArrayList<String>();
for (String pathName : zkToplevelPathes) {
if (ZKUtil.isClusterSetup(pathName, _zkClient)) {
result.add(pathName);
}
}
return result;
}
代码示例来源:origin: apache/helix
private boolean isClusterExist(String cluster) {
HelixZkClient zkClient = getHelixZkClient();
if (ZKUtil.isClusterSetup(cluster, zkClient)) {
return true;
}
return false;
}
}
代码示例来源:origin: apache/helix
@Override
public List<String> getClusters() {
List<String> zkToplevelPathes = _zkClient.getChildren("/");
List<String> result = new ArrayList<String>();
for (String pathName : zkToplevelPathes) {
if (ZKUtil.isClusterSetup(pathName, _zkClient)) {
result.add(pathName);
}
}
return result;
}
代码示例来源:origin: apache/helix
@Test()
public void testIsClusterSetup() {
boolean result = ZKUtil.isClusterSetup(clusterName, _gZkClient);
AssertJUnit.assertTrue(result);
}
代码示例来源:origin: apache/helix
@BeforeClass()
public void beforeClass() throws Exception {
boolean result = ZKUtil.isClusterSetup(clusterName, _gZkClient);
AssertJUnit.assertFalse(result);
result = ZKUtil.isClusterSetup(null, _gZkClient);
AssertJUnit.assertFalse(result);
result = ZKUtil.isClusterSetup(null, null);
AssertJUnit.assertFalse(result);
result = ZKUtil.isClusterSetup(clusterName, null);
AssertJUnit.assertFalse(result);
TestHelper.setupEmptyCluster(_gZkClient, clusterName);
}
代码示例来源:origin: apache/helix
@Override
public void enableBatchMessageMode(String clusterName, boolean enabled) {
logger
.info("{} batch message mode for cluster {}.", enabled ? "Enable" : "Disable", clusterName);
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException("cluster " + clusterName + " is not setup yet");
}
ConfigAccessor accessor = new ConfigAccessor(_zkClient);
ClusterConfig clusterConfig = accessor.getClusterConfig(clusterName);
clusterConfig.setBatchMessageMode(enabled);
accessor.setClusterConfig(clusterName, clusterConfig);
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public void enableBatchMessageMode(String clusterName, boolean enabled) {
logger
.info("{} batch message mode for cluster {}.", enabled ? "Enable" : "Disable", clusterName);
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException("cluster " + clusterName + " is not setup yet");
}
ConfigAccessor accessor = new ConfigAccessor(_zkClient);
ClusterConfig clusterConfig = accessor.getClusterConfig(clusterName);
clusterConfig.setBatchMessageMode(enabled);
accessor.setClusterConfig(clusterName, clusterConfig);
}
代码示例来源:origin: apache/helix
private ZNRecord getConfigZnRecord(HelixConfigScope scope) {
String clusterName = scope.getClusterName();
if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
throw new HelixException("fail to get configs. cluster " + clusterName + " is not setup yet");
}
return zkClient.readData(scope.getZkPath(), true);
}
代码示例来源:origin: org.apache.helix/helix-core
private ZNRecord getConfigZnRecord(HelixConfigScope scope) {
String clusterName = scope.getClusterName();
if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
throw new HelixException("fail to get configs. cluster " + clusterName + " is not setup yet");
}
return zkClient.readData(scope.getZkPath(), true);
}
代码示例来源:origin: apache/helix
private void updateClusterConfig(String clusterName, ClusterConfig clusterConfig, boolean overwrite) {
if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
throw new HelixException("fail to update config. cluster: " + clusterName + " is NOT setup.");
}
HelixConfigScope scope =
new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(clusterName).build();
String zkPath = scope.getZkPath();
if (overwrite) {
ZKUtil.createOrReplace(zkClient, zkPath, clusterConfig.getRecord(), true);
} else {
ZKUtil.createOrUpdate(zkClient, zkPath, clusterConfig.getRecord(), true, true);
}
}
代码示例来源:origin: org.apache.helix/helix-core
private void updateClusterConfig(String clusterName, ClusterConfig clusterConfig, boolean overwrite) {
if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
throw new HelixException("fail to update config. cluster: " + clusterName + " is NOT setup.");
}
HelixConfigScope scope =
new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(clusterName).build();
String zkPath = scope.getZkPath();
if (overwrite) {
ZKUtil.createOrReplace(zkClient, zkPath, clusterConfig.getRecord(), true);
} else {
ZKUtil.createOrUpdate(zkClient, zkPath, clusterConfig.getRecord(), true, true);
}
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public void addInstanceTag(String clusterName, String instanceName, String tag) {
logger
.info("Add instance tag {} for instance {} in cluster {}.", tag, instanceName, clusterName);
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException("cluster " + clusterName + " is not setup yet");
}
if (!ZKUtil.isInstanceSetup(_zkClient, clusterName, instanceName, InstanceType.PARTICIPANT)) {
throw new HelixException("cluster " + clusterName + " instance " + instanceName + " is not setup yet");
}
HelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
Builder keyBuilder = accessor.keyBuilder();
InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig(instanceName));
config.addTag(tag);
accessor.setProperty(keyBuilder.instanceConfig(instanceName), config);
}
代码示例来源:origin: apache/helix
@Override
public void addInstanceTag(String clusterName, String instanceName, String tag) {
logger
.info("Add instance tag {} for instance {} in cluster {}.", tag, instanceName, clusterName);
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException("cluster " + clusterName + " is not setup yet");
}
if (!ZKUtil.isInstanceSetup(_zkClient, clusterName, instanceName, InstanceType.PARTICIPANT)) {
throw new HelixException(
"cluster " + clusterName + " instance " + instanceName + " is not setup yet");
}
HelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
Builder keyBuilder = accessor.keyBuilder();
InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig(instanceName));
config.addTag(tag);
accessor.setProperty(keyBuilder.instanceConfig(instanceName), config);
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public void removeInstanceTag(String clusterName, String instanceName, String tag) {
logger.info("Remove instance tag {} for instance {} in cluster {}.", tag, instanceName,
clusterName);
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException("cluster " + clusterName + " is not setup yet");
}
if (!ZKUtil.isInstanceSetup(_zkClient, clusterName, instanceName, InstanceType.PARTICIPANT)) {
throw new HelixException(
"cluster " + clusterName + " instance " + instanceName + " is not setup yet");
}
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
Builder keyBuilder = accessor.keyBuilder();
InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig(instanceName));
config.removeTag(tag);
accessor.setProperty(keyBuilder.instanceConfig(instanceName), config);
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public void setInstanceZoneId(String clusterName, String instanceName, String zoneId) {
logger.info("Set instance zoneId {} for instance {} in cluster {}.", zoneId, instanceName,
clusterName);
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException("cluster " + clusterName + " is not setup yet");
}
if (!ZKUtil.isInstanceSetup(_zkClient, clusterName, instanceName, InstanceType.PARTICIPANT)) {
throw new HelixException(
"cluster " + clusterName + " instance " + instanceName + " is not setup yet");
}
HelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
Builder keyBuilder = accessor.keyBuilder();
InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig(instanceName));
config.setZoneId(zoneId);
accessor.setProperty(keyBuilder.instanceConfig(instanceName), config);
}
代码示例来源:origin: apache/helix
@Override
public void removeInstanceTag(String clusterName, String instanceName, String tag) {
logger.info("Remove instance tag {} for instance {} in cluster {}.", tag, instanceName,
clusterName);
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException("cluster " + clusterName + " is not setup yet");
}
if (!ZKUtil.isInstanceSetup(_zkClient, clusterName, instanceName, InstanceType.PARTICIPANT)) {
throw new HelixException(
"cluster " + clusterName + " instance " + instanceName + " is not setup yet");
}
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
Builder keyBuilder = accessor.keyBuilder();
InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig(instanceName));
config.removeTag(tag);
accessor.setProperty(keyBuilder.instanceConfig(instanceName), config);
}
代码示例来源:origin: org.apache.helix/helix-core
private void updateResourceConfig(String clusterName, String resourceName,
ResourceConfig resourceConfig, boolean overwrite) {
if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
throw new HelixException("fail to setup config. cluster: " + clusterName + " is NOT setup.");
}
HelixConfigScope scope =
new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE).forCluster(clusterName)
.forResource(resourceName).build();
String zkPath = scope.getZkPath();
if (overwrite) {
ZKUtil.createOrReplace(zkClient, zkPath, resourceConfig.getRecord(), true);
} else {
ZKUtil.createOrUpdate(zkClient, zkPath, resourceConfig.getRecord(), true, true);
}
}
代码示例来源:origin: apache/helix
private void updateResourceConfig(String clusterName, String resourceName,
ResourceConfig resourceConfig, boolean overwrite) {
if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
throw new HelixException("fail to setup config. cluster: " + clusterName + " is NOT setup.");
}
HelixConfigScope scope =
new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE).forCluster(clusterName)
.forResource(resourceName).build();
String zkPath = scope.getZkPath();
if (overwrite) {
ZKUtil.createOrReplace(zkClient, zkPath, resourceConfig.getRecord(), true);
} else {
ZKUtil.createOrUpdate(zkClient, zkPath, resourceConfig.getRecord(), true, true);
}
}
代码示例来源:origin: org.apache.helix/helix-core
private void updateInstanceConfig(String clusterName, String instanceName,
InstanceConfig instanceConfig, boolean overwrite) {
if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
throw new HelixException("fail to setup config. cluster: " + clusterName + " is NOT setup.");
}
HelixConfigScope scope =
new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT).forCluster(clusterName)
.forParticipant(instanceName).build();
String zkPath = scope.getZkPath();
if (overwrite) {
ZKUtil.createOrReplace(zkClient, zkPath, instanceConfig.getRecord(), true);
} else {
ZKUtil.createOrUpdate(zkClient, zkPath, instanceConfig.getRecord(), true, true);
}
}
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public void addInstance(String clusterName, InstanceConfig instanceConfig) {
logger.info("Add instance {} to cluster {}.", instanceConfig.getInstanceName(), clusterName);
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException("cluster " + clusterName + " is not setup yet");
}
String instanceConfigsPath = PropertyPathBuilder.instanceConfig(clusterName);
String nodeId = instanceConfig.getId();
String instanceConfigPath = instanceConfigsPath + "/" + nodeId;
if (_zkClient.exists(instanceConfigPath)) {
throw new HelixException("Node " + nodeId + " already exists in cluster " + clusterName);
}
ZKUtil.createChildren(_zkClient, instanceConfigsPath, instanceConfig.getRecord());
_zkClient.createPersistent(PropertyPathBuilder.instanceMessage(clusterName, nodeId), true);
_zkClient.createPersistent(PropertyPathBuilder.instanceCurrentState(clusterName, nodeId), true);
_zkClient.createPersistent(PropertyPathBuilder.instanceError(clusterName, nodeId), true);
_zkClient.createPersistent(PropertyPathBuilder.instanceStatusUpdate(clusterName, nodeId), true);
_zkClient.createPersistent(PropertyPathBuilder.instanceHistory(clusterName, nodeId), true);
}
内容来源于网络,如有侵权,请联系作者删除!