gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-13 22:02:03 24 4
gpt4 key购买 nike

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

ZkBaseDataAccessor.exists介绍

[英]sync exists
[中]同步存在

代码示例

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

public AutoFallbackPropertyStore(ZkBaseDataAccessor<T> accessor, String root, String fallbackRoot) {
 super(accessor, root, null);
 if (accessor.exists(fallbackRoot, 0)) {
  _fallbackStore = new ZkHelixPropertyStore<T>(accessor, fallbackRoot, null);
 } else {
  LOG.info("fallbackRoot: " + fallbackRoot
    + " doesn't exist, skip creating fallback property store");
  _fallbackStore = null;
 }
}

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

public AutoFallbackPropertyStore(ZkBaseDataAccessor<T> accessor, String root, String fallbackRoot) {
 super(accessor, root, null);
 if (accessor.exists(fallbackRoot, 0)) {
  _fallbackStore = new ZkHelixPropertyStore<T>(accessor, fallbackRoot, null);
 } else {
  LOG.info("fallbackRoot: " + fallbackRoot
    + " doesn't exist, skip creating fallback property store");
  _fallbackStore = null;
 }
}

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

@Override
public boolean exists(String path, int options) {
 String clientPath = path;
 String serverPath = prependChroot(clientPath);
 Cache<T> cache = getCache(serverPath);
 if (cache != null) {
  boolean exists = cache.exists(serverPath);
  if (exists) {
   return true;
  }
 }
 // if not exists in cache, always fall back to zk
 return _baseAccessor.exists(serverPath, options);
}

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

@Override
public boolean exists(String path, int options) {
 String clientPath = path;
 String serverPath = prependChroot(clientPath);
 Cache<T> cache = getCache(serverPath);
 if (cache != null) {
  boolean exists = cache.exists(serverPath);
  if (exists) {
   return true;
  }
 }
 // if not exists in cache, always fall back to zk
 return _baseAccessor.exists(serverPath, options);
}

代码示例来源: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

@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: apache/helix

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");
Assert.assertNotNull(record);
Assert.assertEquals(record.getId(), "0");
Assert.assertFalse(baseAccessor.exists(String.format("%s%s", root, path), 0),
  "Should not exist under new location after get");

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

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");

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

for (int i = 0; i < 20; i++) {
 String path = String.format("/%d", i);
 Assert.assertFalse(baseAccessor.exists(String.format("%s%s", root, path), 0),
   "Should not exist under new location");
 if (i < 10) {
  Assert.assertTrue(baseAccessor.exists(String.format("%s%s", fallbackRoot, path), 0),
    "Should exist under fallback location");
 } else {
  Assert.assertFalse(baseAccessor.exists(String.format("%s%s", fallbackRoot, path), 0),
    "Should not exist under fallback location");
  Assert.assertNull(record);
 Assert.assertFalse(baseAccessor.exists(String.format("%s%s", root, path), 0),
   "Should not exist under new location after get");

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

for (int i = 0; i < 10; i++) {
 String path = String.format("/%d", i);
 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");
 paths.add(path);
 Assert.assertNotNull(record);
 Assert.assertEquals(record.getId(), Integer.toString(i));
 Assert.assertFalse(baseAccessor.exists(String.format("%s%s", root, path), 0),
   "Should not exist under new location after get");

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

String path = String.format("/%d", i);
if (i < 10) {
 Assert.assertTrue(baseAccessor.exists(String.format("%s%s", fallbackRoot, path), 0),
   "Should exist under fallback location");
 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");
 Assert.assertTrue(baseAccessor.exists(String.format("%s%s", root, path), 0),
   "Should exist under new location");

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

for (int i = 0; i < 10; i++) {
 String path = String.format("/%d", i);
 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");
 paths.add(path);

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

Assert.assertTrue(baseAccessor.exists(String.format("%s%s", root, path), 0),
  "Should exist under new location");
Assert.assertTrue(baseAccessor.exists(String.format("%s%s", fallbackRoot, path), 0),
  "Should exist under fallback location");

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

String path = String.format("/%d", i);
if (i < 10) {
 Assert.assertTrue(baseAccessor.exists(String.format("%s%s", root, path), 0),
   "Should exist under new location");
 Assert.assertTrue(baseAccessor.exists(String.format("%s%s", fallbackRoot, path), 0),
   "Should exist under fallback location");
} else {
 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");
 Assert.assertNull(record.getSimpleField("key"));
} else {
 Assert.assertFalse(baseAccessor.exists(String.format("%s%s", fallbackRoot, path), 0),
   "Should not exist under fallback location");

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

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");

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

for (int i = 0; i < 10; i++) {
 String path = String.format("/%d", i);
 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");
 paths.add(path);

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

paths.add(PropertyPathBuilder.instanceMessage(root, "host_1", msgId));
boolean[] exists = accessor.exists(paths, 0);
for (int i = 0; i < 10; i++) {
 String msgId = "msg_" + i;

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