use of io.pravega.client.stream.impl.ReaderGroupState.RemoveReader in project pravega by pravega.
the class ReaderGroupStateManager method readerShutdown.
/**
* Shuts down a reader, releasing all of its segments. The reader should cease all operations.
* @param lastPosition The last position the reader successfully read from.
*/
static void readerShutdown(String readerId, Position lastPosition, StateSynchronizer<ReaderGroupState> sync) {
sync.fetchUpdates();
sync.updateState((state, updates) -> {
Set<Segment> segments = state.getSegments(readerId);
if (segments == null) {
return;
}
log.debug("Removing reader {} from reader group. CurrentState is: {}. Position is: {}.", readerId, state, lastPosition);
updates.add(new RemoveReader(readerId, lastPosition == null ? Collections.emptyMap() : lastPosition.asImpl().getOwnedSegmentsWithOffsets()));
});
}
use of io.pravega.client.stream.impl.ReaderGroupState.RemoveReader in project pravega by pravega.
the class SerializationTest method testReaderGroupUpdates.
@Test
public void testReaderGroupUpdates() throws Exception {
ReaderGroupUpdateSerializer serializer = new ReaderGroupUpdateSerializer();
verify(serializer, new AddReader(createString()));
verify(serializer, new RemoveReader(createString(), createSegmentToLongMap()));
verify(serializer, new ReleaseSegment(createString(), createSegment(), r.nextLong()));
verify(serializer, new AcquireSegment(createString(), createSegment()));
verify(serializer, new UpdateDistanceToTail(createString(), r.nextLong(), createSegmentRangeMap()));
verify(serializer, new SegmentCompleted(createString(), createSegmentWithRange(), createMap(this::createSegmentWithRange, this::createLongList)));
verify(serializer, new CheckpointReader(createString(), createString(), createSegmentToLongMap()));
verify(serializer, new CreateCheckpoint(createString()));
verify(serializer, new ClearCheckpointsBefore(createString()));
verify(serializer, new UpdatingConfig(r.nextBoolean()));
}
Aggregations