use of io.pravega.client.stream.impl.ReaderGroupState in project pravega by pravega.
the class SegmentNotifier method checkAndTriggerSegmentNotification.
private void checkAndTriggerSegmentNotification() {
this.synchronizer.fetchUpdates();
ReaderGroupState state = this.synchronizer.getState();
int newNumberOfSegments = state.getNumberOfSegments();
checkState(newNumberOfSegments > 0, "Number of segments cannot be zero");
if (this.numberOfSegments == 0) {
// initialize the number of segments.
this.numberOfSegments = newNumberOfSegments;
} else if (this.numberOfSegments != newNumberOfSegments) {
// SegmentNotification has happened.
this.numberOfSegments = newNumberOfSegments;
SegmentNotification notification = SegmentNotification.builder().numOfSegments(state.getNumberOfSegments()).numOfReaders(state.getOnlineReaders().size()).build();
notifySystem.notify(notification);
}
}
use of io.pravega.client.stream.impl.ReaderGroupState in project pravega by pravega.
the class EndOfDataNotifier method checkAndTriggerEndOfStreamNotification.
private void checkAndTriggerEndOfStreamNotification() {
this.synchronizer.fetchUpdates();
ReaderGroupState state = this.synchronizer.getState();
if (state.isEndOfData()) {
notifySystem.notify(new EndOfDataNotification());
}
}
Aggregations