Search in sources :

Example 46 with OperationContext

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

the class RequestHandlersTest method scopeDeleteTest.

@Test
public void scopeDeleteTest() {
    final String testScope = "testScope";
    final String testStream = "testStream";
    final String testRG = "_RGTestRG";
    final String testKVT = "testKVT";
    StreamMetadataStore streamStoreSpied = spy(getStore());
    KVTableMetadataStore kvtStoreSpied = spy(getKvtStore());
    StreamMetadataTasks streamMetadataTasks1 = mock(StreamMetadataTasks.class);
    TableMetadataTasks kvtTasksMocked = mock(TableMetadataTasks.class);
    streamStoreSpied.createScope(testScope, null, executor).join();
    OperationContext ctx = new OperationContext() {

        @Override
        public long getOperationStartTime() {
            return 0;
        }

        @Override
        public long getRequestId() {
            return 0;
        }
    };
    UUID scopeId = streamStoreSpied.getScopeId(testScope, ctx, executor).join();
    doAnswer(x -> {
        CompletableFuture<UUID> cf = new CompletableFuture<>();
        cf.complete(scopeId);
        return cf;
    }).when(streamStoreSpied).getScopeId(eq(testScope), eq(ctx), eq(executor));
    doAnswer(invocation -> {
        CompletableFuture<Boolean> cf = new CompletableFuture<>();
        cf.complete(true);
        return cf;
    }).when(streamStoreSpied).isScopeSealed(eq(testScope), any(), any());
    createStreamInStore(testStream, testScope);
    createStreamInStore(testRG, testScope);
    assertTrue(streamStore.checkStreamExists(testScope, testStream, ctx, executor).join());
    doAnswer(invocation -> {
        CompletableFuture<Controller.UpdateStreamStatus.Status> future = new CompletableFuture<>();
        future.complete(Controller.UpdateStreamStatus.Status.SUCCESS);
        return future;
    }).when(streamMetadataTasks1).sealStream(anyString(), anyString(), anyLong());
    doAnswer(invocation -> {
        CompletableFuture<Controller.DeleteStreamStatus.Status> future = new CompletableFuture<>();
        future.complete(Controller.DeleteStreamStatus.Status.SUCCESS);
        return future;
    }).when(streamMetadataTasks1).deleteStream(anyString(), anyString(), anyLong());
    // Create Reader Group
    ReaderGroupConfig rgConfig = ReaderGroupConfig.builder().stream(NameUtils.getScopedStreamName(testScope, testStream)).build();
    final ReaderGroupConfig config = ReaderGroupConfig.cloneConfig(rgConfig, UUID.randomUUID(), 123L);
    Controller.ReaderGroupConfiguration expectedConfig = ModelHelper.decode(testScope, testRG, config);
    doAnswer(invocationOnMock -> {
        CompletableFuture<Controller.CreateReaderGroupResponse.Status> createRG = new CompletableFuture<>();
        createRG.complete(Controller.CreateReaderGroupResponse.Status.SUCCESS);
        return createRG;
    }).when(streamMetadataTasks1).createReaderGroup(anyString(), any(), any(), anyLong(), anyLong());
    doAnswer(invocation -> CompletableFuture.completedFuture(Controller.ReaderGroupConfigResponse.newBuilder().setStatus(Controller.ReaderGroupConfigResponse.Status.SUCCESS).setConfig(expectedConfig).build())).when(streamMetadataTasks1).getReaderGroupConfig(eq(testScope), anyString(), anyLong());
    doAnswer(invocationOnMock -> {
        CompletableFuture<Controller.DeleteReaderGroupStatus.Status> future = new CompletableFuture<>();
        future.complete(Controller.DeleteReaderGroupStatus.Status.SUCCESS);
        return future;
    }).when(streamMetadataTasks1).deleteReaderGroup(anyString(), anyString(), anyString(), anyLong());
    // Create KVT
    KeyValueTableConfiguration kvtConfig = KeyValueTableConfiguration.builder().partitionCount(1).primaryKeyLength(1).secondaryKeyLength(1).build();
    doAnswer(invocationOnMock -> {
        CompletableFuture<Controller.CreateKeyValueTableStatus.Status> fut = new CompletableFuture<>();
        fut.complete(Controller.CreateKeyValueTableStatus.Status.SUCCESS);
        return fut;
    }).when(kvtTasksMocked).createKeyValueTable(anyString(), anyString(), any(), anyLong(), anyLong());
    List<String> tableList = new ArrayList<>();
    tableList.add(testKVT);
    Pair<List<String>, String> listOfKVTables = new ImmutablePair<>(tableList, "");
    doAnswer(invocationOnMock -> CompletableFuture.completedFuture(listOfKVTables)).doAnswer(invocationOnMock -> CompletableFuture.completedFuture(new ImmutablePair<>(Collections.emptyList(), invocationOnMock.getArgument(0)))).when(kvtStoreSpied).listKeyValueTables(anyString(), any(), anyInt(), any(), any());
    doAnswer(invocationOnMock -> {
        CompletableFuture<Controller.DeleteKVTableStatus.Status> future = new CompletableFuture<>();
        future.complete(Controller.DeleteKVTableStatus.Status.SUCCESS);
        return future;
    }).when(kvtTasksMocked).deleteKeyValueTable(anyString(), anyString(), anyLong());
    Controller.CreateKeyValueTableStatus.Status status = kvtTasksMocked.createKeyValueTable(testScope, testKVT, kvtConfig, System.currentTimeMillis(), 123L).join();
    assertEquals(status, Controller.CreateKeyValueTableStatus.Status.SUCCESS);
    DeleteScopeTask requestHandler = new DeleteScopeTask(streamMetadataTasks1, streamStoreSpied, kvtStoreSpied, kvtTasksMocked, executor);
    DeleteScopeEvent event = new DeleteScopeEvent(testScope, 123L, scopeId);
    CompletableFuture<Void> future = requestHandler.execute(event);
    future.join();
}
Also used : UpdateStreamEvent(io.pravega.shared.controller.event.UpdateStreamEvent) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) InetAddress(java.net.InetAddress) StoreException(io.pravega.controller.store.stream.StoreException) Pair(org.apache.commons.lang3.tuple.Pair) AutoScaleTask(io.pravega.controller.server.eventProcessor.requesthandlers.AutoScaleTask) TaskMetadataStore(io.pravega.controller.store.task.TaskMetadataStore) Map(java.util.Map) Mockito.doAnswer(org.mockito.Mockito.doAnswer) ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) StreamTruncationRecord(io.pravega.controller.store.stream.records.StreamTruncationRecord) DeleteStreamEvent(io.pravega.shared.controller.event.DeleteStreamEvent) Mockito.atLeastOnce(org.mockito.Mockito.atLeastOnce) RequestTracker(io.pravega.common.tracing.RequestTracker) KVTableMetadataStore(io.pravega.controller.store.kvtable.KVTableMetadataStore) Assert.assertFalse(org.junit.Assert.assertFalse) CreateReaderGroupTask(io.pravega.controller.server.eventProcessor.requesthandlers.CreateReaderGroupTask) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) EventStreamWriterMock(io.pravega.controller.mocks.EventStreamWriterMock) Futures(io.pravega.common.concurrent.Futures) GrpcAuthHelper(io.pravega.controller.server.security.auth.GrpcAuthHelper) Mockito.mock(org.mockito.Mockito.mock) CuratorFrameworkFactory(org.apache.curator.framework.CuratorFrameworkFactory) StreamMetrics(io.pravega.controller.metrics.StreamMetrics) StreamStoreFactory(io.pravega.controller.store.stream.StreamStoreFactory) TransactionMetrics(io.pravega.controller.metrics.TransactionMetrics) ConnectionFactory(io.pravega.client.connection.impl.ConnectionFactory) Exceptions(io.pravega.common.Exceptions) TruncateStreamEvent(io.pravega.shared.controller.event.TruncateStreamEvent) Mockito.spy(org.mockito.Mockito.spy) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) TestingServerStarter(io.pravega.test.common.TestingServerStarter) TestingServer(org.apache.curator.test.TestingServer) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) WireCommandType(io.pravega.shared.protocol.netty.WireCommandType) UpdateReaderGroupTask(io.pravega.controller.server.eventProcessor.requesthandlers.UpdateReaderGroupTask) Before(org.junit.Before) SegmentHelperMock(io.pravega.controller.mocks.SegmentHelperMock) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) TableMetadataTasks(io.pravega.controller.task.KeyValueTable.TableMetadataTasks) UnknownHostException(java.net.UnknownHostException) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) StreamConfigurationRecord(io.pravega.controller.store.stream.records.StreamConfigurationRecord) TaskStoreFactory(io.pravega.controller.store.task.TaskStoreFactory) WireCommandFailedException(io.pravega.controller.server.WireCommandFailedException) Version(io.pravega.controller.store.Version) StreamTransactionMetadataTasks(io.pravega.controller.task.Stream.StreamTransactionMetadataTasks) DeleteStreamTask(io.pravega.controller.server.eventProcessor.requesthandlers.DeleteStreamTask) StreamRequestHandler(io.pravega.controller.server.eventProcessor.requesthandlers.StreamRequestHandler) CommitRequestHandler(io.pravega.controller.server.eventProcessor.requesthandlers.CommitRequestHandler) ScalingPolicy(io.pravega.client.stream.ScalingPolicy) Assert.assertEquals(org.junit.Assert.assertEquals) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CommitEvent(io.pravega.shared.controller.event.CommitEvent) AssertExtensions(io.pravega.test.common.AssertExtensions) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) SealStreamEvent(io.pravega.shared.controller.event.SealStreamEvent) VersionedMetadata(io.pravega.controller.store.VersionedMetadata) After(org.junit.After) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) SealStreamTask(io.pravega.controller.server.eventProcessor.requesthandlers.SealStreamTask) Predicate(java.util.function.Predicate) Collection(java.util.Collection) DeleteScopeEvent(io.pravega.shared.controller.event.DeleteScopeEvent) PravegaZkCuratorResource(io.pravega.controller.PravegaZkCuratorResource) UUID(java.util.UUID) ScaleOperationTask(io.pravega.controller.server.eventProcessor.requesthandlers.ScaleOperationTask) Collectors(java.util.stream.Collectors) List(java.util.List) CuratorFramework(org.apache.curator.framework.CuratorFramework) Config(io.pravega.controller.util.Config) UpdateStreamTask(io.pravega.controller.server.eventProcessor.requesthandlers.UpdateStreamTask) VersionedTransactionData(io.pravega.controller.store.stream.VersionedTransactionData) Optional(java.util.Optional) DeleteScopeTask(io.pravega.controller.server.eventProcessor.requesthandlers.DeleteScopeTask) TruncateStreamTask(io.pravega.controller.server.eventProcessor.requesthandlers.TruncateStreamTask) IntStream(java.util.stream.IntStream) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) OperationContext(io.pravega.controller.store.stream.OperationContext) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) CommittingTransactionsRecord(io.pravega.controller.store.stream.records.CommittingTransactionsRecord) SegmentHelper(io.pravega.controller.server.SegmentHelper) ModelHelper(io.pravega.client.control.impl.ModelHelper) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) BucketStore(io.pravega.controller.store.stream.BucketStore) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) EventStreamClientFactory(io.pravega.client.EventStreamClientFactory) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) SocketConnectionFactoryImpl(io.pravega.client.connection.impl.SocketConnectionFactoryImpl) NameUtils(io.pravega.shared.NameUtils) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Mockito.verify(org.mockito.Mockito.verify) AbstractMap(java.util.AbstractMap) EpochRecord(io.pravega.controller.store.stream.records.EpochRecord) State(io.pravega.controller.store.stream.State) ExecutorServiceHelpers(io.pravega.common.concurrent.ExecutorServiceHelpers) DeleteReaderGroupTask(io.pravega.controller.server.eventProcessor.requesthandlers.DeleteReaderGroupTask) ScaleOpEvent(io.pravega.shared.controller.event.ScaleOpEvent) Collections(java.util.Collections) ClientConfig(io.pravega.client.ClientConfig) DeleteScopeTask(io.pravega.controller.server.eventProcessor.requesthandlers.DeleteScopeTask) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) CompletableFuture(java.util.concurrent.CompletableFuture) TableMetadataTasks(io.pravega.controller.task.KeyValueTable.TableMetadataTasks) ArrayList(java.util.ArrayList) List(java.util.List) DeleteScopeEvent(io.pravega.shared.controller.event.DeleteScopeEvent) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) UUID(java.util.UUID) OperationContext(io.pravega.controller.store.stream.OperationContext) ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) KVTableMetadataStore(io.pravega.controller.store.kvtable.KVTableMetadataStore) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Test(org.junit.Test)

Example 47 with OperationContext

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

the class AbortRequestHandler method processEvent.

@Override
public CompletableFuture<Void> processEvent(AbortEvent event) {
    String scope = event.getScope();
    String stream = event.getStream();
    int epoch = event.getEpoch();
    UUID txId = event.getTxid();
    long requestId = event.getRequestId();
    if (requestId == 0L) {
        requestId = ControllerService.nextRequestId();
    }
    Timer timer = new Timer();
    OperationContext context = streamMetadataStore.createStreamContext(scope, stream, requestId);
    log.info(requestId, "Aborting transaction {} on stream {}/{}", event.getTxid(), event.getScope(), event.getStream());
    return Futures.toVoid(streamMetadataStore.getSegmentsInEpoch(event.getScope(), event.getStream(), epoch, context, executor).thenApply(segments -> segments.stream().map(StreamSegmentRecord::segmentId).collect(Collectors.toList())).thenCompose(segments -> streamMetadataTasks.notifyTxnAbort(scope, stream, segments, txId, context.getRequestId())).thenCompose(x -> streamMetadataStore.abortTransaction(scope, stream, txId, context, executor)).whenComplete((result, error) -> {
        if (error != null) {
            log.warn(context.getRequestId(), "Failed aborting transaction {} on stream {}/{}", event.getTxid(), event.getScope(), event.getStream());
            TransactionMetrics.getInstance().abortTransactionFailed(scope, stream);
        } else {
            log.info(context.getRequestId(), "Successfully aborted transaction {} on stream {}/{}", event.getTxid(), event.getScope(), event.getStream());
            if (processedEvents != null) {
                processedEvents.offer(event);
            }
            TransactionMetrics.getInstance().abortTransaction(scope, stream, timer.getElapsed());
        }
    }));
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext) ControllerService(io.pravega.controller.server.ControllerService) OperationContext(io.pravega.controller.store.stream.OperationContext) SerializedRequestHandler(io.pravega.controller.eventProcessor.impl.SerializedRequestHandler) TransactionMetrics(io.pravega.controller.metrics.TransactionMetrics) StreamSegmentRecord(io.pravega.controller.store.stream.records.StreamSegmentRecord) LoggerFactory(org.slf4j.LoggerFactory) BlockingQueue(java.util.concurrent.BlockingQueue) CompletableFuture(java.util.concurrent.CompletableFuture) UUID(java.util.UUID) Timer(io.pravega.common.Timer) Collectors(java.util.stream.Collectors) TagLogger(io.pravega.common.tracing.TagLogger) AbortEvent(io.pravega.shared.controller.event.AbortEvent) 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) Futures(io.pravega.common.concurrent.Futures) StreamSegmentRecord(io.pravega.controller.store.stream.records.StreamSegmentRecord) Timer(io.pravega.common.Timer) UUID(java.util.UUID)

Example 48 with OperationContext

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

the class CommitRequestHandler method execute.

/**
 * This method attempts to collect all transactions in the epoch that are marked for commit and decides if they can be
 * committed in active epoch or if it needs to roll the transactions.
 *
 * @param event event to process
 * @return Completable future which indicates completion of processing of commit event.
 */
@Override
public CompletableFuture<Void> execute(CommitEvent event) {
    String scope = event.getScope();
    String stream = event.getStream();
    long requestId = streamMetadataTasks.getRequestId(null);
    OperationContext context = streamMetadataStore.createStreamContext(scope, stream, requestId);
    log.debug(requestId, "Attempting to commit available transactions on stream {}/{}", event.getScope(), event.getStream());
    CompletableFuture<Void> future = new CompletableFuture<>();
    // Note: we will ignore the epoch in the event. It has been deprecated.
    // The logic now finds the smallest epoch with transactions and commits them.
    tryCommitTransactions(scope, stream, context).whenComplete((r, e) -> {
        if (e != null) {
            Throwable cause = Exceptions.unwrap(e);
            // for operation not allowed, we will report the event
            if (cause instanceof StoreException.OperationNotAllowedException) {
                log.debug(requestId, "Cannot commit transaction on stream {}/{}. Postponing", scope, stream);
            } else {
                log.warn(requestId, "Exception while attempting to commit transaction on stream {}/{}", scope, stream, e);
                TransactionMetrics.getInstance().commitTransactionFailed(scope, stream);
            }
            future.completeExceptionally(cause);
        } else {
            if (r >= 0) {
                log.info(requestId, "Successfully committed transactions on epoch {} on stream {}/{}", r, scope, stream);
            } else {
                log.info(requestId, "No transactions found in committing state on stream {}/{}", scope, stream);
            }
            if (processedEvents != null) {
                try {
                    processedEvents.offer(event);
                } catch (Exception ex) {
                // ignore, this processed events is only added for enabling unit testing this class
                }
            }
            future.complete(null);
        }
    });
    return future;
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext) CompletableFuture(java.util.concurrent.CompletableFuture) StoreException(io.pravega.controller.store.stream.StoreException)

Example 49 with OperationContext

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

the class CreateReaderGroupTask method execute.

@Override
public CompletableFuture<Void> execute(final CreateReaderGroupEvent request) {
    String scope = request.getScope();
    String readerGroup = request.getRgName();
    UUID readerGroupId = request.getReaderGroupId();
    ReaderGroupConfig config = getConfigFromEvent(request);
    long requestId = request.getRequestId();
    OperationContext context = streamMetadataStore.createRGContext(scope, readerGroup, requestId);
    return streamMetadataStore.isScopeSealed(scope, context, executor).thenCompose(exists -> {
        if (exists) {
            log.warn(requestId, "Scope {} already in sealed state", scope);
            return CompletableFuture.completedFuture(null);
        }
        return RetryHelper.withRetriesAsync(() -> streamMetadataStore.getReaderGroupId(scope, readerGroup, context, executor).thenCompose(rgId -> {
            if (!rgId.equals(readerGroupId)) {
                log.warn(requestId, "Skipping processing of CreateReaderGroupEvent with stale UUID.");
                return CompletableFuture.completedFuture(null);
            }
            return streamMetadataTasks.isRGCreationComplete(scope, readerGroup, context).thenCompose(complete -> {
                if (!complete) {
                    return Futures.toVoid(streamMetadataTasks.createReaderGroupTasks(scope, readerGroup, config, request.getCreateTimeStamp(), context));
                }
                return CompletableFuture.completedFuture(null);
            });
        }), e -> Exceptions.unwrap(e) instanceof RetryableException, Integer.MAX_VALUE, executor);
    });
}
Also used : ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) OperationContext(io.pravega.controller.store.stream.OperationContext) OperationContext(io.pravega.controller.store.stream.OperationContext) StreamCut(io.pravega.client.stream.StreamCut) Exceptions(io.pravega.common.Exceptions) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) TagLogger(io.pravega.common.tracing.TagLogger) Stream(io.pravega.client.stream.Stream) RetryableException(io.pravega.controller.retryable.RetryableException) Map(java.util.Map) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) RGStreamCutRecord(io.pravega.shared.controller.event.RGStreamCutRecord) Preconditions(com.google.common.base.Preconditions) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) Futures(io.pravega.common.concurrent.Futures) CreateReaderGroupEvent(io.pravega.shared.controller.event.CreateReaderGroupEvent) ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) RetryHelper(io.pravega.controller.util.RetryHelper) RetryableException(io.pravega.controller.retryable.RetryableException) UUID(java.util.UUID)

Example 50 with OperationContext

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

the class DeleteReaderGroupTask method execute.

@Override
public CompletableFuture<Void> execute(final DeleteReaderGroupEvent request) {
    String scope = request.getScope();
    String readerGroup = request.getRgName();
    long requestId = request.getRequestId();
    UUID readerGroupId = request.getReaderGroupId();
    final OperationContext context = streamMetadataStore.createRGContext(scope, readerGroup, requestId);
    return streamMetadataStore.getReaderGroupId(scope, readerGroup, context, executor).thenCompose(id -> {
        if (!id.equals(readerGroupId)) {
            log.warn(requestId, "Skipping processing of Reader Group delete request {} as UUIDs did not match.", requestId);
            return CompletableFuture.completedFuture(null);
        }
        return streamMetadataStore.getReaderGroupConfigRecord(scope, readerGroup, context, executor).thenCompose(configRecord -> {
            if (!ReaderGroupConfig.StreamDataRetention.values()[configRecord.getObject().getRetentionTypeOrdinal()].equals(ReaderGroupConfig.StreamDataRetention.NONE)) {
                String scopedRGName = NameUtils.getScopedReaderGroupName(scope, readerGroup);
                // update Stream metadata tables, if RG is a Subscriber
                Iterator<String> streamIter = configRecord.getObject().getStartingStreamCuts().keySet().iterator();
                return Futures.loop(streamIter::hasNext, () -> {
                    Stream stream = Stream.of(streamIter.next());
                    OperationContext streamContext = streamMetadataStore.createStreamContext(stream.getScope(), stream.getStreamName(), requestId);
                    return streamMetadataStore.deleteSubscriber(stream.getScope(), stream.getStreamName(), scopedRGName, configRecord.getObject().getGeneration(), streamContext, executor);
                }, executor);
            }
            return CompletableFuture.completedFuture(null);
        }).thenCompose(v -> {
            String rgStreamContext = NameUtils.getStreamForReaderGroup(readerGroup);
            OperationContext streamContext = streamMetadataStore.createStreamContext(scope, rgStreamContext, requestId);
            return streamMetadataTasks.sealStream(scope, rgStreamContext, streamContext).thenCompose(z -> streamMetadataTasks.deleteStream(scope, rgStreamContext, streamContext));
        }).thenCompose(v1 -> streamMetadataStore.deleteReaderGroup(scope, readerGroup, context, executor));
    });
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext) OperationContext(io.pravega.controller.store.stream.OperationContext) NameUtils(io.pravega.shared.NameUtils) Iterator(java.util.Iterator) DeleteReaderGroupEvent(io.pravega.shared.controller.event.DeleteReaderGroupEvent) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) UUID(java.util.UUID) TagLogger(io.pravega.common.tracing.TagLogger) Stream(io.pravega.client.stream.Stream) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) Preconditions(com.google.common.base.Preconditions) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) Futures(io.pravega.common.concurrent.Futures) ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) Stream(io.pravega.client.stream.Stream) UUID(java.util.UUID)

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