Search in sources :

Example 6 with SimpleEntryView

use of com.hazelcast.map.impl.SimpleEntryView in project hazelcast by hazelcast.

the class MapMergePolicyQuickTest method testPassThroughMapMergePolicy.

@Test
public void testPassThroughMapMergePolicy() {
    HazelcastInstance instance = createHazelcastInstance(getConfig());
    String name = randomString();
    IMap<String, String> map = instance.getMap(name);
    MapServiceContext mapServiceContext = getMapServiceContext(instance);
    Data dataKey = mapServiceContext.toData("key");
    RecordStore recordStore = mapServiceContext.getRecordStore(getPartitionId(instance, "key"), name);
    MapMergePolicy mergePolicy = mapServiceContext.getMergePolicyProvider().getMergePolicy(PassThroughMergePolicy.class.getName());
    SimpleEntryView<String, String> initialEntry = new SimpleEntryView<String, String>("key", "value1");
    recordStore.merge(dataKey, initialEntry, mergePolicy);
    SimpleEntryView<String, String> mergingEntry = new SimpleEntryView<String, String>("key", "value2");
    recordStore.merge(dataKey, mergingEntry, mergePolicy);
    assertEquals("value2", map.get("key"));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) PassThroughMergePolicy(com.hazelcast.map.merge.PassThroughMergePolicy) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) SimpleEntryView(com.hazelcast.map.impl.SimpleEntryView) Data(com.hazelcast.nio.serialization.Data) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) PutIfAbsentMapMergePolicy(com.hazelcast.map.merge.PutIfAbsentMapMergePolicy) MapMergePolicy(com.hazelcast.map.merge.MapMergePolicy) LatestUpdateMapMergePolicy(com.hazelcast.map.merge.LatestUpdateMapMergePolicy) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

SimpleEntryView (com.hazelcast.map.impl.SimpleEntryView)6 Data (com.hazelcast.nio.serialization.Data)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)4 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)4 MapMergePolicy (com.hazelcast.map.merge.MapMergePolicy)4 PutIfAbsentMapMergePolicy (com.hazelcast.map.merge.PutIfAbsentMapMergePolicy)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 LatestUpdateMapMergePolicy (com.hazelcast.map.merge.LatestUpdateMapMergePolicy)3 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 MapGetEntryViewCodec (com.hazelcast.client.impl.protocol.codec.MapGetEntryViewCodec)1 MapService (com.hazelcast.map.impl.MapService)1 PassThroughMergePolicy (com.hazelcast.map.merge.PassThroughMergePolicy)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1