gpt4 book ai didi

io.pravega.controller.store.stream.ZKStoreHelper.createEphemeralZNode()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:58:50 26 4
gpt4 key购买 nike

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

ZKStoreHelper.createEphemeralZNode介绍

暂无

代码示例

代码示例来源:origin: pravega/pravega

@Override
public CompletableFuture<Boolean> takeBucketOwnership(int bucket, String processId, Executor executor) {
  Preconditions.checkArgument(bucket < bucketCount);
  // try creating an ephemeral node
  String bucketPath = ZKPaths.makePath(BUCKET_OWNERSHIP_PATH, String.valueOf(bucket));
  return storeHelper.createEphemeralZNode(bucketPath, SerializationUtils.serialize(processId))
      .thenCompose(created -> {
        if (!created) {
          // Note: data may disappear by the time we do a getData. Let exception be thrown from here
          // so that caller may retry.
          return storeHelper.getData(bucketPath)
              .thenApply(data -> (SerializationUtils.deserialize(data.getData())).equals(processId));
        } else {
          return CompletableFuture.completedFuture(true);
        }
      });
}

代码示例来源:origin: pravega/pravega

@Test
  public void testEphemeralNode() {
    CuratorFramework cli2 = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), new RetryNTimes(0, 0));
    cli2.start();
    ZKStoreHelper zkStoreHelper2 = new ZKStoreHelper(cli2, executor);

    Assert.assertTrue(zkStoreHelper2.createEphemeralZNode("/testEphemeral", new byte[0]).join());
    Assert.assertNotNull(zkStoreHelper2.getData("/testEphemeral").join());
    zkStoreHelper2.getClient().close();
    // let session get expired.
    // now read the data again. Verify that node no longer exists
    AssertExtensions.assertFutureThrows("", Futures.delayedFuture(() -> zkStoreHelper.getData("/testEphemeral"), 1000, executor),
        e -> e instanceof StoreException.DataNotFoundException);
  }
}

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