Search in sources :

Example 1 with SegmentCompleted

use of io.pravega.client.stream.impl.ReaderGroupState.SegmentCompleted in project pravega by pravega.

the class ReaderGroupStateManager method handleEndOfSegment.

/**
 * Handles a segment being completed by calling the controller to gather all successors to the completed segment.
 */
void handleEndOfSegment(Segment segmentCompleted) throws ReinitializationRequiredException {
    val successors = getAndHandleExceptions(controller.getSuccessors(segmentCompleted), RuntimeException::new);
    synchronized (this) {
        latestDelegationToken = successors.getDelegationToken();
    }
    AtomicBoolean reinitRequired = new AtomicBoolean(false);
    sync.updateState(state -> {
        if (!state.isReaderOnline(readerId)) {
            reinitRequired.set(true);
            return null;
        }
        return Collections.singletonList(new SegmentCompleted(readerId, segmentCompleted, successors.getSegmentToPredecessor()));
    });
    if (reinitRequired.get()) {
        throw new ReinitializationRequiredException();
    }
    acquireTimer.zero();
}
Also used : lombok.val(lombok.val) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ReinitializationRequiredException(io.pravega.client.stream.ReinitializationRequiredException) SegmentCompleted(io.pravega.client.stream.impl.ReaderGroupState.SegmentCompleted)

Aggregations

ReinitializationRequiredException (io.pravega.client.stream.ReinitializationRequiredException)1 SegmentCompleted (io.pravega.client.stream.impl.ReaderGroupState.SegmentCompleted)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 lombok.val (lombok.val)1