Search in sources :

Example 1 with ReaderGroupState

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);
    }
}
Also used : ReaderGroupState(io.pravega.client.stream.impl.ReaderGroupState) SegmentNotification(io.pravega.client.stream.notifications.SegmentNotification)

Example 2 with ReaderGroupState

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());
    }
}
Also used : EndOfDataNotification(io.pravega.client.stream.notifications.EndOfDataNotification) ReaderGroupState(io.pravega.client.stream.impl.ReaderGroupState)

Aggregations

ReaderGroupState (io.pravega.client.stream.impl.ReaderGroupState)2 EndOfDataNotification (io.pravega.client.stream.notifications.EndOfDataNotification)1 SegmentNotification (io.pravega.client.stream.notifications.SegmentNotification)1