Search in sources :

Example 1 with DeleteTableEvent

use of io.pravega.shared.controller.event.kvtable.DeleteTableEvent in project pravega by pravega.

the class DeleteTableTask method execute.

@Override
public CompletableFuture<Void> execute(final DeleteTableEvent request) {
    String scope = request.getScope();
    String kvt = request.getKvtName();
    long requestId = request.getRequestId();
    String kvTableId = request.getTableId().toString();
    final OperationContext context = kvtMetadataStore.createContext(scope, kvt, requestId);
    return RetryHelper.withRetriesAsync(() -> getKeyValueTable(scope, kvt).thenCompose(table -> table.getId(context)).thenCompose(id -> {
        if (!id.equals(kvTableId)) {
            log.debug(requestId, "Skipped processing delete event for KeyValueTable {}/{} with Id:{} as UUIDs did not match.", scope, kvt, id);
            return CompletableFuture.completedFuture(null);
        } else {
            return Futures.exceptionallyExpecting(kvtMetadataStore.getAllSegmentIds(scope, kvt, context, executor).thenComposeAsync(allSegments -> kvtMetadataTasks.deleteSegments(scope, kvt, allSegments, kvtMetadataTasks.retrieveDelegationToken(), requestId), executor), e -> Exceptions.unwrap(e) instanceof StoreException.DataNotFoundException, null).thenCompose(v -> this.kvtMetadataStore.deleteKeyValueTable(scope, kvt, context, executor));
        }
    }), e -> Exceptions.unwrap(e) instanceof RetryableException, Integer.MAX_VALUE, executor);
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext) OperationContext(io.pravega.controller.store.stream.OperationContext) KeyValueTable(io.pravega.controller.store.kvtable.KeyValueTable) Exceptions(io.pravega.common.Exceptions) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) TableMetadataTasks(io.pravega.controller.task.KeyValueTable.TableMetadataTasks) KVTableMetadataStore(io.pravega.controller.store.kvtable.KVTableMetadataStore) TagLogger(io.pravega.common.tracing.TagLogger) StoreException(io.pravega.controller.store.stream.StoreException) RetryableException(io.pravega.controller.retryable.RetryableException) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Preconditions(com.google.common.base.Preconditions) DeleteTableEvent(io.pravega.shared.controller.event.kvtable.DeleteTableEvent) Futures(io.pravega.common.concurrent.Futures) RetryHelper(io.pravega.controller.util.RetryHelper) RetryableException(io.pravega.controller.retryable.RetryableException) StoreException(io.pravega.controller.store.stream.StoreException)

Aggregations

Preconditions (com.google.common.base.Preconditions)1 Exceptions (io.pravega.common.Exceptions)1 Futures (io.pravega.common.concurrent.Futures)1 TagLogger (io.pravega.common.tracing.TagLogger)1 RetryableException (io.pravega.controller.retryable.RetryableException)1 KVTableMetadataStore (io.pravega.controller.store.kvtable.KVTableMetadataStore)1 KeyValueTable (io.pravega.controller.store.kvtable.KeyValueTable)1 OperationContext (io.pravega.controller.store.stream.OperationContext)1 StoreException (io.pravega.controller.store.stream.StoreException)1 TableMetadataTasks (io.pravega.controller.task.KeyValueTable.TableMetadataTasks)1 RetryHelper (io.pravega.controller.util.RetryHelper)1 DeleteTableEvent (io.pravega.shared.controller.event.kvtable.DeleteTableEvent)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 LoggerFactory (org.slf4j.LoggerFactory)1