gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-13 21:40:03 27 4
gpt4 key购买 nike

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

ZkBaseDataAccessor.doSet介绍

[英]sync set
[中]同步集

代码示例

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

/**
 * sync set
 */
@Override
public boolean set(String path, T record, int expectVersion, int options) {
 AccessResult result = doSet(path, record, expectVersion, options);
 return result._retCode == RetCode.OK;
}

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

/**
 * sync set
 */
@Override
public boolean set(String path, T record, int expectVersion, int options) {
 AccessResult result = doSet(path, record, expectVersion, options);
 return result._retCode == RetCode.OK;
}

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

@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;
}

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