use of io.pravega.segmentstore.server.UpdateableSegmentMetadata in project pravega by pravega.
the class StorageWriterTests method appendDataBreadthFirst.
/**
* Appends data, round-robin style, one append per segment (for each segment), then back to the beginning.
*/
private void appendDataBreadthFirst(Collection<Long> segmentIds, HashMap<Long, ByteArrayOutputStream> segmentContents, TestContext context) {
int writeId = 0;
for (int i = 0; i < APPENDS_PER_SEGMENT; i++) {
for (long segmentId : segmentIds) {
UpdateableSegmentMetadata segmentMetadata = context.metadata.getStreamSegmentMetadata(segmentId);
appendData(segmentMetadata, i, writeId, segmentContents, context);
writeId++;
}
}
}
use of io.pravega.segmentstore.server.UpdateableSegmentMetadata in project pravega by pravega.
the class StorageWriterTests method initializeSegment.
private void initializeSegment(long segmentId, TestContext context) {
UpdateableSegmentMetadata metadata = context.metadata.getStreamSegmentMetadata(segmentId);
metadata.setLength(0);
metadata.setStorageLength(0);
context.storage.create(metadata.getName(), TIMEOUT).join();
}
use of io.pravega.segmentstore.server.UpdateableSegmentMetadata in project pravega by pravega.
the class StorageWriterTests method sealSegments.
private void sealSegments(Collection<Long> segmentIds, TestContext context) {
for (long segmentId : segmentIds) {
UpdateableSegmentMetadata segmentMetadata = context.metadata.getStreamSegmentMetadata(segmentId);
segmentMetadata.markSealed();
StreamSegmentSealOperation sealOp = new StreamSegmentSealOperation(segmentId);
sealOp.setStreamSegmentOffset(segmentMetadata.getLength());
context.dataSource.add(sealOp);
}
}
use of io.pravega.segmentstore.server.UpdateableSegmentMetadata in project pravega by pravega.
the class ContainerMetadataUpdateTransaction method copySegmentMetadata.
private void copySegmentMetadata(Collection<UpdateableSegmentMetadata> newSegments, Predicate<SegmentMetadata> filter, UpdateableContainerMetadata target) {
for (SegmentMetadata newMetadata : newSegments) {
if (!filter.test(newMetadata)) {
continue;
}
UpdateableSegmentMetadata existingMetadata;
if (newMetadata.isTransaction()) {
existingMetadata = target.mapStreamSegmentId(newMetadata.getName(), newMetadata.getId(), newMetadata.getParentId());
} else {
existingMetadata = target.mapStreamSegmentId(newMetadata.getName(), newMetadata.getId());
}
// Update real metadata with all the information from the new metadata.
existingMetadata.copyFrom(newMetadata);
}
}
use of io.pravega.segmentstore.server.UpdateableSegmentMetadata in project pravega by pravega.
the class ContainerMetadataUpdateTransaction method acceptMetadataOperation.
private void acceptMetadataOperation(StreamSegmentMapOperation operation) throws MetadataUpdateException {
if (operation.getStreamSegmentId() == ContainerMetadata.NO_STREAM_SEGMENT_ID) {
throw new MetadataUpdateException(this.containerId, "StreamSegmentMapOperation does not have a SegmentId assigned: " + operation);
}
// Create or reuse an existing Segment Metadata.
UpdateableSegmentMetadata segmentMetadata = getOrCreateSegmentUpdateTransaction(operation.getStreamSegmentName(), operation.getStreamSegmentId(), operation.getParentStreamSegmentId());
updateMetadata(operation, segmentMetadata);
}
Aggregations