Search in sources :

Example 1 with DeleteStreamEvent

use of io.pravega.shared.controller.event.DeleteStreamEvent in project pravega by pravega.

the class DeleteStreamTask method execute.

@Override
public CompletableFuture<Void> execute(final DeleteStreamEvent request) {
    final OperationContext context = streamMetadataStore.createContext(request.getScope(), request.getStream());
    String scope = request.getScope();
    String stream = request.getStream();
    return streamMetadataStore.isSealed(scope, stream, context, executor).thenComposeAsync(sealed -> {
        if (!sealed) {
            log.warn("{}/{} stream not sealed", scope, stream);
            return Futures.failedFuture(new RuntimeException("Stream not sealed"));
        }
        return notifyAndDelete(context, scope, stream);
    }, executor).exceptionally(e -> {
        if (e instanceof StoreException.DataNotFoundException) {
            return null;
        }
        log.error("{}/{} stream delete workflow threw exception.", scope, stream, e);
        throw new CompletionException(e);
    });
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext) OperationContext(io.pravega.controller.store.stream.OperationContext) Slf4j(lombok.extern.slf4j.Slf4j) StoreException(io.pravega.controller.store.stream.StoreException) DeleteStreamEvent(io.pravega.shared.controller.event.DeleteStreamEvent) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) Preconditions(com.google.common.base.Preconditions) CompletableFuture(java.util.concurrent.CompletableFuture) CompletionException(java.util.concurrent.CompletionException) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) Futures(io.pravega.common.concurrent.Futures) CompletionException(java.util.concurrent.CompletionException)

Aggregations

Preconditions (com.google.common.base.Preconditions)1 Futures (io.pravega.common.concurrent.Futures)1 OperationContext (io.pravega.controller.store.stream.OperationContext)1 StoreException (io.pravega.controller.store.stream.StoreException)1 StreamMetadataStore (io.pravega.controller.store.stream.StreamMetadataStore)1 StreamMetadataTasks (io.pravega.controller.task.Stream.StreamMetadataTasks)1 DeleteStreamEvent (io.pravega.shared.controller.event.DeleteStreamEvent)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletionException (java.util.concurrent.CompletionException)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Slf4j (lombok.extern.slf4j.Slf4j)1