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);
}
}
}
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());
}
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);
}
Aggregations