Search in sources :

Example 26 with WriterFlushResult

use of io.pravega.segmentstore.server.WriterFlushResult in project pravega by pravega.

the class WriterTableProcessor method flush.

@Override
public CompletableFuture<WriterFlushResult> flush(boolean force, Duration timeout) {
    Exceptions.checkNotClosed(this.closed.get(), this);
    if (!force && !mustFlush()) {
        return CompletableFuture.completedFuture(new WriterFlushResult());
    }
    TimeoutTimer timer = new TimeoutTimer(timeout);
    return this.connector.getSegment(timer.getRemaining()).thenComposeAsync(segment -> flushWithSingleRetry(segment, timer).thenComposeAsync(flushResult -> {
        flushComplete(flushResult);
        return compactIfNeeded(segment, flushResult.highestCopiedOffset, timer).thenApply(v -> flushResult);
    }, this.executor), this.executor);
}
Also used : TableAttributes(io.pravega.segmentstore.contracts.tables.TableAttributes) SneakyThrows(lombok.SneakyThrows) Exceptions(io.pravega.common.Exceptions) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CompletableFuture(java.util.concurrent.CompletableFuture) BadAttributeUpdateException(io.pravega.segmentstore.contracts.BadAttributeUpdateException) BufferView(io.pravega.common.util.BufferView) Duration(java.time.Duration) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) SerializationException(io.pravega.common.io.SerializationException) Operation(io.pravega.segmentstore.server.logs.operations.Operation) WriterFlushResult(io.pravega.segmentstore.server.WriterFlushResult) TimeoutTimer(io.pravega.common.TimeoutTimer) NonNull(lombok.NonNull) Collection(java.util.Collection) lombok.val(lombok.val) ThreadSafe(javax.annotation.concurrent.ThreadSafe) GuardedBy(javax.annotation.concurrent.GuardedBy) Collectors(java.util.stream.Collectors) AtomicLong(java.util.concurrent.atomic.AtomicLong) DirectSegmentAccess(io.pravega.segmentstore.server.DirectSegmentAccess) Slf4j(lombok.extern.slf4j.Slf4j) SegmentOperation(io.pravega.segmentstore.server.SegmentOperation) CachedStreamSegmentAppendOperation(io.pravega.segmentstore.server.logs.operations.CachedStreamSegmentAppendOperation) Preconditions(com.google.common.base.Preconditions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) DataCorruptionException(io.pravega.segmentstore.server.DataCorruptionException) WriterSegmentProcessor(io.pravega.segmentstore.server.WriterSegmentProcessor) ArrayDeque(java.util.ArrayDeque) Futures(io.pravega.common.concurrent.Futures) ReadResult(io.pravega.segmentstore.contracts.ReadResult) WriterFlushResult(io.pravega.segmentstore.server.WriterFlushResult) TimeoutTimer(io.pravega.common.TimeoutTimer)

Aggregations

WriterFlushResult (io.pravega.segmentstore.server.WriterFlushResult)26 AtomicLong (java.util.concurrent.atomic.AtomicLong)17 Cleanup (lombok.Cleanup)16 StorageOperation (io.pravega.segmentstore.server.logs.operations.StorageOperation)15 DataCorruptionException (io.pravega.segmentstore.server.DataCorruptionException)12 SegmentProperties (io.pravega.segmentstore.contracts.SegmentProperties)11 StreamSegmentNotExistsException (io.pravega.segmentstore.contracts.StreamSegmentNotExistsException)11 Operation (io.pravega.segmentstore.server.logs.operations.Operation)11 Duration (java.time.Duration)11 CompletableFuture (java.util.concurrent.CompletableFuture)11 Test (org.junit.Test)11 Preconditions (com.google.common.base.Preconditions)10 Exceptions (io.pravega.common.Exceptions)10 Futures (io.pravega.common.concurrent.Futures)10 Attributes (io.pravega.segmentstore.contracts.Attributes)10 UpdateableSegmentMetadata (io.pravega.segmentstore.server.UpdateableSegmentMetadata)10 CachedStreamSegmentAppendOperation (io.pravega.segmentstore.server.logs.operations.CachedStreamSegmentAppendOperation)10 StreamSegmentSealOperation (io.pravega.segmentstore.server.logs.operations.StreamSegmentSealOperation)10 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)10 AtomicReference (java.util.concurrent.atomic.AtomicReference)10