Search in sources :

Example 76 with OperationContext

use of io.pravega.controller.store.stream.OperationContext in project pravega by pravega.

the class AbstractKVTableMetadataStore method deleteKeyValueTable.

@Override
public CompletableFuture<Void> deleteKeyValueTable(final String scope, final String name, final OperationContext ctx, final Executor executor) {
    OperationContext kvtContext = getOperationContext(ctx);
    KeyValueTable kvTable = getKVTable(scope, name, kvtContext);
    return Futures.completeOn(Futures.exceptionallyExpecting(kvTable.getActiveEpochRecord(true, kvtContext).thenApply(epoch -> epoch.getSegments().stream().map(KVTSegmentRecord::getSegmentNumber).reduce(Integer::max).get()).thenCompose(lastActiveSegment -> recordLastKVTableSegment(scope, name, lastActiveSegment, kvtContext, executor)), DATA_NOT_FOUND_PREDICATE, null).thenCompose(v -> kvTable.delete(kvtContext)), executor).thenCompose(v -> deleteFromScope(scope, name, kvtContext, executor));
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext) ControllerService(io.pravega.controller.server.ControllerService) OperationContext(io.pravega.controller.store.stream.OperationContext) LoadingCache(com.google.common.cache.LoadingCache) Getter(lombok.Getter) Executor(java.util.concurrent.Executor) Predicate(java.util.function.Predicate) Exceptions(io.pravega.common.Exceptions) Set(java.util.Set) Scope(io.pravega.controller.store.Scope) CompletableFuture(java.util.concurrent.CompletableFuture) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault) HostIndex(io.pravega.controller.store.index.HostIndex) CacheLoader(com.google.common.cache.CacheLoader) KVTSegmentRecord(io.pravega.controller.store.kvtable.records.KVTSegmentRecord) TimeUnit(java.util.concurrent.TimeUnit) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) VersionedMetadata(io.pravega.controller.store.VersionedMetadata) StoreException(io.pravega.controller.store.stream.StoreException) Pair(org.apache.commons.lang3.tuple.Pair) CacheBuilder(com.google.common.cache.CacheBuilder) Futures(io.pravega.common.concurrent.Futures) KVTSegmentRecord(io.pravega.controller.store.kvtable.records.KVTSegmentRecord)

Aggregations

OperationContext (io.pravega.controller.store.stream.OperationContext)76 CompletableFuture (java.util.concurrent.CompletableFuture)53 Futures (io.pravega.common.concurrent.Futures)48 StreamMetadataStore (io.pravega.controller.store.stream.StreamMetadataStore)44 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)42 Exceptions (io.pravega.common.Exceptions)41 Collectors (java.util.stream.Collectors)41 UUID (java.util.UUID)39 StoreException (io.pravega.controller.store.stream.StoreException)38 List (java.util.List)38 TagLogger (io.pravega.common.tracing.TagLogger)37 LoggerFactory (org.slf4j.LoggerFactory)37 Preconditions (com.google.common.base.Preconditions)36 Map (java.util.Map)32 NameUtils (io.pravega.shared.NameUtils)31 VisibleForTesting (com.google.common.annotations.VisibleForTesting)27 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)26 State (io.pravega.controller.store.stream.State)26 CompletionException (java.util.concurrent.CompletionException)26 BucketStore (io.pravega.controller.store.stream.BucketStore)25