use of io.pravega.shared.NameUtils.getStreamForReaderGroup in project pravega by pravega.
the class ReaderGroupManagerImpl method deleteReaderGroup.
@Override
public void deleteReaderGroup(String groupName) {
UUID readerGroupId = null;
ReaderGroupConfig syncConfig = null;
try {
@Cleanup StateSynchronizer<ReaderGroupState> synchronizer = clientFactory.createStateSynchronizer(NameUtils.getStreamForReaderGroup(groupName), new ReaderGroupStateUpdatesSerializer(), new ReaderGroupStateInitSerializer(), SynchronizerConfig.builder().build());
synchronizer.fetchUpdates();
syncConfig = synchronizer.getState().getConfig();
readerGroupId = syncConfig.getReaderGroupId();
if (ReaderGroupConfig.DEFAULT_UUID.equals(syncConfig.getReaderGroupId()) && ReaderGroupConfig.DEFAULT_GENERATION == syncConfig.getGeneration()) {
// migrate RG case
try {
controller.getReaderGroupConfig(scope, groupName).thenCompose(conf -> controller.deleteReaderGroup(scope, groupName, conf.getReaderGroupId())).join();
} catch (ReaderGroupNotFoundException ex) {
controller.sealStream(scope, getStreamForReaderGroup(groupName)).thenCompose(b -> controller.deleteStream(scope, getStreamForReaderGroup(groupName))).exceptionally(e -> {
log.warn("Failed to delete ReaderGroup Stream {}", getStreamForReaderGroup(groupName), e);
throw Exceptions.sneakyThrow(e);
}).join();
}
return;
}
} catch (InvalidStreamException ex) {
log.warn("State-Synchronizer Stream for ReaderGroup {} was not found.", NameUtils.getScopedReaderGroupName(scope, groupName));
// if the State Synchronizer Stream was deleted, but the RG still exists, get Id from Controller
readerGroupId = getAndHandleExceptions(controller.getReaderGroupConfig(scope, groupName), RuntimeException::new).getReaderGroupId();
}
// normal delete
getAndHandleExceptions(controller.deleteReaderGroup(scope, groupName, readerGroupId), RuntimeException::new);
}
Aggregations