gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-14 11:20:49 33 4
gpt4 key购买 nike

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

ZkClient.createPersistent介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-pinot

FakeHelixManager(String clusterName, String instanceName, InstanceType instanceType, String zkAddress) {
 super(clusterName, instanceName, instanceType, zkAddress);
 super._zkclient = new ZkClient(StringUtil.join("/", StringUtils.chomp(ZkStarter.DEFAULT_ZK_STR, "/")),
   ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
 _zkclient.deleteRecursive("/" + clusterName + "/PROPERTYSTORE");
 _zkclient.createPersistent("/" + clusterName + "/PROPERTYSTORE", true);
 setPropertyStore(clusterName);
}

代码示例来源:origin: apache/incubator-pinot

@BeforeTest
public void beforeTest() {
 _zookeeperInstance = ZkStarter.startLocalZkServer();
 _zkClient = new ZkClient(StringUtil.join("/", StringUtils.chomp(ZkStarter.DEFAULT_ZK_STR, "/")),
   ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
 String helixClusterName = "TestTimeBoundaryService";
 _zkClient.deleteRecursive("/" + helixClusterName + "/PROPERTYSTORE");
 _zkClient.createPersistent("/" + helixClusterName + "/PROPERTYSTORE", true);
 _propertyStore = new ZkHelixPropertyStore<>(new ZkBaseDataAccessor<ZNRecord>(_zkClient),
   "/" + helixClusterName + "/PROPERTYSTORE", null);
}

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

public static void createChildren(ZkClient client, String parentPath, ZNRecord nodeRecord) {
 client.createPersistent(parentPath, true);
 String id = nodeRecord.getId();
 String temp = parentPath + "/" + id;
 client.createPersistent(temp, nodeRecord);
}

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

client.createPersistent(zkPath, true);
if (children != null && children.length > 0) {
 client.createPersistent(zkPath, result);
} finally {
 input.close();

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

_zkClient.createPersistent(PropertyPathBuilder.idealState(clusterName));
_zkClient.createPersistent(path, true);
_zkClient.writeData(path, new ZNRecord(clusterName));
path = PropertyPathBuilder.instanceConfig(clusterName);
_zkClient.createPersistent(path);
path = PropertyPathBuilder.resourceConfig(clusterName);
_zkClient.createPersistent(path);
_zkClient.createPersistent(path);
_zkClient.createPersistent(PropertyPathBuilder.liveInstance(clusterName));
_zkClient.createPersistent(PropertyPathBuilder.instance(clusterName));
_zkClient.createPersistent(PropertyPathBuilder.externalView(clusterName));
_zkClient.createPersistent(PropertyPathBuilder.stateModelDef(clusterName));
_zkClient.createPersistent(PropertyPathBuilder.controller(clusterName));
path = PropertyPathBuilder.controllerHistory(clusterName);
final ZNRecord emptyHistory = new ZNRecord(PropertyType.HISTORY.toString());
final List<String> emptyList = new ArrayList<String>();
emptyHistory.setListField(clusterName, emptyList);
_zkClient.createPersistent(path, emptyHistory);
_zkClient.createPersistent(path);
_zkClient.createPersistent(path);

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

_zkClient.createPersistent(root, true);
} catch (Exception e) {

代码示例来源: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 boolean isInstanceSetup(ZkClient zkclient, String clusterName, String instanceName,
  InstanceType type) {
 if (type == InstanceType.PARTICIPANT || type == InstanceType.CONTROLLER_PARTICIPANT) {
  ArrayList<String> requiredPaths = new ArrayList<>();
  requiredPaths.add(PropertyPathBuilder.instanceConfig(clusterName, instanceName));
  requiredPaths.add(PropertyPathBuilder.instanceMessage(clusterName, instanceName));
  requiredPaths.add(PropertyPathBuilder.instanceCurrentState(clusterName, instanceName));
  requiredPaths.add(PropertyPathBuilder.instanceStatusUpdate(clusterName, instanceName));
  requiredPaths.add(PropertyPathBuilder.instanceError(clusterName, instanceName));
  boolean isValid = true;
  for (String path : requiredPaths) {
   if (!zkclient.exists(path)) {
    isValid = false;
    logger.error("Invalid instance setup, missing znode path: {}", path);
   }
  }
  if (isValid) {
   // Create the instance history node if it does not exist.
   // This is for back-compatibility.
   String historyPath = PropertyPathBuilder.instanceHistory(clusterName, instanceName);
   if (!zkclient.exists(historyPath)) {
    zkclient.createPersistent(historyPath, true);
   }
  }
  return isValid;
 }
 return true;
}

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

client.createPersistent(path, true);

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

_zkClient.createPersistent(TEST_ROOT, true);

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

ZkClient zkClient = ZKClientPool.getZkClient(zkAddr);
zkClient.createPersistent("/" + testName, new ZNRecord(testName));
ZNRecord record = zkClient.readData("/" + testName);
Assert.assertEquals(record.getId(), testName);
zkClient.createPersistent("/" + testName, new ZNRecord(testName));
record = zkClient.readData("/" + testName);
Assert.assertEquals(record.getId(), testName);

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

} else {
 try {
  zkClient.createPersistent(path, true);
 } catch (ZkNodeExistsException e) {

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

public void post(String zkServer, Message message, String clusterName, String instanceName) {
 ZkClient client = new ZkClient(zkServer);
 client.setZkSerializer(new ZNRecordSerializer());
 String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId());
 client.delete(path);
 ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName));
 message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString()));
 message.setTgtName(record.getId());
 // System.out.println(message);
 client.createPersistent(path, message.getRecord());
}

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

@Test()
void testGetStat() {
 String path = "/tmp/getStatTest";
 _zkClient.deleteRecursively(path);
 Stat stat, newStat;
 stat = _zkClient.getStat(path);
 AssertJUnit.assertNull(stat);
 _zkClient.createPersistent(path, true);
 stat = _zkClient.getStat(path);
 AssertJUnit.assertNotNull(stat);
 newStat = _zkClient.getStat(path);
 AssertJUnit.assertEquals(stat, newStat);
 _zkClient.writeData(path, new ZNRecord("Test"));
 newStat = _zkClient.getStat(path);
 AssertJUnit.assertNotSame(stat, newStat);
}

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