use of io.pravega.controller.store.stream.PravegaTablesStreamMetadataStore.DATA_NOT_FOUND_PREDICATE in project pravega by pravega.
the class PravegaTablesScope method readAll.
private CompletableFuture<Pair<List<String>, String>> readAll(int limit, String continuationToken, String tableName, OperationContext context) {
List<String> taken = new ArrayList<>();
AtomicReference<String> token = new AtomicReference<>(continuationToken);
AtomicBoolean canContinue = new AtomicBoolean(true);
return Futures.exceptionallyExpecting(storeHelper.getKeysPaginated(tableName, Unpooled.wrappedBuffer(Base64.getDecoder().decode(token.get())), limit, context.getRequestId()).thenApply(result -> {
if (result.getValue().isEmpty()) {
canContinue.set(false);
} else {
taken.addAll(result.getValue());
}
token.set(Base64.getEncoder().encodeToString(result.getKey().array()));
return new ImmutablePair<>(taken, token.get());
}), DATA_NOT_FOUND_PREDICATE, new ImmutablePair<>(Collections.emptyList(), token.get()));
}
use of io.pravega.controller.store.stream.PravegaTablesStreamMetadataStore.DATA_NOT_FOUND_PREDICATE in project pravega by pravega.
the class PravegaTablesStream method createCompletedTxEntries.
private CompletableFuture<Void> createCompletedTxEntries(List<Map.Entry<String, CompletedTxnRecord>> complete, OperationContext context) {
Preconditions.checkNotNull(context, "operation context cannot be null");
Integer batch = currentBatchSupplier.get();
String tableName = getCompletedTransactionsBatchTableName(batch);
return Futures.toVoid(Futures.exceptionallyComposeExpecting(storeHelper.addNewEntriesIfAbsent(tableName, complete, CompletedTxnRecord::toBytes, context.getRequestId()), DATA_NOT_FOUND_PREDICATE, () -> tryCreateBatchTable(batch, context).thenCompose(v -> storeHelper.addNewEntriesIfAbsent(tableName, complete, CompletedTxnRecord::toBytes, context.getRequestId())))).exceptionally(e -> {
throw new CompletionException(e);
});
}
Aggregations