本文整理了Java中io.pravega.controller.store.stream.ZKStoreHelper.getClient()
方法的一些代码示例,展示了ZKStoreHelper.getClient()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKStoreHelper.getClient()
方法的具体详情如下:
包路径:io.pravega.controller.store.stream.ZKStoreHelper
类名称: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);
内容来源于网络,如有侵权,请联系作者删除!