Search in sources :

Example 71 with AttributeUpdate

use of io.pravega.segmentstore.contracts.AttributeUpdate in project pravega by pravega.

the class ContainerMetadataUpdateTransactionTests method verifyAttributeUpdates.

private void verifyAttributeUpdates(String stepName, ContainerMetadata containerMetadata, Collection<AttributeUpdate> attributeUpdates, Map<AttributeId, Long> expectedValues) {
    // Verify that the Attribute Updates have their expected values and that the updater has internalized the attribute updates.
    val transactionMetadata = containerMetadata.getStreamSegmentMetadata(SEGMENT_ID);
    val expectedTransactionAttributes = new HashMap<>(expectedValues);
    attributeUpdates.forEach(au -> expectedTransactionAttributes.put(au.getAttributeId(), au.getValue()));
    SegmentMetadataComparer.assertSameAttributes("Unexpected attributes in transaction metadata " + stepName + ".", expectedTransactionAttributes, transactionMetadata);
    for (AttributeUpdate au : attributeUpdates) {
        Assert.assertEquals("Unexpected updated value for [" + au + "] " + stepName, (long) expectedValues.get(au.getAttributeId()), au.getValue());
    }
}
Also used : lombok.val(lombok.val) AttributeUpdate(io.pravega.segmentstore.contracts.AttributeUpdate) DynamicAttributeUpdate(io.pravega.segmentstore.contracts.DynamicAttributeUpdate) HashMap(java.util.HashMap)

Aggregations

AttributeUpdate (io.pravega.segmentstore.contracts.AttributeUpdate)71 lombok.val (lombok.val)51 AttributeUpdateCollection (io.pravega.segmentstore.contracts.AttributeUpdateCollection)36 ArrayList (java.util.ArrayList)34 HashMap (java.util.HashMap)34 Test (org.junit.Test)32 AttributeId (io.pravega.segmentstore.contracts.AttributeId)31 AttributeUpdateType (io.pravega.segmentstore.contracts.AttributeUpdateType)31 CompletableFuture (java.util.concurrent.CompletableFuture)30 BadAttributeUpdateException (io.pravega.segmentstore.contracts.BadAttributeUpdateException)25 DynamicAttributeUpdate (io.pravega.segmentstore.contracts.DynamicAttributeUpdate)24 StreamSegmentNotExistsException (io.pravega.segmentstore.contracts.StreamSegmentNotExistsException)24 Collection (java.util.Collection)24 Collections (java.util.Collections)24 Map (java.util.Map)24 Attributes (io.pravega.segmentstore.contracts.Attributes)23 Duration (java.time.Duration)23 Exceptions (io.pravega.common.Exceptions)22 Collectors (java.util.stream.Collectors)22 Cleanup (lombok.Cleanup)22