Search in sources :

Example 6 with StreamTruncationRecord

use of io.pravega.controller.store.stream.tables.StreamTruncationRecord in project pravega by pravega.

the class PersistentStreamBase method completeTruncation.

@Override
public CompletableFuture<Void> completeTruncation() {
    return getTruncationData(true).thenCompose(truncationData -> {
        Preconditions.checkNotNull(truncationData);
        StreamProperty<StreamTruncationRecord> current = SerializationUtils.deserialize(truncationData.getData());
        if (current.isUpdating()) {
            StreamTruncationRecord truncationRecord = current.getProperty();
            StreamProperty<StreamTruncationRecord> completedProp = StreamProperty.complete(truncationRecord.mergeDeleted());
            return setTruncationData(new Data<>(SerializationUtils.serialize(completedProp), truncationData.getVersion()));
        } else {
            // idempotent
            return CompletableFuture.completedFuture(null);
        }
    });
}
Also used : StreamTruncationRecord(io.pravega.controller.store.stream.tables.StreamTruncationRecord)

Aggregations

StreamTruncationRecord (io.pravega.controller.store.stream.tables.StreamTruncationRecord)6 HashMap (java.util.HashMap)5 Test (org.junit.Test)5 ScalingPolicy (io.pravega.client.stream.ScalingPolicy)4 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)4 ControllerEventStreamWriterMock (io.pravega.controller.mocks.ControllerEventStreamWriterMock)3 AbstractMap (java.util.AbstractMap)3 ArrayList (java.util.ArrayList)3 RetentionPolicy (io.pravega.client.stream.RetentionPolicy)2 StreamCutRecord (io.pravega.controller.store.stream.StreamCutRecord)2 ScaleStreamStatus (io.pravega.controller.stream.api.grpc.v1.Controller.ScaleResponse.ScaleStreamStatus)2 UpdateStreamStatus (io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus)2 ScaleOperationTask (io.pravega.controller.server.eventProcessor.requesthandlers.ScaleOperationTask)1 TruncateStreamTask (io.pravega.controller.server.eventProcessor.requesthandlers.TruncateStreamTask)1 StartScaleResponse (io.pravega.controller.store.stream.StartScaleResponse)1 StoreException (io.pravega.controller.store.stream.StoreException)1 HistoryRecord (io.pravega.controller.store.stream.tables.HistoryRecord)1 ScaleResponse (io.pravega.controller.stream.api.grpc.v1.Controller.ScaleResponse)1 TruncateStreamEvent (io.pravega.shared.controller.event.TruncateStreamEvent)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1