use of io.pravega.segmentstore.server.logs.operations.StorageMetadataCheckpointOperation in project pravega by pravega.
the class DurableDataLogRepairCommand method createUserDefinedOperation.
/**
* Guides the user to generate a new {@link Operation} that will eventually modify the Original Log.
*
* @return New {@link Operation} to be added in the Original Log.
*/
@VisibleForTesting
Operation createUserDefinedOperation() {
Operation result;
final String operations = "[DeleteSegmentOperation|MergeSegmentOperation|MetadataCheckpointOperation|" + "StorageMetadataCheckpointOperation|StreamSegmentAppendOperation|StreamSegmentMapOperation|" + "StreamSegmentSealOperation|StreamSegmentTruncateOperation|UpdateAttributesOperation]";
switch(getStringUserInput("Type one of the following Operations to instantiate: " + operations)) {
case "DeleteSegmentOperation":
long segmentId = getLongUserInput("Input Segment Id for DeleteSegmentOperation:");
result = new DeleteSegmentOperation(segmentId);
long offset = getLongUserInput("Input Segment Offset for DeleteSegmentOperation:");
((DeleteSegmentOperation) result).setStreamSegmentOffset(offset);
break;
case "MergeSegmentOperation":
long targetSegmentId = getLongUserInput("Input Target Segment Id for MergeSegmentOperation:");
long sourceSegmentId = getLongUserInput("Input Source Segment Id for MergeSegmentOperation:");
result = new MergeSegmentOperation(targetSegmentId, sourceSegmentId, createAttributeUpdateCollection());
offset = getLongUserInput("Input Segment Offset for MergeSegmentOperation:");
((MergeSegmentOperation) result).setStreamSegmentOffset(offset);
break;
case "MetadataCheckpointOperation":
result = new MetadataCheckpointOperation();
((MetadataCheckpointOperation) result).setContents(createOperationContents());
break;
case "StorageMetadataCheckpointOperation":
result = new StorageMetadataCheckpointOperation();
((StorageMetadataCheckpointOperation) result).setContents(createOperationContents());
break;
case "StreamSegmentAppendOperation":
segmentId = getLongUserInput("Input Segment Id for StreamSegmentAppendOperation:");
offset = getLongUserInput("Input Segment Offset for StreamSegmentAppendOperation:");
result = new StreamSegmentAppendOperation(segmentId, offset, createOperationContents(), createAttributeUpdateCollection());
break;
case "StreamSegmentMapOperation":
result = new StreamSegmentMapOperation(createSegmentProperties());
break;
case "StreamSegmentSealOperation":
segmentId = getLongUserInput("Input Segment Id for StreamSegmentSealOperation:");
result = new StreamSegmentSealOperation(segmentId);
offset = getLongUserInput("Input Segment Offset for StreamSegmentSealOperation:");
((StreamSegmentSealOperation) result).setStreamSegmentOffset(offset);
break;
case "StreamSegmentTruncateOperation":
segmentId = getLongUserInput("Input Segment Id for StreamSegmentTruncateOperation:");
offset = getLongUserInput("Input Offset for StreamSegmentTruncateOperation:");
result = new StreamSegmentTruncateOperation(segmentId, offset);
break;
case "UpdateAttributesOperation":
segmentId = getLongUserInput("Input Segment Id for UpdateAttributesOperation:");
result = new UpdateAttributesOperation(segmentId, createAttributeUpdateCollection());
break;
default:
output("Invalid operation, please select one of " + operations);
throw new UnsupportedOperationException();
}
return result;
}
use of io.pravega.segmentstore.server.logs.operations.StorageMetadataCheckpointOperation in project pravega by pravega.
the class ContainerMetadataUpdateTransactionTests method testOperationConcurrentSerializationDeletion.
@Test
public void testOperationConcurrentSerializationDeletion() throws ContainerException, StreamSegmentException {
CompletableFuture<Void> deletion = new CompletableFuture<>();
InstrumentedContainerMetadata metadata = new InstrumentedContainerMetadata(CONTAINER_ID, 1000, deletion);
// Add some segments to the metadata.
populateMetadata(metadata);
metadata.getGetAllStreamSegmentIdsFuture().thenRun(() -> {
// Cannot call getStreamSegmentMetadata because it is instrumented and will block, so we must manually construct it.
UpdateableSegmentMetadata segment = new StreamSegmentMetadata(SEGMENT_NAME, SEGMENT_ID, 0);
// Ensures it is eligible for eviction.
segment.markDeleted();
metadata.cleanup(Set.of(segment), SEGMENT_LENGTH);
}).thenRun(() -> {
deletion.complete(null);
});
ContainerMetadataUpdateTransaction transaction = createUpdateTransaction(metadata);
StorageMetadataCheckpointOperation checkpoint = createStorageMetadataCheckpoint();
// If successful this operation should not throw a NullPointerException.
transaction.preProcessOperation(checkpoint);
}
Aggregations