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);
}
Aggregations