Search in sources :

Example 16 with OperationContext

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

the class StreamCutBucketService method performRetention.

private CompletableFuture<Void> performRetention(StreamImpl stream) {
    log.debug("Periodic background processing for retention called for stream {}/{}", stream.getScope(), stream.getStreamName());
    OperationContext context = streamMetadataStore.createContext(stream.getScope(), stream.getStreamName());
    return RetryHelper.withRetriesAsync(() -> streamMetadataStore.getConfiguration(stream.getScope(), stream.getStreamName(), context, executor).thenCompose(config -> streamMetadataTasks.retention(stream.getScope(), stream.getStreamName(), config.getRetentionPolicy(), System.currentTimeMillis(), context, this.streamMetadataTasks.retrieveDelegationToken())).exceptionally(e -> {
        log.warn("Exception thrown while performing auto retention for stream {} ", stream, e);
        throw new CompletionException(e);
    }), RetryHelper.UNCONDITIONAL_PREDICATE, 5, executor).exceptionally(e -> {
        log.warn("Unable to perform retention for stream {}. Ignoring, retention will be attempted in next cycle.", stream, e);
        return null;
    });
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext) OperationContext(io.pravega.controller.store.stream.OperationContext) StreamImpl(io.pravega.client.stream.impl.StreamImpl) Exceptions(io.pravega.common.Exceptions) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CompletableFuture(java.util.concurrent.CompletableFuture) CompletionException(java.util.concurrent.CompletionException) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Collectors(java.util.stream.Collectors) ConcurrentMap(java.util.concurrent.ConcurrentMap) TimeUnit(java.util.concurrent.TimeUnit) Slf4j(lombok.extern.slf4j.Slf4j) Config(io.pravega.controller.util.Config) Stream(io.pravega.client.stream.Stream) Duration(java.time.Duration) Map(java.util.Map) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) AbstractService(com.google.common.util.concurrent.AbstractService) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) VisibleForTesting(com.google.common.annotations.VisibleForTesting) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) Collections(java.util.Collections) Futures(io.pravega.common.concurrent.Futures) RetryHelper(io.pravega.controller.util.RetryHelper) CompletionException(java.util.concurrent.CompletionException)

Aggregations

OperationContext (io.pravega.controller.store.stream.OperationContext)16 StreamMetadataStore (io.pravega.controller.store.stream.StreamMetadataStore)12 CompletableFuture (java.util.concurrent.CompletableFuture)12 Futures (io.pravega.common.concurrent.Futures)11 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)11 Collectors (java.util.stream.Collectors)11 Slf4j (lombok.extern.slf4j.Slf4j)10 HostControllerStore (io.pravega.controller.store.host.HostControllerStore)9 List (java.util.List)9 SegmentHelper (io.pravega.controller.server.SegmentHelper)8 Segment (io.pravega.controller.store.stream.Segment)8 VisibleForTesting (com.google.common.annotations.VisibleForTesting)7 StreamMetadataTasks (io.pravega.controller.task.Stream.StreamMetadataTasks)7 UUID (java.util.UUID)7 ConnectionFactory (io.pravega.client.netty.impl.ConnectionFactory)6 Exceptions (io.pravega.common.Exceptions)6 Config (io.pravega.controller.util.Config)6 Duration (java.time.Duration)6 Preconditions (com.google.common.base.Preconditions)5 EventStreamWriter (io.pravega.client.stream.EventStreamWriter)5