- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.helix.manager.zk.ZKUtil
类的一些代码示例,展示了ZKUtil
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil
类的具体详情如下:
包路径:org.apache.helix.manager.zk.ZKUtil
类名称:ZKUtil
暂无
代码示例来源: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: apache/helix
@Test()
public void testChildrenOperations() {
List<ZNRecord> list = new ArrayList<ZNRecord>();
list.add(new ZNRecord("id1"));
list.add(new ZNRecord("id2"));
String path = PropertyPathBuilder.instanceConfig(clusterName);
ZKUtil.createChildren(_gZkClient, path, list);
list = ZKUtil.getChildren(_gZkClient, path);
AssertJUnit.assertEquals(2, list.size());
ZKUtil.dropChildren(_gZkClient, path, list);
ZKUtil.dropChildren(_gZkClient, path, new ZNRecord("id1"));
list = ZKUtil.getChildren(_gZkClient, path);
AssertJUnit.assertEquals(0, list.size());
ZKUtil.dropChildren(_gZkClient, path, (List<ZNRecord>) null);
}
代码示例来源:origin: apache/helix
/**
* Remove multiple configs
*
* @param scope scope specification of the entity set to query (e.g. cluster, resource,
* participant, etc.)
* @param recordToRemove the ZNRecord that holds the entries that needs to be removed
*/
public void remove(HelixConfigScope scope, ZNRecord recordToRemove) {
if (scope == null || scope.getType() == null || !scope.isFullKey()) {
LOG.error("fail to remove. invalid scope: " + scope);
return;
}
String clusterName = scope.getClusterName();
if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
throw new HelixException("fail to remove. cluster " + clusterName + " is not setup yet");
}
String zkPath = scope.getZkPath();
ZKUtil.subtract(zkClient, zkPath, recordToRemove);
}
代码示例来源:origin: apache/helix
/**
* Partially updates the fields appearing in the given IdealState (input).
* @param clusterName
* @param resourceName
* @param idealState
*/
@Override
public void updateIdealState(String clusterName, String resourceName, IdealState idealState) {
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException(
"updateIdealState failed. Cluster: " + clusterName + " is NOT setup properly.");
}
String zkPath = PropertyPathBuilder.idealState(clusterName, resourceName);
if (!_zkClient.exists(zkPath)) {
throw new HelixException(String.format(
"updateIdealState failed. The IdealState for the given resource does not already exist. Resource name: %s",
resourceName));
}
// Update by way of merge
ZKUtil.createOrUpdate(_zkClient, zkPath, idealState.getRecord(), true, true);
}
代码示例来源: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: org.apache.helix/helix-core
if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
throw new HelixException("cluster: " + clusterName + " is NOT setup.");
String scopeStr = scope.getScopeStr();
String instanceName = scopeStr.substring(scopeStr.lastIndexOf('/') + 1);
if (!ZKUtil.isInstanceSetup(zkClient, scope.getClusterName(), instanceName,
InstanceType.PARTICIPANT)) {
throw new HelixException("instance: " + instanceName + " is NOT setup in cluster: "
ZKUtil.createOrMerge(zkClient, splits[0], update, 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: 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);
}
代码示例来源:origin: org.apache.helix/helix-core
public static void createChildren(ZkClient client, String parentPath, List<ZNRecord> list) {
client.createPersistent(parentPath, true);
if (list != null) {
for (ZNRecord record : list) {
createChildren(client, parentPath, record);
}
}
}
代码示例来源:origin: apache/helix
if (!ZKUtil.isInstanceSetup(_zkclient, _clusterName, _instanceName, _instanceType)) {
if (!autoJoin) {
throw new HelixException("Initial cluster structure is not set up for instance: "
代码示例来源:origin: apache/helix
String path = PropertyPathBuilder.instanceConfig(clusterName, "id7");
ZNRecord record = new ZNRecord("id7");
ZKUtil.createOrMerge(_gZkClient, path, record, true, true);
record = _gZkClient.readData(path);
AssertJUnit.assertEquals("id7", record.getId());
List<String> list = Arrays.asList("value1", "value2");
record.setListField("list", list);
ZKUtil.createOrUpdate(_gZkClient, path, record, true, true);
record = _gZkClient.readData(path);
AssertJUnit.assertEquals(list, record.getListField("list"));
List<String> list2 = Arrays.asList("value3", "value4");
record.setListField("list", list2);
ZKUtil.createOrUpdate(_gZkClient, path, record, true, true);
record = _gZkClient.readData(path);
AssertJUnit.assertEquals(list2, record.getListField("list"));
ZKUtil.createOrUpdate(_gZkClient, path, record, true, true);
record = _gZkClient.readData(path);
AssertJUnit.assertEquals(map, record.getMapField("map"));
Map<String, String> map2 = new HashMap<String, String>() {{put("k2", "v2");}};
record.setMapField("map", map2);
ZKUtil.createOrUpdate(_gZkClient, path, record, true, true);
record = _gZkClient.readData(path);
AssertJUnit.assertEquals(new HashMap<String, String>() {{
代码示例来源:origin: org.apache.helix/helix-core
public static void dropChildren(ZkClient client, String parentPath, List<ZNRecord> list) {
// TODO: check if parentPath exists
if (list != null) {
for (ZNRecord record : list) {
dropChildren(client, parentPath, record);
}
}
}
代码示例来源:origin: apache/helix
/**
* Selectively removes fields appearing in the given IdealState (input) from the IdealState in ZK.
* @param clusterName
* @param resourceName
* @param idealState
*/
@Override
public void removeFromIdealState(String clusterName, String resourceName, IdealState idealState) {
String zkPath = PropertyPathBuilder.idealState(clusterName, resourceName);
ZKUtil.subtract(_zkClient, zkPath, idealState.getRecord());
}
代码示例来源:origin: apache/helix
@Test()
public void testCreateOrReplace() {
String path = PropertyPathBuilder.instanceConfig(clusterName, "id8");
ZNRecord record = new ZNRecord("id8");
ZKUtil.createOrReplace(_gZkClient, path, record, true);
record = _gZkClient.readData(path);
AssertJUnit.assertEquals("id8", record.getId());
record = new ZNRecord("id9");
ZKUtil.createOrReplace(_gZkClient, path, record, true);
record = _gZkClient.readData(path);
AssertJUnit.assertEquals("id9", record.getId());
}
代码示例来源:origin: apache/helix
@Test()
public void testCreateOrMerge() {
String path = PropertyPathBuilder.instanceConfig(clusterName, "id7");
ZNRecord record = new ZNRecord("id7");
List<String> list = Arrays.asList("value1");
record.setListField("list", list);
ZKUtil.createOrMerge(_gZkClient, path, record, true, true);
record = _gZkClient.readData(path);
AssertJUnit.assertEquals(list, record.getListField("list"));
record = new ZNRecord("id7");
List<String> list2 = Arrays.asList("value2");
record.setListField("list", list2);
ZKUtil.createOrMerge(_gZkClient, path, record, true, true);
record = _gZkClient.readData(path);
AssertJUnit.assertEquals(Arrays.asList("value1", "value2"), record.getListField("list"));
Map<String, String> map = new HashMap<String, String>() {{put("k1", "v1");}};
record.setMapField("map", map);
ZKUtil.createOrMerge(_gZkClient, path, record, true, true);
record = _gZkClient.readData(path);
AssertJUnit.assertEquals(map, record.getMapField("map"));
record = new ZNRecord("id7");
Map<String, String> map2 = new HashMap<String, String>() {{put("k2", "v2");}};
record.setMapField("map", map2);
ZKUtil.createOrMerge(_gZkClient, path, record, true, true);
record = _gZkClient.readData(path);
AssertJUnit.assertEquals(new HashMap<String, String>() {{
put("k1", "v1");
put("k2", "v2");
}}, record.getMapField("map"));
}
代码示例来源:origin: apache/helix
private boolean isClusterExist(String cluster) {
HelixZkClient zkClient = getHelixZkClient();
if (ZKUtil.isClusterSetup(cluster, zkClient)) {
return true;
}
return false;
}
}
代码示例来源:origin: apache/helix
if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
throw new HelixException("cluster: " + clusterName + " is NOT setup.");
String scopeStr = scope.getScopeStr();
String instanceName = scopeStr.substring(scopeStr.lastIndexOf('/') + 1);
if (!ZKUtil.isInstanceSetup(zkClient, scope.getClusterName(), instanceName,
InstanceType.PARTICIPANT)) {
throw new HelixException("instance: " + instanceName + " is NOT setup in cluster: "
ZKUtil.createOrMerge(zkClient, splits[0], update, true, true);
代码示例来源: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: apache/helix
@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);
}
代码示例来源:origin: apache/helix
public static void createChildren(HelixZkClient client, String parentPath, List<ZNRecord> list) {
client.createPersistent(parentPath, true);
if (list != null) {
for (ZNRecord record : list) {
createChildren(client, parentPath, record);
}
}
}
I have created a hybrid activation and then setup an ssm agent on my on-premise windows system.我创
我对 python/django 编程很陌生,因为我没有编程背景。我正在在线上课,我只想确切地知道 manage.py 文件的作用。我试过用谷歌搜索它,但除了在 django-admin.py 周围放
我的 DependancyInject 存在结构问题。 情况 我正在为基于体素的游戏创建服务器;它是完全调制的,但相关模块有以下3个。 NetworkModule(发送和接收数据包)WorldModu
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 5年前关闭。 Improve thi
上 Docker正在编写的网站: The MANAGER STATUS column shows node participation in the Raft consensus: No value
我正在尝试使用发布管理作为构建版本的工具,但我很难理解码件、工具和操作之间的真正区别。有人可以分解这三个概念之间的差异以及它们如何相互配合吗? 最佳答案 由于它适用于基于代理的版本: 工具旨在提供自定
当尝试在远程环境中在 pycharm 中执行“run manage.py Task...”时,出现以下错误: ssh://vagrant@127.0.0.1:2222/home/vagrant/.vi
在过去的 48 小时里,我一直在努力解决这个问题,这让我发疯了。 我的 SDK Manager.exe 闪烁一个 cmd 屏幕并在不到一秒内关闭。 经过多方搜索,我终于在调整android.bat并以
我在 this tutorial 之后创建了以下自定义管理命令. from django.core.management.base import BaseCommand, CommandError f
我在一家拥有 2,500 多名员工和同样多的 Android 智能手机的非营利组织工作。 近年来,我们测试了许多 EMM 产品。尽管我们只需要一些非常基本的功能,除了一两个特殊功能,但没有一个能真正赢
我已经在我的网站上安装了 Google 标签管理器,但自从新版本的 Google 标签管理器以来,我无法使用预览选项。每次我点击它时,我都会看到我的网站页面打开,但随后出现以下错误:“Tag Assi
我是 django 的新手,并创建了一个与教程中描述的民意调查网站没有太大区别的应用程序。 在网站上我得到: Exception Type: TemplateSyntaxError Exception
https://cloud.google.com/deployment-manager/docs/configuration/templates/create-basic-template 我可以像这
我们正在使用 Microsoft 的发布管理将我们的 Web 应用程序部署到我们的测试环境 (QA)。它是一个直接的 MVC.Net Web 应用程序。我们的构建生成一个 web 部署包,我们有一个命
我想将 python manage.py 缩短为 ./manage.py。 这可能很简单,但我找不到答案。我在有关 django 的问题的答案之一中看到了一步一步的方法,但我没有记住。尝试在 stac
我想将 python manage.py 缩短为 ./manage.py。 这可能很简单,但我找不到答案。我在有关 django 的问题的答案之一中看到了一步一步的方法,但我没有记住。尝试在 stac
我正在使用安装了 SQL Server Data Tools 的 VS 2012。我有一个 ADO NET 源,它使用 .Net Providers\MySQL 数据提供程序,并试图将一些数据推送到
根据我从文档中阅读的内容 https://developer.android.com/topic/libraries/architecture/workmanager , 它说: The task i
这两个类显然是相关的。 SupportFragmentManager 是否用于使用 FragmentTransaction 生成的 Fragments,而“常规”FragmentManager 专门用
我有一个桌子经理(经理ID、姓名、地址、城市、电话)。如果多个经理来自同一城市,我必须显示城市、姓名和电话详细信息。我的代码是:。但这向我展示了第一行中的一个错误,即“不是按表达式分组”。请救救我!
我是一名优秀的程序员,十分优秀!