Search in sources :

Example 1 with OperationPriority

use of io.pravega.segmentstore.server.logs.operations.OperationPriority in project pravega by pravega.

the class PriorityCalculatorTests method testGetPriority.

/**
 * Tests the {@link PriorityCalculator#getPriority} method.
 */
@Test
public void testGetPriority() {
    for (val st : SEGMENT_TYPES) {
        for (val ot : OPERATION_TYPES) {
            OperationPriority expected;
            if (st.isSystem()) {
                expected = st.isCritical() ? OperationPriority.SystemCritical : (ot == OperationType.Deletion ? OperationPriority.Critical : OperationPriority.High);
            } else {
                expected = st.isCritical() || (ot == OperationType.Deletion) ? OperationPriority.Critical : OperationPriority.Normal;
            }
            OperationPriority actual = PriorityCalculator.getPriority(st, ot);
            Assert.assertEquals("Unexpected priority for SegmentType = " + st + ", OperationType = " + ot, expected, actual);
        }
    }
}
Also used : lombok.val(lombok.val) OperationPriority(io.pravega.segmentstore.server.logs.operations.OperationPriority) Test(org.junit.Test)

Example 2 with OperationPriority

use of io.pravega.segmentstore.server.logs.operations.OperationPriority in project pravega by pravega.

the class StreamSegmentContainer method mapSegmentId.

private CompletableFuture<Long> mapSegmentId(long segmentId, SegmentProperties segmentProperties, boolean pin, Duration timeout) {
    StreamSegmentMapOperation op = new StreamSegmentMapOperation(segmentProperties);
    if (segmentId != ContainerMetadata.NO_STREAM_SEGMENT_ID) {
        op.setStreamSegmentId(segmentId);
    }
    if (pin) {
        op.markPinned();
    }
    OperationPriority priority = calculatePriority(SegmentType.fromAttributes(segmentProperties.getAttributes()), op);
    return this.durableLog.add(op, priority, timeout).thenApply(ignored -> op.getStreamSegmentId());
}
Also used : StreamSegmentMapOperation(io.pravega.segmentstore.server.logs.operations.StreamSegmentMapOperation) OperationPriority(io.pravega.segmentstore.server.logs.operations.OperationPriority)

Example 3 with OperationPriority

use of io.pravega.segmentstore.server.logs.operations.OperationPriority in project pravega by pravega.

the class StreamSegmentContainer method addOperation.

private <T extends Operation & SegmentOperation> CompletableFuture<Void> addOperation(T operation, Duration timeout) {
    SegmentMetadata sm = this.metadata.getStreamSegmentMetadata(operation.getStreamSegmentId());
    OperationPriority priority = calculatePriority(sm.getType(), operation);
    return this.durableLog.add(operation, priority, timeout);
}
Also used : UpdateableSegmentMetadata(io.pravega.segmentstore.server.UpdateableSegmentMetadata) SegmentMetadata(io.pravega.segmentstore.server.SegmentMetadata) OperationPriority(io.pravega.segmentstore.server.logs.operations.OperationPriority)

Aggregations

OperationPriority (io.pravega.segmentstore.server.logs.operations.OperationPriority)3 SegmentMetadata (io.pravega.segmentstore.server.SegmentMetadata)1 UpdateableSegmentMetadata (io.pravega.segmentstore.server.UpdateableSegmentMetadata)1 StreamSegmentMapOperation (io.pravega.segmentstore.server.logs.operations.StreamSegmentMapOperation)1 lombok.val (lombok.val)1 Test (org.junit.Test)1