gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-13 10:59:11 25 4
gpt4 key购买 nike

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

ZKStoreHelper.getClient介绍

暂无

代码示例

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

@SneakyThrows(Exception.class)
private NodeCache registerWatch(String watchPath) {
  NodeCache nodeCache = new NodeCache(zkStoreHelper.getClient(), watchPath);
  NodeCacheListener watchListener = () -> {
    currentBatch.set(nodeCache.getCurrentData().getStat().getVersion());
    log.debug("Current batch for {} changed to {}", gcName, currentBatch.get());
  };
  nodeCache.getListenable().addListener(watchListener);
  nodeCache.start();
  return nodeCache;
}

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

@Override
@SneakyThrows
public void registerBucketOwnershipListener(BucketOwnershipListener listener) {
  Preconditions.checkNotNull(listener);
  PathChildrenCacheListener bucketListener = (client, event) -> {
    switch (event.getType()) {
      case CHILD_ADDED:
        // no action required
        break;
      case CHILD_REMOVED:
        int bucketId = Integer.parseInt(ZKPaths.getNodeFromPath(event.getData().getPath()));
        listener.notify(new BucketNotification(bucketId, BucketNotification.NotificationType.BucketAvailable));
        break;
      case CONNECTION_LOST:
        listener.notify(new BucketNotification(Integer.MIN_VALUE, BucketNotification.NotificationType.ConnectivityError));
        break;
      default:
        log.warn("Received unknown event {}", event.getType());
    }
  };
  bucketOwnershipCacheRef.compareAndSet(null, new PathChildrenCache(storeHelper.getClient(), BUCKET_OWNERSHIP_PATH, true));
  bucketOwnershipCacheRef.get().getListenable().addListener(bucketListener);
  bucketOwnershipCacheRef.get().start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
  log.info("bucket ownership listener registered");
}

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

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

bucketCacheMap.put(bucket, new PathChildrenCache(storeHelper.getClient(), bucketRoot, true));
PathChildrenCache pathChildrenCache = bucketCacheMap.get(bucket);
pathChildrenCache.getListenable().addListener(bucketListener);

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