Search in sources :

Example 6 with ContainerMetadata

use of io.pravega.segmentstore.server.ContainerMetadata in project pravega by pravega.

the class OperationMetadataUpdaterTests method clone.

private UpdateableContainerMetadata clone(ContainerMetadata base) {
    val metadata = createBlankMetadata();
    // First clone stand-alone (parent) Segments (since there may be Transactions mapped to them).
    base.getAllStreamSegmentIds().stream().map(base::getStreamSegmentMetadata).filter(sm -> !sm.isTransaction()).forEach(bsm -> metadata.mapStreamSegmentId(bsm.getName(), bsm.getId()).copyFrom(bsm));
    // Then clone transactions.
    base.getAllStreamSegmentIds().stream().map(base::getStreamSegmentMetadata).filter(SegmentMetadata::isTransaction).forEach(bsm -> metadata.mapStreamSegmentId(bsm.getName(), bsm.getId(), bsm.getParentId()).copyFrom(bsm));
    return metadata;
}
Also used : lombok.val(lombok.val) Arrays(java.util.Arrays) StreamSegmentInformation(io.pravega.segmentstore.contracts.StreamSegmentInformation) ContainerMetadata(io.pravega.segmentstore.server.ContainerMetadata) HashMap(java.util.HashMap) LogAddress(io.pravega.segmentstore.storage.LogAddress) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) UpdateableContainerMetadata(io.pravega.segmentstore.server.UpdateableContainerMetadata) AttributeUpdate(io.pravega.segmentstore.contracts.AttributeUpdate) SegmentMetadata(io.pravega.segmentstore.server.SegmentMetadata) Map(java.util.Map) Timeout(org.junit.rules.Timeout) Operation(io.pravega.segmentstore.server.logs.operations.Operation) StreamSegmentMapOperation(io.pravega.segmentstore.server.logs.operations.StreamSegmentMapOperation) Attributes(io.pravega.segmentstore.contracts.Attributes) Predicate(java.util.function.Predicate) lombok.val(lombok.val) Test(org.junit.Test) UUID(java.util.UUID) AtomicLong(java.util.concurrent.atomic.AtomicLong) AbstractMap(java.util.AbstractMap) Rule(org.junit.Rule) StreamSegmentContainerMetadata(io.pravega.segmentstore.server.containers.StreamSegmentContainerMetadata) StreamSegmentAppendOperation(io.pravega.segmentstore.server.logs.operations.StreamSegmentAppendOperation) AttributeUpdateType(io.pravega.segmentstore.contracts.AttributeUpdateType) Assert(org.junit.Assert) MergeTransactionOperation(io.pravega.segmentstore.server.logs.operations.MergeTransactionOperation) StreamSegmentSealOperation(io.pravega.segmentstore.server.logs.operations.StreamSegmentSealOperation)

Aggregations

ContainerMetadata (io.pravega.segmentstore.server.ContainerMetadata)6 UpdateableContainerMetadata (io.pravega.segmentstore.server.UpdateableContainerMetadata)6 AbstractMap (java.util.AbstractMap)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 lombok.val (lombok.val)5 AttributeUpdate (io.pravega.segmentstore.contracts.AttributeUpdate)4 AttributeUpdateType (io.pravega.segmentstore.contracts.AttributeUpdateType)4 SegmentMetadata (io.pravega.segmentstore.server.SegmentMetadata)4 MergeTransactionOperation (io.pravega.segmentstore.server.logs.operations.MergeTransactionOperation)4 Operation (io.pravega.segmentstore.server.logs.operations.Operation)4 StreamSegmentAppendOperation (io.pravega.segmentstore.server.logs.operations.StreamSegmentAppendOperation)4 StreamSegmentSealOperation (io.pravega.segmentstore.server.logs.operations.StreamSegmentSealOperation)4 UUID (java.util.UUID)4 Supplier (java.util.function.Supplier)4 Assert (org.junit.Assert)4 StreamSegmentContainerMetadata (io.pravega.segmentstore.server.containers.StreamSegmentContainerMetadata)3 Test (org.junit.Test)3