use of io.pravega.common.TimeoutTimer in project pravega by pravega.
the class StreamSegmentContainer method saveStorageSnapshot.
private CompletableFuture<Void> saveStorageSnapshot(SnapshotInfo checkpoint, Duration timeout) {
TimeoutTimer timer = new TimeoutTimer(timeout);
val attributeUpdates = AttributeUpdateCollection.from(new AttributeUpdate(ATTRIBUTE_SLTS_LATEST_SNAPSHOT_ID, AttributeUpdateType.Replace, checkpoint.getSnapshotId()), new AttributeUpdate(ATTRIBUTE_SLTS_LATEST_SNAPSHOT_EPOCH, AttributeUpdateType.Replace, checkpoint.getEpoch()));
return this.metadataStore.getOrAssignSegmentId(NameUtils.getMetadataSegmentName(this.metadata.getContainerId()), timer.getRemaining(), streamSegmentId -> updateAttributesForSegment(streamSegmentId, attributeUpdates, timer.getRemaining())).thenRun(() -> log.debug("{}: Save SLTS snapshot. {}", this.traceObjectId, checkpoint));
}
use of io.pravega.common.TimeoutTimer in project pravega by pravega.
the class StreamSegmentContainer method append.
// endregion
// region StreamSegmentStore Implementation
@Override
public CompletableFuture<Long> append(String streamSegmentName, BufferView data, AttributeUpdateCollection attributeUpdates, Duration timeout) {
ensureRunning();
TimeoutTimer timer = new TimeoutTimer(timeout);
logRequest("append", streamSegmentName, data.getLength());
this.metrics.append();
return this.metadataStore.getOrAssignSegmentId(streamSegmentName, timer.getRemaining(), streamSegmentId -> {
val operation = new StreamSegmentAppendOperation(streamSegmentId, data, attributeUpdates);
return processAppend(operation, timer).thenApply(v -> operation.getLastStreamSegmentOffset());
});
}
Aggregations