use of io.pravega.client.stream.StreamCut in project pravega by pravega.
the class ReaderGroupImpl method getUnreadBytesIgnoringRange.
private long getUnreadBytesIgnoringRange(Map<Stream, Map<SegmentWithRange, Long>> positions, Map<Segment, Long> endSegments) {
log.debug("Compute unread bytes from position {}", positions);
long totalLength = 0;
for (Entry<Stream, Map<SegmentWithRange, Long>> streamPosition : positions.entrySet()) {
StreamCut fromStreamCut = new StreamCutImpl(streamPosition.getKey(), dropRange(streamPosition.getValue()));
StreamCut toStreamCut = computeEndStreamCut(streamPosition.getKey(), endSegments);
totalLength += Futures.getAndHandleExceptions(getRemainingBytes(streamPosition.getKey(), fromStreamCut, toStreamCut), RuntimeException::new).longValue();
}
return totalLength;
}
use of io.pravega.client.stream.StreamCut in project pravega by pravega.
the class ReaderGroupManagerImplTest method testDeleteReaderGroupRGStreamDeleted.
@Test
public void testDeleteReaderGroupRGStreamDeleted() {
ReaderGroupConfig config = ReaderGroupConfig.builder().startFromStreamCuts(ImmutableMap.<Stream, StreamCut>builder().put(createStream("s1"), createStreamCut("s1", 2)).put(createStream("s2"), createStreamCut("s2", 3)).build()).retentionType(ReaderGroupConfig.StreamDataRetention.MANUAL_RELEASE_AT_USER_STREAMCUT).build();
when(clientFactory.createStateSynchronizer(anyString(), any(Serializer.class), any(Serializer.class), any(SynchronizerConfig.class))).thenThrow(new InvalidStreamException(""));
when(controller.getReaderGroupConfig(SCOPE, GROUP_NAME)).thenReturn(CompletableFuture.completedFuture(config));
when(controller.deleteReaderGroup(SCOPE, GROUP_NAME, config.getReaderGroupId())).thenReturn(CompletableFuture.completedFuture(true));
// Delete ReaderGroup
readerGroupManager.deleteReaderGroup(GROUP_NAME);
verify(controller, times(1)).getReaderGroupConfig(SCOPE, GROUP_NAME);
verify(controller, times(1)).deleteReaderGroup(SCOPE, GROUP_NAME, config.getReaderGroupId());
}
use of io.pravega.client.stream.StreamCut in project pravega by pravega.
the class ReaderGroupManagerImplTest method testDeleteRGMigrationConfigOnController.
@Test
@SuppressWarnings("unchecked")
public void testDeleteRGMigrationConfigOnController() {
ReaderGroupConfig config = ReaderGroupConfig.builder().startFromStreamCuts(ImmutableMap.<Stream, StreamCut>builder().put(createStream("s1"), createStreamCut("s1", 2)).put(createStream("s2"), createStreamCut("s2", 3)).build()).retentionType(ReaderGroupConfig.StreamDataRetention.MANUAL_RELEASE_AT_USER_STREAMCUT).build();
when(clientFactory.createStateSynchronizer(anyString(), any(Serializer.class), any(Serializer.class), any(SynchronizerConfig.class))).thenReturn(synchronizer);
when(synchronizer.getState()).thenReturn(state);
when(state.getConfig()).thenReturn(config);
ReaderGroupConfig expectedConfig = ReaderGroupConfig.cloneConfig(config, UUID.randomUUID(), 0L);
when(controller.getReaderGroupConfig(anyString(), anyString())).thenReturn(CompletableFuture.completedFuture(expectedConfig));
when(controller.deleteReaderGroup(anyString(), anyString(), any(UUID.class))).thenReturn(CompletableFuture.completedFuture(true));
// Delete ReaderGroup
readerGroupManager.deleteReaderGroup(GROUP_NAME);
verify(controller, times(1)).getReaderGroupConfig(SCOPE, GROUP_NAME);
verify(controller, times(1)).deleteReaderGroup(SCOPE, GROUP_NAME, expectedConfig.getReaderGroupId());
}
use of io.pravega.client.stream.StreamCut in project pravega by pravega.
the class ReaderGroupManagerImplTest method testDeleteReaderGroup.
@Test
public void testDeleteReaderGroup() {
final UUID rgId = UUID.randomUUID();
ReaderGroupConfig config = ReaderGroupConfig.builder().startFromStreamCuts(ImmutableMap.<Stream, StreamCut>builder().put(createStream("s1"), createStreamCut("s1", 2)).put(createStream("s2"), createStreamCut("s2", 3)).build()).retentionType(ReaderGroupConfig.StreamDataRetention.MANUAL_RELEASE_AT_USER_STREAMCUT).build();
config = ReaderGroupConfig.cloneConfig(config, rgId, 0L);
when(clientFactory.createStateSynchronizer(anyString(), any(Serializer.class), any(Serializer.class), any(SynchronizerConfig.class))).thenReturn(synchronizer);
when(synchronizer.getState()).thenReturn(state);
when(state.getConfig()).thenReturn(config);
when(controller.deleteReaderGroup(SCOPE, GROUP_NAME, config.getReaderGroupId())).thenReturn(CompletableFuture.completedFuture(true));
// Delete ReaderGroup
readerGroupManager.deleteReaderGroup(GROUP_NAME);
verify(controller, times(1)).deleteReaderGroup(SCOPE, GROUP_NAME, config.getReaderGroupId());
}
use of io.pravega.client.stream.StreamCut in project pravega by pravega.
the class ReaderGroupManagerImplTest method testCreateReaderGroupWithSameConfig.
@Test
public void testCreateReaderGroupWithSameConfig() {
ReaderGroupConfig config = ReaderGroupConfig.builder().startFromStreamCuts(ImmutableMap.<Stream, StreamCut>builder().put(createStream("s1"), createStreamCut("s1", 2)).put(createStream("s2"), createStreamCut("s2", 3)).build()).retentionType(ReaderGroupConfig.StreamDataRetention.MANUAL_RELEASE_AT_USER_STREAMCUT).build();
ReaderGroupConfig expectedConfig = ReaderGroupConfig.cloneConfig(config, UUID.randomUUID(), 1L);
when(controller.createReaderGroup(anyString(), anyString(), any(ReaderGroupConfig.class))).thenReturn(CompletableFuture.completedFuture(expectedConfig));
// Create a ReaderGroup
boolean created = readerGroupManager.createReaderGroup(GROUP_NAME, config);
assertFalse(created);
verify(clientFactory, never()).createStateSynchronizer(anyString(), any(Serializer.class), any(Serializer.class), any(SynchronizerConfig.class));
verify(synchronizer, never()).initialize(any(InitialUpdate.class));
}
Aggregations