use of io.pravega.client.stream.TruncatedDataException in project pravega by pravega.
the class RevisionedStreamClientImpl method readFrom.
@Override
public Iterator<Entry<Revision, T>> readFrom(Revision start) {
synchronized (lock) {
long startOffset = start.asImpl().getOffsetInSegment();
SegmentInfo segmentInfo = meta.getSegmentInfo();
long endOffset = segmentInfo.getWriteOffset();
if (startOffset < segmentInfo.getStartingOffset()) {
throw new TruncatedDataException("Data at the supplied revision has been truncated.");
}
log.trace("Creating iterator from {} until {}", startOffset, endOffset);
return new StreamIterator(startOffset, endOffset);
}
}
use of io.pravega.client.stream.TruncatedDataException in project pravega by pravega.
the class EventStreamReaderImpl method handleSegmentTruncated.
private void handleSegmentTruncated(SegmentInputStream segmentReader) throws ReinitializationRequiredException, TruncatedDataException {
Segment segmentId = segmentReader.getSegmentId();
log.info("{} encountered truncation for segment {} ", this, segmentId);
String delegationToken = groupState.getLatestDelegationToken();
@Cleanup SegmentMetadataClient metadataClient = metadataClientFactory.createSegmentMetadataClient(segmentId, delegationToken);
try {
long startingOffset = metadataClient.getSegmentInfo().getStartingOffset();
segmentReader.setOffset(startingOffset);
} catch (NoSuchSegmentException e) {
handleEndOfSegment(segmentReader);
}
throw new TruncatedDataException();
}
use of io.pravega.client.stream.TruncatedDataException in project pravega by pravega.
the class StateSynchronizerImpl method fetchUpdates.
@Override
public void fetchUpdates() {
Revision revision = getRevisionToReadFrom(true);
log.trace("Fetching updates after {} ", revision);
try {
val iter = client.readFrom(revision);
while (iter.hasNext()) {
Entry<Revision, UpdateOrInit<StateT>> entry = iter.next();
log.trace("Found entry {} ", entry.getValue());
if (entry.getValue().isInit()) {
InitialUpdate<StateT> init = entry.getValue().getInit();
if (isNewer(entry.getKey())) {
updateCurrentState(init.create(segment.getScopedStreamName(), entry.getKey()));
}
} else {
applyUpdates(entry.getKey().asImpl(), entry.getValue().getUpdates());
}
}
} catch (TruncatedDataException e) {
log.warn("{} encountered truncation on segment {}", this, segment);
handleTruncation();
}
}
Aggregations