use of io.pravega.shared.controller.event.CreateReaderGroupEvent 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);
});
}
use of io.pravega.shared.controller.event.CreateReaderGroupEvent in project pravega by pravega.
the class StreamMetadataTasksTest method readerGroupFailureTests.
@Test(timeout = 30000)
public void readerGroupFailureTests() throws InterruptedException {
WriterMock requestEventWriter = new WriterMock(streamMetadataTasks, executor);
streamMetadataTasks.setRequestEventWriter(requestEventWriter);
UpdateReaderGroupEvent badUpdateEvent = new UpdateReaderGroupEvent(SCOPE, "rg3", 2L, UUID.randomUUID(), 0L, false, ImmutableSet.of());
requestEventWriter.writeEvent(badUpdateEvent);
AssertExtensions.assertFutureThrows("DataNotFoundException", processFailingEvent(requestEventWriter), e -> Exceptions.unwrap(e) instanceof StoreException.DataNotFoundException);
String scopedStreamName = "scope/stream";
ReaderGroupConfig rgConf = ReaderGroupConfig.builder().disableAutomaticCheckpoints().stream(scopedStreamName).retentionType(ReaderGroupConfig.StreamDataRetention.NONE).build();
CreateReaderGroupEvent badCreateEvent = buildCreateRGEvent(SCOPE, "rg", rgConf, 1L, System.currentTimeMillis());
requestEventWriter.writeEvent(badCreateEvent);
AssertExtensions.assertFutureThrows("DataNotFoundException", processFailingEvent(requestEventWriter), e -> Exceptions.unwrap(e) instanceof StoreException.DataNotFoundException);
DeleteReaderGroupEvent badDeleteEvent = new DeleteReaderGroupEvent(SCOPE, "rg3", 1L, UUID.randomUUID());
requestEventWriter.writeEvent(badDeleteEvent);
AssertExtensions.assertFutureThrows("DataNotFoundException", processFailingEvent(requestEventWriter), e -> Exceptions.unwrap(e) instanceof StoreException.DataNotFoundException);
}
Aggregations