- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.helix.manager.zk.ZkBaseDataAccessor
类的一些代码示例,展示了ZkBaseDataAccessor
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkBaseDataAccessor
类的具体详情如下:
包路径:org.apache.helix.manager.zk.ZkBaseDataAccessor
类名称:ZkBaseDataAccessor
暂无
代码示例来源:origin: apache/incubator-pinot
void setPropertyStore(String clusterName) {
_propertyStore =
new ZkHelixPropertyStore<>(new ZkBaseDataAccessor<ZNRecord>(_zkclient), "/" + clusterName + "/PROPERTYSTORE",
null);
}
代码示例来源:origin: apache/incubator-pinot
LOGGER.info("Updating IdealState for table {}", tableName);
if (zkBaseDataAccessor
.set(idealStateKey.getPath(), nextIdealState.getRecord(), currentIdealState.getRecord().getVersion(),
AccessOption.PERSISTENT)) {
代码示例来源:origin: apache/helix
String root = String.format("/%s/%s", clusterName, PropertyType.PROPERTYSTORE.name());
String fallbackRoot = String.format("/%s/%s", clusterName, "HELIX_PROPERTYSTORE");
ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
baseAccessor.create(path, new ZNRecord(Integer.toString(i)), AccessOption.PERSISTENT);
Assert.assertFalse(baseAccessor.exists(String.format("%s%s", root, path), 0),
"Should not exist under new location");
Assert.assertTrue(baseAccessor.exists(String.format("%s%s", fallbackRoot, path), 0),
"Should exist under fallback location");
ZNRecord record = new ZNRecord("new0");
Assert.assertTrue(succeed);
record = baseAccessor.get(String.format("%s%s", fallbackRoot, path), null, 0);
Assert.assertNotNull(record);
Assert.assertEquals(record.getId(), "0");
record = baseAccessor.get(String.format("%s%s", root, path), null, 0);
Assert.assertNotNull(record);
Assert.assertEquals(record.getId(), "new0");
代码示例来源:origin: apache/helix
@Test
public void testSyncExist() {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String testName = className + "_" + methodName;
System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis()));
String path = String.format("/%s/%s", _rootPath, "msg_0");
ZNRecord record = new ZNRecord("msg_0");
ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
boolean success = accessor.exists(path, 0);
Assert.assertFalse(success);
success = accessor.create(path, record, AccessOption.EPHEMERAL);
Assert.assertTrue(success);
success = accessor.exists(path, 0);
Assert.assertTrue(success);
System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));
}
代码示例来源:origin: apache/helix
ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<>(_gZkClient);
boolean[] success = accessor.createChildren(paths, records, AccessOption.PERSISTENT);
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
success = accessor.setChildren(paths, records, AccessOption.PERSISTENT);
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
success = accessor.updateChildren(paths, znrecordUpdaters, AccessOption.PERSISTENT);
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
records = accessor.getChildren(parentPath, null, 0);
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
boolean[] exists = accessor.exists(paths, 0);
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
Stat[] stats = accessor.getStats(paths, 0);
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
success = accessor.remove(paths, 0);
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
代码示例来源:origin: apache/helix
@Test
public void testSyncCreate() {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String testName = className + "_" + methodName;
System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis()));
String path = String.format("/%s/%s", _rootPath, "msg_0");
ZNRecord record = new ZNRecord("msg_0");
ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<>(_gZkClient);
boolean success = accessor.create(path, record, AccessOption.PERSISTENT);
Assert.assertTrue(success);
ZNRecord getRecord = _gZkClient.readData(path);
Assert.assertNotNull(getRecord);
Assert.assertEquals(getRecord.getId(), "msg_0");
record.setSimpleField("key0", "value0");
success = accessor.create(path, record, AccessOption.PERSISTENT);
Assert.assertFalse(success, "Should fail since node already exists");
getRecord = _gZkClient.readData(path);
Assert.assertNotNull(getRecord);
Assert.assertEquals(getRecord.getSimpleFields().size(), 0);
System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));
}
代码示例来源:origin: org.apache.helix/helix-core
public static void main(String[] args) {
ZkClient zkclient = new ZkClient("localhost:2191");
zkclient.setZkSerializer(new ZNRecordSerializer());
ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<ZNRecord>(zkclient);
List<List<String>> pathsCreated =
new ArrayList<List<String>>(Collections.<List<String>> nCopies(createPaths.size(), null));
accessor.create(createPaths, createRecords, needCreate, pathsCreated, AccessOption.PERSISTENT);
System.out.println("pathsCreated: " + pathsCreated);
new ArrayList<List<String>>(Collections.<List<String>> nCopies(setPaths.size(), null));
boolean[] success =
accessor.set(setPaths, setRecords, pathsCreated, null, AccessOption.PERSISTENT);
System.out.println("pathsCreated: " + pathsCreated);
System.out.println("setSuccess: " + Arrays.toString(success));
accessor.update(updatePaths, updaters, pathsCreated, null, AccessOption.PERSISTENT);
for (int i = 0; i < updatePaths.size(); i++) {
success[i] = updateRecords.get(i) != null;
代码示例来源:origin: apache/helix
.buildZkClient(new HelixZkClient.ZkConnectionConfig(ZK_ADDR));
extZkclient.setZkSerializer(new ZNRecordSerializer());
ZkBaseDataAccessor<ZNRecord> extBaseAccessor = new ZkBaseDataAccessor<ZNRecord>(extZkclient);
String extViewPath = PropertyPathBuilder.externalView(clusterName);
ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
extBaseAccessor.create(curStatePath, null, AccessOption.PERSISTENT);
boolean[] success = extBaseAccessor.createChildren(paths, records, AccessOption.PERSISTENT);
for (int i = 0; i < 10; i++) {
Assert.assertTrue(success[i], "Should succeed in create: " + paths.get(i));
updaters.add(updater);
success = extBaseAccessor.updateChildren(paths, updaters, AccessOption.PERSISTENT);
records.add(record);
success = extBaseAccessor.setChildren(paths, records, AccessOption.PERSISTENT);
for (int i = 0; i < 10; i++) {
Assert.assertTrue(success[i], "Should succeed in set: " + paths.get(i));
success = extBaseAccessor.remove(paths, 0);
for (int i = 0; i < 10; i++) {
Assert.assertTrue(success[i], "Should succeed in remove: " + paths.get(i));
代码示例来源:origin: apache/helix
@Test
public void testSyncGetStat() {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String testName = className + "_" + methodName;
System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis()));
String path = String.format("/%s/%s", _rootPath, "msg_0");
ZNRecord record = new ZNRecord("msg_0");
ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
Stat stat = accessor.getStat(path, 0);
Assert.assertNull(stat);
boolean success = accessor.create(path, record, AccessOption.EPHEMERAL);
Assert.assertTrue(success);
stat = accessor.getStat(path, 0);
Assert.assertNotNull(stat);
Assert.assertEquals(stat.getVersion(), 0);
Assert.assertNotSame(stat.getEphemeralOwner(), 0);
System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));
}
代码示例来源:origin: apache/helix
@Test
public void testSyncRemove() {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String testName = className + "_" + methodName;
System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis()));
String path = String.format("/%s/%s", _rootPath, "msg_0");
ZNRecord record = new ZNRecord("msg_0");
ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
// Base data accessor shall not fail when remove a non-exist path
boolean success = accessor.remove(path, 0);
Assert.assertTrue(success);
success = accessor.create(path, record, AccessOption.PERSISTENT);
Assert.assertTrue(success);
ZNRecord getRecord = _gZkClient.readData(path);
Assert.assertNotNull(getRecord);
Assert.assertEquals(getRecord.getId(), "msg_0");
success = accessor.remove(path, 0);
Assert.assertTrue(success);
Assert.assertFalse(_gZkClient.exists(path));
System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));
}
代码示例来源:origin: apache/helix
ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
String path = keyBuilder.liveInstance("localhost_12918").getPath();
Stat stat = new Stat();
ZNRecord data = accessor.get(path, stat, 2);
data.getSimpleFields().put("SESSION_ID", "invalid-id");
accessor.set(path, data, 2);
Thread.sleep(2000);
代码示例来源:origin: apache/helix
@Test
public void testSyncDoSet() {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String testName = className + "_" + methodName;
System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis()));
String path = String.format("/%s/%s/%s", _rootPath, "msg_0", "submsg_0");
ZNRecord record = new ZNRecord("submsg_0");
ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
AccessResult result = accessor.doSet(path, record, -1, AccessOption.PERSISTENT);
Assert.assertEquals(result._retCode, RetCode.OK);
Assert.assertEquals(result._pathCreated.size(), 3);
Assert.assertTrue(result._pathCreated.contains(String.format("/%s/%s", _rootPath, "msg_0")));
Assert.assertTrue(result._pathCreated.contains(path));
Assert.assertTrue(_gZkClient.exists(String.format("/%s/%s", _rootPath, "msg_0")));
ZNRecord getRecord = _gZkClient.readData(path);
Assert.assertNotNull(getRecord);
Assert.assertEquals(getRecord.getId(), "submsg_0");
System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));
}
代码示例来源:origin: apache/helix
@Test
public void testFailOnSingleGet() {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String clusterName = className + "_" + methodName;
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
String root = String.format("/%s/%s", clusterName, PropertyType.PROPERTYSTORE.name());
String fallbackRoot = String.format("/%s/%s", clusterName, "HELIX_PROPERTYSTORE");
ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
AutoFallbackPropertyStore<ZNRecord> store =
new AutoFallbackPropertyStore<ZNRecord>(baseAccessor, root, fallbackRoot);
String path = String.format("/%d", 0);
Assert.assertFalse(baseAccessor.exists(String.format("%s%s", root, path), 0),
"Should not exist under new location");
Assert.assertFalse(baseAccessor.exists(String.format("%s%s", fallbackRoot, path), 0),
"Should not exist under fallback location");
// test single exist
boolean exist = store.exists(path, 0);
Assert.assertFalse(exist);
// test single getStat
Stat stat = store.getStat(path, 0);
Assert.assertNull(stat);
// test single get
ZNRecord record = store.get(path, null, 0);
Assert.assertNull(record);
System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public boolean[] setChildren(List<String> paths, List<T> records, int options) {
final int size = paths.size();
List<String> serverPaths = prependChroot(paths);
Cache<T> cache = getCache(serverPaths);
if (cache != null) {
try {
cache.lockWrite();
List<Stat> setStats = new ArrayList<Stat>();
List<List<String>> pathsCreatedList =
new ArrayList<List<String>>(Collections.<List<String>> nCopies(size, null));
boolean[] success =
_baseAccessor.set(serverPaths, records, pathsCreatedList, setStats, options);
for (int i = 0; i < size; i++) {
updateCache(cache, pathsCreatedList.get(i), success[i], serverPaths.get(i),
records.get(i), setStats.get(i));
}
return success;
} finally {
cache.unlockWrite();
}
}
return _baseAccessor.setChildren(serverPaths, records, options);
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public boolean set(String path, T data, int expectVersion, int options) {
String clientPath = path;
String serverPath = prependChroot(clientPath);
Cache<T> cache = getCache(serverPath);
boolean success = false;
try {
if (cache != null) {
cache.lockWrite();
ZkBaseDataAccessor<T>.AccessResult result =
_baseAccessor.doSet(serverPath, data, expectVersion, options);
success = result._retCode == RetCode.OK;
updateCache(cache, result._pathCreated, success, serverPath, data, result._stat);
} else {
// no cache
success = _baseAccessor.set(serverPath, data, expectVersion, options);
}
} catch (Exception e) {
} finally {
if (cache != null) {
cache.unlockWrite();
}
}
return success;
}
代码示例来源:origin: org.apache.helix/helix-core
try {
merged = accessor.get(mergedKey, readStat, options);
} catch (ZkNoNodeException e) {
success = accessor.set(mergedKey, merged, readStat.getVersion(), options);
if (!success) {
LOG.error("Fail to group commit. path: " + mergedKey + ", value: " + merged
代码示例来源:origin: org.apache.helix/helix-core
@Override
public List<T> get(List<String> paths, List<Stat> stats, int options,
boolean throwException) throws HelixException {
boolean[] needRead = new boolean[paths.size()];
Arrays.fill(needRead, true);
return get(paths, stats, needRead, throwException);
}
代码示例来源:origin: apache/helix
@Override
public Stat getStat(String path, int options) {
String clientPath = path;
String serverPath = prependChroot(clientPath);
Cache<T> cache = getCache(serverPath);
if (cache != null) {
Stat stat = new Stat();
ZNode znode = cache.get(serverPath);
if (znode != null) {
return znode.getStat();
} else {
// if cache miss, fall back to zk and update cache
try {
cache.lockWrite();
T data = _baseAccessor.get(serverPath, stat, options);
cache.update(serverPath, data, stat);
} catch (ZkNoNodeException e) {
return null;
} finally {
cache.unlockWrite();
}
return stat;
}
}
// no cache
return _baseAccessor.getStat(serverPath, options);
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public boolean[] createChildren(List<String> paths, List<T> records, int options) {
final int size = paths.size();
List<String> serverPaths = prependChroot(paths);
Cache<T> cache = getCache(serverPaths);
if (cache != null) {
try {
cache.lockWrite();
boolean[] needCreate = new boolean[size];
Arrays.fill(needCreate, true);
List<List<String>> pathsCreatedList =
new ArrayList<List<String>>(Collections.<List<String>> nCopies(size, null));
CreateCallbackHandler[] createCbList =
_baseAccessor.create(serverPaths, records, needCreate, pathsCreatedList, options);
boolean[] success = new boolean[size];
for (int i = 0; i < size; i++) {
CreateCallbackHandler cb = createCbList[i];
success[i] = (Code.get(cb.getRc()) == Code.OK);
updateCache(cache, pathsCreatedList.get(i), success[i], serverPaths.get(i),
records.get(i), ZNode.ZERO_STAT);
}
return success;
} finally {
cache.unlockWrite();
}
}
// no cache
return _baseAccessor.createChildren(serverPaths, records, options);
}
代码示例来源:origin: org.apache.helix/helix-core
get(paths, curStats, Arrays.copyOf(needUpdate, needUpdate.length), false);
createCbList = create(paths, newDataList, needCreate, pathsCreated, options);
for (int i = 0; i < paths.size(); i++) {
CreateCallbackHandler createCb = createCbList[i];
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、姓名、地址、城市、电话)。如果多个经理来自同一城市,我必须显示城市、姓名和电话详细信息。我的代码是:。但这向我展示了第一行中的一个错误,即“不是按表达式分组”。请救救我!
我是一名优秀的程序员,十分优秀!