Search in sources :

Example 1 with DATA_NOT_FOUND_PREDICATE

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()));
}
Also used : IntStream(java.util.stream.IntStream) OperationContext(io.pravega.controller.store.stream.OperationContext) Exceptions(io.pravega.common.Exceptions) LoggerFactory(org.slf4j.LoggerFactory) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) NameUtils.getQualifiedTableName(io.pravega.shared.NameUtils.getQualifiedTableName) CompletableFuture(java.util.concurrent.CompletableFuture) DATA_NOT_FOUND_PREDICATE(io.pravega.controller.store.stream.PravegaTablesStreamMetadataStore.DATA_NOT_FOUND_PREDICATE) AtomicReference(java.util.concurrent.atomic.AtomicReference) Supplier(java.util.function.Supplier) Unpooled(io.netty.buffer.Unpooled) ArrayList(java.util.ArrayList) TagLogger(io.pravega.common.tracing.TagLogger) StoreException(io.pravega.controller.store.stream.StoreException) Pair(org.apache.commons.lang3.tuple.Pair) SEPARATOR(io.pravega.shared.NameUtils.SEPARATOR) HashHelper(io.pravega.common.hash.HashHelper) Executor(java.util.concurrent.Executor) BYTES_TO_UUID_FUNCTION(io.pravega.controller.store.PravegaTablesStoreHelper.BYTES_TO_UUID_FUNCTION) lombok.val(lombok.val) Set(java.util.Set) CompletionException(java.util.concurrent.CompletionException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) INTERNAL_SCOPE_NAME(io.pravega.shared.NameUtils.INTERNAL_SCOPE_NAME) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) StandardCharsets(java.nio.charset.StandardCharsets) UUID_TO_BYTES_FUNCTION(io.pravega.controller.store.PravegaTablesStoreHelper.UUID_TO_BYTES_FUNCTION) Objects(java.util.Objects) Base64(java.util.Base64) List(java.util.List) TagRecord(io.pravega.controller.store.stream.records.TagRecord) TableSegmentEntry(io.pravega.client.tables.impl.TableSegmentEntry) SCOPES_TABLE(io.pravega.controller.store.stream.PravegaTablesStreamMetadataStore.SCOPES_TABLE) Preconditions(com.google.common.base.Preconditions) Collections(java.util.Collections) Futures(io.pravega.common.concurrent.Futures) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ArrayList(java.util.ArrayList) AtomicReference(java.util.concurrent.atomic.AtomicReference)

Example 2 with DATA_NOT_FOUND_PREDICATE

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);
    });
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DATA_NOT_EMPTY_PREDICATE(io.pravega.controller.store.stream.AbstractStreamMetadataStore.DATA_NOT_EMPTY_PREDICATE) BiFunction(java.util.function.BiFunction) LoggerFactory(org.slf4j.LoggerFactory) NameUtils.getQualifiedTableName(io.pravega.shared.NameUtils.getQualifiedTableName) COMPLETED_TRANSACTIONS_BATCHES_TABLE(io.pravega.shared.NameUtils.COMPLETED_TRANSACTIONS_BATCHES_TABLE) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) ByteBuffer(java.nio.ByteBuffer) TagLogger(io.pravega.common.tracing.TagLogger) VersionedMetadata(io.pravega.controller.store.VersionedMetadata) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SEPARATOR(io.pravega.shared.NameUtils.SEPARATOR) Map(java.util.Map) CONFIGURATION_KEY(io.pravega.shared.NameUtils.CONFIGURATION_KEY) EpochTransitionRecord(io.pravega.controller.store.stream.records.EpochTransitionRecord) Subscribers(io.pravega.controller.store.stream.records.Subscribers) StreamTruncationRecord(io.pravega.controller.store.stream.records.StreamTruncationRecord) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) BYTES_TO_UUID_FUNCTION(io.pravega.controller.store.PravegaTablesStoreHelper.BYTES_TO_UUID_FUNCTION) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) WRITERS_POSITIONS_TABLE(io.pravega.shared.NameUtils.WRITERS_POSITIONS_TABLE) CompletionException(java.util.concurrent.CompletionException) ActiveTxnRecord(io.pravega.controller.store.stream.records.ActiveTxnRecord) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Objects(java.util.Objects) List(java.util.List) BYTES_TO_INTEGER_FUNCTION(io.pravega.controller.store.PravegaTablesStoreHelper.BYTES_TO_INTEGER_FUNCTION) Optional(java.util.Optional) HistoryTimeSeries(io.pravega.controller.store.stream.records.HistoryTimeSeries) Futures(io.pravega.common.concurrent.Futures) LONG_TO_BYTES_FUNCTION(io.pravega.controller.store.PravegaTablesStoreHelper.LONG_TO_BYTES_FUNCTION) EPOCH_TRANSITION_KEY(io.pravega.shared.NameUtils.EPOCH_TRANSITION_KEY) CompletedTxnRecord(io.pravega.controller.store.stream.records.CompletedTxnRecord) CommittingTransactionsRecord(io.pravega.controller.store.stream.records.CommittingTransactionsRecord) RETENTION_SET_KEY(io.pravega.shared.NameUtils.RETENTION_SET_KEY) Exceptions(io.pravega.common.Exceptions) EPOCH_RECORD_KEY_FORMAT(io.pravega.shared.NameUtils.EPOCH_RECORD_KEY_FORMAT) WAITING_REQUEST_PROCESSOR_PATH(io.pravega.shared.NameUtils.WAITING_REQUEST_PROCESSOR_PATH) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) DATA_NOT_FOUND_PREDICATE(io.pravega.controller.store.stream.PravegaTablesStreamMetadataStore.DATA_NOT_FOUND_PREDICATE) COMMITTING_TRANSACTIONS_RECORD_KEY(io.pravega.shared.NameUtils.COMMITTING_TRANSACTIONS_RECORD_KEY) RetentionSet(io.pravega.controller.store.stream.records.RetentionSet) SUBSCRIBER_KEY_PREFIX(io.pravega.shared.NameUtils.SUBSCRIBER_KEY_PREFIX) AtomicReference(java.util.concurrent.atomic.AtomicReference) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) CURRENT_EPOCH_KEY(io.pravega.shared.NameUtils.CURRENT_EPOCH_KEY) Strings(com.google.common.base.Strings) HISTORY_TIMESERIES_CHUNK_FORMAT(io.pravega.shared.NameUtils.HISTORY_TIMESERIES_CHUNK_FORMAT) TRANSACTIONS_IN_EPOCH_TABLE_FORMAT(io.pravega.shared.NameUtils.TRANSACTIONS_IN_EPOCH_TABLE_FORMAT) StateRecord(io.pravega.controller.store.stream.records.StateRecord) BYTES_TO_LONG_FUNCTION(io.pravega.controller.store.PravegaTablesStoreHelper.BYTES_TO_LONG_FUNCTION) SEGMENT_MARKER_PATH_FORMAT(io.pravega.shared.NameUtils.SEGMENT_MARKER_PATH_FORMAT) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) StreamSubscriber(io.pravega.controller.store.stream.records.StreamSubscriber) SEGMENTS_SEALED_SIZE_MAP_SHARD_FORMAT(io.pravega.shared.NameUtils.SEGMENTS_SEALED_SIZE_MAP_SHARD_FORMAT) INTEGER_TO_BYTES_FUNCTION(io.pravega.controller.store.PravegaTablesStoreHelper.INTEGER_TO_BYTES_FUNCTION) SealedSegmentsMapShard(io.pravega.controller.store.stream.records.SealedSegmentsMapShard) METADATA_TABLE(io.pravega.shared.NameUtils.METADATA_TABLE) STATE_KEY(io.pravega.shared.NameUtils.STATE_KEY) EPOCHS_WITH_TRANSACTIONS_TABLE(io.pravega.shared.NameUtils.EPOCHS_WITH_TRANSACTIONS_TABLE) WriterMark(io.pravega.controller.store.stream.records.WriterMark) StreamCutRecord(io.pravega.controller.store.stream.records.StreamCutRecord) TRUNCATION_KEY(io.pravega.shared.NameUtils.TRUNCATION_KEY) INTERNAL_SCOPE_NAME(io.pravega.shared.NameUtils.INTERNAL_SCOPE_NAME) StreamConfigurationRecord(io.pravega.controller.store.stream.records.StreamConfigurationRecord) AbstractMap(java.util.AbstractMap) EpochRecord(io.pravega.controller.store.stream.records.EpochRecord) Version(io.pravega.controller.store.Version) COMPLETED_TRANSACTIONS_BATCH_TABLE_FORMAT(io.pravega.shared.NameUtils.COMPLETED_TRANSACTIONS_BATCH_TABLE_FORMAT) PravegaTablesStoreHelper(io.pravega.controller.store.PravegaTablesStoreHelper) CREATION_TIME_KEY(io.pravega.shared.NameUtils.CREATION_TIME_KEY) SUBSCRIBER_SET_KEY(io.pravega.shared.NameUtils.SUBSCRIBER_SET_KEY) Preconditions(com.google.common.base.Preconditions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) RETENTION_STREAM_CUT_RECORD_KEY_FORMAT(io.pravega.shared.NameUtils.RETENTION_STREAM_CUT_RECORD_KEY_FORMAT) Collections(java.util.Collections) SEGMENT_SEALED_EPOCH_KEY_FORMAT(io.pravega.shared.NameUtils.SEGMENT_SEALED_EPOCH_KEY_FORMAT) CompletedTxnRecord(io.pravega.controller.store.stream.records.CompletedTxnRecord) CompletionException(java.util.concurrent.CompletionException)

Aggregations

Preconditions (com.google.common.base.Preconditions)2 Exceptions (io.pravega.common.Exceptions)2 Futures (io.pravega.common.concurrent.Futures)2 TagLogger (io.pravega.common.tracing.TagLogger)2 BYTES_TO_UUID_FUNCTION (io.pravega.controller.store.PravegaTablesStoreHelper.BYTES_TO_UUID_FUNCTION)2 DATA_NOT_FOUND_PREDICATE (io.pravega.controller.store.stream.PravegaTablesStreamMetadataStore.DATA_NOT_FOUND_PREDICATE)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Strings (com.google.common.base.Strings)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Unpooled (io.netty.buffer.Unpooled)1 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)1 TableSegmentEntry (io.pravega.client.tables.impl.TableSegmentEntry)1 HashHelper (io.pravega.common.hash.HashHelper)1 PravegaTablesStoreHelper (io.pravega.controller.store.PravegaTablesStoreHelper)1 BYTES_TO_INTEGER_FUNCTION (io.pravega.controller.store.PravegaTablesStoreHelper.BYTES_TO_INTEGER_FUNCTION)1 BYTES_TO_LONG_FUNCTION (io.pravega.controller.store.PravegaTablesStoreHelper.BYTES_TO_LONG_FUNCTION)1 INTEGER_TO_BYTES_FUNCTION (io.pravega.controller.store.PravegaTablesStoreHelper.INTEGER_TO_BYTES_FUNCTION)1 LONG_TO_BYTES_FUNCTION (io.pravega.controller.store.PravegaTablesStoreHelper.LONG_TO_BYTES_FUNCTION)1 UUID_TO_BYTES_FUNCTION (io.pravega.controller.store.PravegaTablesStoreHelper.UUID_TO_BYTES_FUNCTION)1 Version (io.pravega.controller.store.Version)1