Search in sources :

Example 1 with SealSegment

use of io.pravega.shared.protocol.netty.WireCommands.SealSegment in project pravega by pravega.

the class PravegaRequestProcessor method sealSegment.

@Override
public void sealSegment(SealSegment sealSegment) {
    String segment = sealSegment.getSegment();
    log.debug("Sealing segment {} ", sealSegment);
    if (!verifyToken(segment, sealSegment.getRequestId(), sealSegment.getDelegationToken(), READ_UPDATE, "Seal Segment")) {
        return;
    }
    segmentStore.sealStreamSegment(segment, TIMEOUT).thenAccept(size -> connection.send(new SegmentSealed(sealSegment.getRequestId(), segment))).whenComplete((r, e) -> {
        if (e != null) {
            handleException(sealSegment.getRequestId(), segment, "Seal segment", e);
        } else {
            DYNAMIC_LOGGER.freezeCounter(nameFromSegment(SEGMENT_WRITE_BYTES, segment));
            DYNAMIC_LOGGER.freezeCounter(nameFromSegment(SEGMENT_WRITE_EVENTS, segment));
            if (statsRecorder != null) {
                statsRecorder.sealSegment(sealSegment.getSegment());
            }
        }
    });
}
Also used : SCALE_POLICY_RATE(io.pravega.segmentstore.contracts.Attributes.SCALE_POLICY_RATE) Arrays(java.util.Arrays) READ(io.pravega.auth.AuthHandler.Permissions.READ) StreamSegmentNotExistsException(io.pravega.segmentstore.contracts.StreamSegmentNotExistsException) SEGMENT_CREATE_LATENCY(io.pravega.shared.MetricsNames.SEGMENT_CREATE_LATENCY) AuthHandler(io.pravega.auth.AuthHandler) SegmentIsTruncated(io.pravega.shared.protocol.netty.WireCommands.SegmentIsTruncated) CREATION_TIME(io.pravega.segmentstore.contracts.Attributes.CREATION_TIME) MetricsNames.nameFromSegment(io.pravega.shared.MetricsNames.nameFromSegment) GetStreamSegmentInfo(io.pravega.shared.protocol.netty.WireCommands.GetStreamSegmentInfo) ReadResultEntryContents(io.pravega.segmentstore.contracts.ReadResultEntryContents) Duration(java.time.Duration) Map(java.util.Map) SegmentCreated(io.pravega.shared.protocol.netty.WireCommands.SegmentCreated) StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) Attributes(io.pravega.segmentstore.contracts.Attributes) CancellationException(java.util.concurrent.CancellationException) ContainerNotFoundException(io.pravega.segmentstore.contracts.ContainerNotFoundException) Slf4j(lombok.extern.slf4j.Slf4j) CreateSegment(io.pravega.shared.protocol.netty.WireCommands.CreateSegment) SealSegment(io.pravega.shared.protocol.netty.WireCommands.SealSegment) SegmentSealed(io.pravega.shared.protocol.netty.WireCommands.SegmentSealed) EndOfStreamSegment(io.pravega.segmentstore.contracts.ReadResultEntryType.EndOfStreamSegment) SegmentAttribute(io.pravega.shared.protocol.netty.WireCommands.SegmentAttribute) SEGMENT_READ_LATENCY(io.pravega.shared.MetricsNames.SEGMENT_READ_LATENCY) Exceptions(io.pravega.common.Exceptions) BadAttributeUpdateException(io.pravega.segmentstore.contracts.BadAttributeUpdateException) GetSegmentAttribute(io.pravega.shared.protocol.netty.WireCommands.GetSegmentAttribute) ArrayList(java.util.ArrayList) READ_UPDATE(io.pravega.auth.AuthHandler.Permissions.READ_UPDATE) SegmentRead(io.pravega.shared.protocol.netty.WireCommands.SegmentRead) AccessLevel(lombok.AccessLevel) Future(io.pravega.segmentstore.contracts.ReadResultEntryType.Future) FailingRequestProcessor(io.pravega.shared.protocol.netty.FailingRequestProcessor) StreamHelpers(io.pravega.common.io.StreamHelpers) StreamSegmentTruncatedException(io.pravega.segmentstore.contracts.StreamSegmentTruncatedException) StatsLogger(io.pravega.shared.metrics.StatsLogger) OpStatsLogger(io.pravega.shared.metrics.OpStatsLogger) lombok.val(lombok.val) SEGMENT_WRITE_EVENTS(io.pravega.shared.MetricsNames.SEGMENT_WRITE_EVENTS) IOException(java.io.IOException) WireCommands(io.pravega.shared.protocol.netty.WireCommands) WrongHost(io.pravega.shared.protocol.netty.WireCommands.WrongHost) SegmentDeleted(io.pravega.shared.protocol.netty.WireCommands.SegmentDeleted) CreateTransaction(io.pravega.shared.protocol.netty.WireCommands.CreateTransaction) Truncated(io.pravega.segmentstore.contracts.ReadResultEntryType.Truncated) SegmentTruncated(io.pravega.shared.protocol.netty.WireCommands.SegmentTruncated) RequestProcessor(io.pravega.shared.protocol.netty.RequestProcessor) OperationUnsupported(io.pravega.shared.protocol.netty.WireCommands.OperationUnsupported) Preconditions(com.google.common.base.Preconditions) TransactionInfo(io.pravega.shared.protocol.netty.WireCommands.TransactionInfo) AbortTransaction(io.pravega.shared.protocol.netty.WireCommands.AbortTransaction) AuthenticationException(io.pravega.common.auth.AuthenticationException) Cache(io.pravega.segmentstore.contracts.ReadResultEntryType.Cache) SneakyThrows(lombok.SneakyThrows) ByteBuffer(java.nio.ByteBuffer) AttributeUpdate(io.pravega.segmentstore.contracts.AttributeUpdate) StreamSegmentSealedException(io.pravega.segmentstore.contracts.StreamSegmentSealedException) UpdateSegmentAttribute(io.pravega.shared.protocol.netty.WireCommands.UpdateSegmentAttribute) UpdateSegmentPolicy(io.pravega.shared.protocol.netty.WireCommands.UpdateSegmentPolicy) SegmentStatsRecorder(io.pravega.segmentstore.server.host.stat.SegmentStatsRecorder) CommitTransaction(io.pravega.shared.protocol.netty.WireCommands.CommitTransaction) Collection(java.util.Collection) UUID(java.util.UUID) Math.min(java.lang.Math.min) StreamSegmentNameUtils(io.pravega.shared.segment.StreamSegmentNameUtils) MetricsProvider(io.pravega.shared.metrics.MetricsProvider) List(java.util.List) StreamSegmentExistsException(io.pravega.segmentstore.contracts.StreamSegmentExistsException) PassingTokenVerifier(io.pravega.segmentstore.server.host.delegationtoken.PassingTokenVerifier) BadOffsetException(io.pravega.segmentstore.contracts.BadOffsetException) DelegationTokenVerifier(io.pravega.segmentstore.server.host.delegationtoken.DelegationTokenVerifier) Math.max(java.lang.Math.max) SegmentIsSealed(io.pravega.shared.protocol.netty.WireCommands.SegmentIsSealed) ReadResult(io.pravega.segmentstore.contracts.ReadResult) TransactionAborted(io.pravega.shared.protocol.netty.WireCommands.TransactionAborted) DeleteSegment(io.pravega.shared.protocol.netty.WireCommands.DeleteSegment) SegmentPolicyUpdated(io.pravega.shared.protocol.netty.WireCommands.SegmentPolicyUpdated) Getter(lombok.Getter) NoSuchSegment(io.pravega.shared.protocol.netty.WireCommands.NoSuchSegment) CompletableFuture(java.util.concurrent.CompletableFuture) GetTransactionInfo(io.pravega.shared.protocol.netty.WireCommands.GetTransactionInfo) DynamicLogger(io.pravega.shared.metrics.DynamicLogger) SEGMENT_WRITE_BYTES(io.pravega.shared.MetricsNames.SEGMENT_WRITE_BYTES) ReadResultEntry(io.pravega.segmentstore.contracts.ReadResultEntry) SEGMENT_READ_BYTES(io.pravega.shared.MetricsNames.SEGMENT_READ_BYTES) SCALE_POLICY_TYPE(io.pravega.segmentstore.contracts.Attributes.SCALE_POLICY_TYPE) TransactionCommitted(io.pravega.shared.protocol.netty.WireCommands.TransactionCommitted) TYPE_PLUS_LENGTH_SIZE(io.pravega.shared.protocol.netty.WireCommands.TYPE_PLUS_LENGTH_SIZE) StreamSegmentInfo(io.pravega.shared.protocol.netty.WireCommands.StreamSegmentInfo) TransactionCreated(io.pravega.shared.protocol.netty.WireCommands.TransactionCreated) TruncateSegment(io.pravega.shared.protocol.netty.WireCommands.TruncateSegment) ReadSegment(io.pravega.shared.protocol.netty.WireCommands.ReadSegment) SegmentAlreadyExists(io.pravega.shared.protocol.netty.WireCommands.SegmentAlreadyExists) LoggerHelpers(io.pravega.common.LoggerHelpers) StreamSegmentMergedException(io.pravega.segmentstore.contracts.StreamSegmentMergedException) Timer(io.pravega.common.Timer) SegmentAttributeUpdated(io.pravega.shared.protocol.netty.WireCommands.SegmentAttributeUpdated) VisibleForTesting(com.google.common.annotations.VisibleForTesting) AttributeUpdateType(io.pravega.segmentstore.contracts.AttributeUpdateType) Collections(java.util.Collections) SegmentSealed(io.pravega.shared.protocol.netty.WireCommands.SegmentSealed)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 AuthHandler (io.pravega.auth.AuthHandler)1 READ (io.pravega.auth.AuthHandler.Permissions.READ)1 READ_UPDATE (io.pravega.auth.AuthHandler.Permissions.READ_UPDATE)1 Exceptions (io.pravega.common.Exceptions)1 LoggerHelpers (io.pravega.common.LoggerHelpers)1 Timer (io.pravega.common.Timer)1 AuthenticationException (io.pravega.common.auth.AuthenticationException)1 StreamHelpers (io.pravega.common.io.StreamHelpers)1 AttributeUpdate (io.pravega.segmentstore.contracts.AttributeUpdate)1 AttributeUpdateType (io.pravega.segmentstore.contracts.AttributeUpdateType)1 Attributes (io.pravega.segmentstore.contracts.Attributes)1 CREATION_TIME (io.pravega.segmentstore.contracts.Attributes.CREATION_TIME)1 SCALE_POLICY_RATE (io.pravega.segmentstore.contracts.Attributes.SCALE_POLICY_RATE)1 SCALE_POLICY_TYPE (io.pravega.segmentstore.contracts.Attributes.SCALE_POLICY_TYPE)1 BadAttributeUpdateException (io.pravega.segmentstore.contracts.BadAttributeUpdateException)1 BadOffsetException (io.pravega.segmentstore.contracts.BadOffsetException)1 ContainerNotFoundException (io.pravega.segmentstore.contracts.ContainerNotFoundException)1 ReadResult (io.pravega.segmentstore.contracts.ReadResult)1