- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中io.pravega.controller.store.stream.ZKStoreHelper
类的一些代码示例,展示了ZKStoreHelper
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKStoreHelper
类的具体详情如下:
包路径:io.pravega.controller.store.stream.ZKStoreHelper
类名称:ZKStoreHelper
暂无
代码示例来源:origin: pravega/pravega
@Override
public CompletableFuture<Void> createScope() {
return store.addNode(scopePath);
}
代码示例来源:origin: pravega/pravega
@Override
public CompletableFuture<String> getScopeConfiguration(final String scopeName) {
return storeHelper.checkExists(String.format("/store/%s", scopeName))
.thenApply(scopeExists -> {
if (scopeExists) {
return scopeName;
} else {
throw StoreException.create(StoreException.Type.DATA_NOT_FOUND, scopeName);
}
});
}
代码示例来源:origin: pravega/pravega
CompletableFuture<Integer> createZNodeIfNotExist(final String path, final byte[] data) {
return createZNodeIfNotExist(path, data, true);
}
代码示例来源:origin: pravega/pravega
private CompletableFuture<Void> gcCompletedTxn() {
return storeHelper.getChildren(COMPLETED_TX_BATCH_ROOT_PATH)
.thenApply(children -> {
// retain latest two and delete remainder.
List<Long> list = children.stream().map(Long::parseLong).sorted().collect(Collectors.toList());
if (list.size() > 2) {
return list.subList(0, list.size() - 2);
} else {
return new ArrayList<Long>();
}
}
)
.thenCompose(toDeleteList -> {
log.debug("deleting batches {} on new scheme" + toDeleteList);
// delete all those marked for toDelete.
return Futures.allOf(toDeleteList.stream()
.map(toDelete -> storeHelper.deleteTree(String.format(COMPLETED_TX_BATCH_PATH, toDelete)))
.collect(Collectors.toList()));
});
}
代码示例来源: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
@Override
public CompletableFuture<Void> addUpdateStreamForAutoStreamCut(final String scope, final String stream, final RetentionPolicy retentionPolicy,
final OperationContext context, final Executor executor) {
Preconditions.checkNotNull(retentionPolicy);
int bucket = getBucket(scope, stream);
String retentionPath = String.format(RETENTION_PATH, bucket, encodedScopedStreamName(scope, stream));
byte[] serialize = SerializationUtils.serialize(retentionPolicy);
return storeHelper.getData(retentionPath)
.exceptionally(e -> {
if (e instanceof StoreException.DataNotFoundException) {
return null;
} else {
throw new CompletionException(e);
}
}).thenCompose(data -> {
if (data == null) {
return Futures.toVoid(storeHelper.createZNodeIfNotExist(retentionPath, serialize));
} else {
return Futures.toVoid(storeHelper.setData(retentionPath, new Data(serialize, data.getVersion())));
}
});
}
代码示例来源:origin: pravega/pravega
@Test(timeout = 10000)
public void testGetActiveTxn() throws Exception {
ZKStoreHelper storeHelper = spy(new ZKStoreHelper(cli, executor));
ZKStream stream = new ZKStream("scope", "stream", storeHelper);
final int startingSegmentNumber = 0;
storeHelper.createZNodeIfNotExist("/store/scope").join();
final ScalingPolicy policy1 = ScalingPolicy.fixed(2);
final StreamConfiguration configuration1 = StreamConfiguration.builder().scalingPolicy(policy1).build();
stream.create(configuration1, System.currentTimeMillis(), startingSegmentNumber).join();
stream.updateState(State.ACTIVE).join();
UUID txId = stream.generateNewTxnId(0, 0L).join();
stream.createTransaction(txId, 1000L, 1000L).join();
String activeTxPath = stream.getActiveTxPath(0, txId.toString());
// throw DataNotFoundException for txn path
doReturn(Futures.failedFuture(StoreException.create(StoreException.Type.DATA_NOT_FOUND, "txn data not found")))
.when(storeHelper).getData(eq(activeTxPath));
Map<String, Data> result = stream.getCurrentTxns().join();
// verify that call succeeds and no active txns were found
assertTrue(result.isEmpty());
// throw generic exception for txn path
doReturn(Futures.failedFuture(new RuntimeException())).when(storeHelper).getData(eq(activeTxPath));
ZKStream stream2 = new ZKStream("scope", "stream", storeHelper);
// verify that the call fails
AssertExtensions.assertFutureThrows("", stream2.getCurrentTxns(), e -> Exceptions.unwrap(e) instanceof RuntimeException);
reset(storeHelper);
ZKStream stream3 = new ZKStream("scope", "stream", storeHelper);
result = stream3.getCurrentTxns().join();
assertEquals(1, result.size());
}
代码示例来源:origin: pravega/pravega
@Override
CompletableFuture<Data> getEpochTransitionNode() {
return store.getData(epochTransitionPath);
}
代码示例来源:origin: pravega/pravega
/**
* List Scopes in the cluster.
*
* @return A list of scopes.
*/
public CompletableFuture<List<String>> listScopes() {
return getChildren("/store");
}
代码示例来源:origin: pravega/pravega
@Override
public CompletableFuture<Map<String, Data>> getTxnInEpoch(int epoch) {
return Futures.exceptionallyExpecting(store.getChildren(getEpochPath(epoch)),
e -> Exceptions.unwrap(e) instanceof StoreException.DataNotFoundException, Collections.emptyList())
.thenCompose(txIds -> Futures.allOfWithResults(txIds.stream().collect(
Collectors.toMap(txId -> txId, txId -> Futures.exceptionallyExpecting(store.getData(getActiveTxPath(epoch, txId)),
e -> Exceptions.unwrap(e) instanceof StoreException.DataNotFoundException, EMPTY_DATA)))
).thenApply(txnMap -> txnMap.entrySet().stream().filter(x -> !x.getValue().equals(EMPTY_DATA))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)))
);
}
代码示例来源: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
@VisibleForTesting
ZKStreamMetadataStore(CuratorFramework client, int bucketCount, Executor executor, Duration gcPeriod) {
super(new ZKHostIndex(client, "/hostTxnIndex", executor), bucketCount);
storeHelper = new ZKStoreHelper(client, executor);
bucketCacheMap = new ConcurrentHashMap<>();
bucketOwnershipCacheRef = new AtomicReference<>();
this.lock = new Object();
this.counter = new AtomicInt96();
this.limit = new AtomicInt96();
this.refreshFutureRef = null;
this.completedTxnGC = new ZKGarbageCollector(COMPLETED_TXN_GC_NAME, storeHelper, this::gcCompletedTxn, gcPeriod);
this.completedTxnGC.startAsync();
this.completedTxnGC.awaitRunning();
}
代码示例来源:origin: pravega/pravega
@Test
public void testDeleteNode() throws ExecutionException, InterruptedException, IOException {
Assert.assertNull(zkStoreHelper.addNode("/test/test1").get());
Assert.assertNull(zkStoreHelper.addNode("/test/test1/test2").get());
AssertExtensions.assertFutureThrows("Should throw NodeNotEmptyException", zkStoreHelper.deleteNode("/test/test1"),
e -> e instanceof StoreException.DataNotEmptyException);
Assert.assertNull(zkStoreHelper.deleteNode("/test/test1/test2").get());
Assert.assertNull(zkStoreHelper.deleteNode("/test/test1").get());
AssertExtensions.assertFutureThrows("Should throw NodeNotFoundException", zkStoreHelper.deleteNode("/test/test1"),
e -> e instanceof StoreException.DataNotFoundException);
zkServer.stop();
AssertExtensions.assertFutureThrows("Should throw UnknownException", zkStoreHelper.deleteNode("/test/test1"),
e -> e instanceof StoreException.StoreConnectionException);
}
代码示例来源:origin: pravega/pravega
@Test
public void verifyBucketInitialization() {
ZKStoreHelper zkStoreHelper = new ZKStoreHelper(cli, executor);
// Verify that buckets are not initialized.
assertFalse(zkStoreHelper.checkExists(ZKStreamMetadataStore.BUCKET_ROOT_PATH).join());
// Execute the initialization of buckets in ZKStreamMetadataStore.
store.createBucketsRoot().join();
// Verify that the expected buckets are created after the execution of createBucketsRoot().
assertTrue(zkStoreHelper.checkExists(ZKStreamMetadataStore.BUCKET_ROOT_PATH).join());
assertTrue(zkStoreHelper.checkExists(ZKStreamMetadataStore.BUCKET_OWNERSHIP_PATH).join());
for (int i = 0; i < ((AbstractStreamMetadataStore) store).getBucketCount(); i++) {
assertTrue(zkStoreHelper.checkExists(String.format(ZKStreamMetadataStore.BUCKET_PATH, i)).join());
}
}
代码示例来源:origin: pravega/pravega
@Test
public void testCounterConcurrentUpdates() {
ZKStoreHelper storeHelper = spy(new ZKStoreHelper(cli, executor));
storeHelper.createZNodeIfNotExist("/store/scope").join();
ZKStreamMetadataStore zkStore = spy((ZKStreamMetadataStore) this.store);
ZKStreamMetadataStore zkStore2 = spy((ZKStreamMetadataStore) this.store);
ZKStreamMetadataStore zkStore3 = spy((ZKStreamMetadataStore) this.store);
zkStore.setStoreHelperForTesting(storeHelper);
// first call should get the new range from store
Int96 counter = zkStore.getNextCounter().join();
// verify that the generated counter is from new range
assertEquals(0, counter.getMsb());
assertEquals(1L, counter.getLsb());
assertEquals(zkStore.getCounterForTesting(), counter);
Int96 limit = zkStore.getLimitForTesting();
assertEquals(ZKStreamMetadataStore.COUNTER_RANGE, limit.getLsb());
zkStore3.getRefreshFuture().join();
assertEquals(ZKStreamMetadataStore.COUNTER_RANGE, zkStore3.getCounterForTesting().getLsb());
assertEquals(ZKStreamMetadataStore.COUNTER_RANGE * 2, zkStore3.getLimitForTesting().getLsb());
zkStore2.getRefreshFuture().join();
assertEquals(ZKStreamMetadataStore.COUNTER_RANGE * 2, zkStore2.getCounterForTesting().getLsb());
assertEquals(ZKStreamMetadataStore.COUNTER_RANGE * 3, zkStore2.getLimitForTesting().getLsb());
zkStore.getRefreshFuture().join();
assertEquals(ZKStreamMetadataStore.COUNTER_RANGE * 3, zkStore.getCounterForTesting().getLsb());
assertEquals(ZKStreamMetadataStore.COUNTER_RANGE * 4, zkStore.getLimitForTesting().getLsb());
}
代码示例来源:origin: pravega/pravega
CompletableFuture<Void> addNode(final String path) {
final CompletableFuture<Void> result = new CompletableFuture<>();
try {
client.create().creatingParentsIfNeeded().inBackground(
callback(x -> result.complete(null), result::completeExceptionally, path), executor).forPath(path);
} catch (Exception e) {
result.completeExceptionally(StoreException.create(StoreException.Type.UNKNOWN, e, path));
}
return result;
}
代码示例来源: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
public CompletableFuture<Void> deleteScope() {
return store.deleteNode(scopePath);
}
代码示例来源:origin: pravega/pravega
@Override
CompletableFuture<Void> recordLastStreamSegment(final String scope, final String stream, final int lastActiveSegment,
OperationContext context, final Executor executor) {
final String deletePath = String.format(DELETED_STREAMS_PATH, getScopedStreamName(scope, stream));
byte[] maxSegmentNumberBytes = new byte[Integer.BYTES];
BitConverter.writeInt(maxSegmentNumberBytes, 0, lastActiveSegment);
return storeHelper.getData(deletePath)
.exceptionally(e -> {
if (e instanceof StoreException.DataNotFoundException) {
return null;
} else {
throw new CompletionException(e);
}
})
.thenCompose(data -> {
log.debug("Recording last segment {} for stream {}/{} on deletion.", lastActiveSegment, scope, stream);
if (data == null) {
return Futures.toVoid(storeHelper.createZNodeIfNotExist(deletePath, maxSegmentNumberBytes));
} else {
final int oldLastActiveSegment = BitConverter.readInt(data.getData(), 0);
Preconditions.checkArgument(lastActiveSegment >= oldLastActiveSegment,
"Old last active segment ({}) for {}/{} is higher than current one {}.",
oldLastActiveSegment, scope, stream, lastActiveSegment);
return Futures.toVoid(storeHelper.setData(deletePath, new Data(maxSegmentNumberBytes, data.getVersion())));
}
});
}
代码示例来源:origin: pravega/pravega
@Test
public void testCounter() throws Exception {
ZKStoreHelper storeHelper = spy(new ZKStoreHelper(cli, executor));
storeHelper.createZNodeIfNotExist("/store/scope").join();
doReturn(CompletableFuture.completedFuture(data)).when(storeHelper).getData(COUNTER_PATH);
我一直在尝试将 Redux 集成到项目中。 我按照使用示例进行操作,但收到错误store.getState is not a function。 所以我知道其他人也问过类似的问题,但情况略有不同。 R
我正在尝试将我的第一个应用程序上传到 App Store。我已完成 iTunes Connect 所需的所有步骤,我的应用程序状态为“等待上传”。 我相信下一步是使用 Application Load
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭10 年前。 Improve th
App Store 有所谓的“服务器到服务器”通知。也就是说,当您购买应用内功能时,Apple 服务器会向您服务器的回调方法(发送收据数据)发出 HTTPS 请求。 问题是 - 收据数据中似乎没有用户
我已经将我的第一个应用程序上载到App Store,但是我没有放置我的App需要位置服务和wifi的UIRequiredDeviceCapabilities。结果:该应用程序没有像应做的那样开始寻找坐
由于iOS 8将于本月发布,并且我的应用仅支持32位(因为第3个库仅兼容32位),因此我不确定如果我将新版本的应用提交给我,则该应用的新版本是否会被拒绝App Store将于下个月发布,因为它不支持6
我有一个让我有些困惑的问题。 为了将我的应用提交到App Store,我必须输入Bundle ID后缀。如您所知,Bundle ID会获得Bundle ID后缀的确切名称(您在Bundle ID后缀上
如问题所述,我想知道更新后的应用程序一旦获得批准,是否会自动发布到应用程序商店中? 我的更新已完成并且已经过测试,由于需要几天的时间才能批准,因此我希望现在将其提交批准。同时,我需要在服务器上更改一些
获取应用程序提交到 Apple App Store 的屏幕截图的最简单方法是什么,需要包含的各种尺寸是多少? 另外,是否允许状态栏?我相信我听说它不是,但是包括 Facebook 和 Quora 在内
我在 iTunes 商店中有一个应用程序,其分发证书(在 key 链访问中)将于明天到期。它是一年前生成的,尽管我最近更新了我的 iPhone 开发者计划,但我还没有更新任何证书或签名。 当我将测试设
我的商店包含以下 reducer : export const centralStampState = { layoutState : layoutReducer, //this one is n
我即将将我的应用程序提交到 Apple App Store,并且我了解到 Apple 需要两周时间才能对其进行审核,然后才能上线。但是,在 iTunes Connect 的定价部分,它询问我什么时候发
如果我的应用程序正在接受审核或已获得批准(因此处于 Ready For Sale 状态或同等状态),我可以编辑哪些应用程序信息而无需提交应用程序的新版本? 最佳答案 据此Apple Documenta
我已经在Opera管理控制台上进行了全面检查,看不到他们在哪里提到付款方式。他们说明何时制作,但没有说明。即Paypal,Cheque等。 有人知道他们如何付款吗? 最佳答案 当金额达到200美元时,
我上传了我的二进制文件并创建了屏幕截图。我做的所有屏幕截图都是 640x960,我将它们上传为 PNG。这背后的想法是,我应该以尽可能最好的质量把它交给他们,这样当他们将它们重新压缩成 320x480
我从Microsoft下载了Windows 8 app samples,并下载了这些示例之一加速度传感器示例 我不知道如何测试它以计划使用此功能的软件? 我没有水面设备,想知道只有一种方法可以做到吗?
我正在为TestFlight上传第二个应用程序。第一次进展顺利,但这次却被拒绝了。 We have started the review of your beta app, but we are no
不确定这是正确的论坛,如果不是,我提前道歉。 某处是否有 App Store 新版本的提要?还是带有类别和发布日期的应用提要/列表? 此列表已从 App Store 中消失,我想看看是否可以制作一个应
我有一个 JSON 存储,定义如下 var subAccountStore = new Ext.data.JsonStore({ autoLoad: true, proxy: { ty
我有一个提交到应用商店的应用被拒绝,原因是: 2.30 不符合 Mac OS X 文件系统文档的应用将被拒绝 他们声称我的应用正在修改不受支持的 ~/Library/Preferences/com.a
我是一名优秀的程序员,十分优秀!