use of com.hazelcast.map.merge.MapMergePolicy in project hazelcast by hazelcast.
the class MapReplicationSupportingService method handleUpdate.
private void handleUpdate(MapReplicationUpdate replicationUpdate) {
EntryView entryView = replicationUpdate.getEntryView();
MapMergePolicy mergePolicy = replicationUpdate.getMergePolicy();
String mapName = replicationUpdate.getMapName();
MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
MapOperationProvider operationProvider = mapServiceContext.getMapOperationProvider(mapName);
Data dataKey = mapServiceContext.toData(entryView.getKey(), mapContainer.getPartitioningStrategy());
MapOperation operation = operationProvider.createMergeOperation(mapName, dataKey, entryView, mergePolicy, true);
try {
int partitionId = nodeEngine.getPartitionService().getPartitionId(entryView.getKey());
Future f = nodeEngine.getOperationService().invokeOnPartition(SERVICE_NAME, operation, partitionId);
f.get();
} catch (Throwable t) {
throw ExceptionUtil.rethrow(t);
}
}
use of com.hazelcast.map.merge.MapMergePolicy in project hazelcast by hazelcast.
the class MergePolicySerializationTest method testIssue2665.
@Test
public void testIssue2665() {
String name = randomString();
String serviceName = "hz:impl:mapService";
HazelcastInstance instance = createHazelcastInstance(getConfig());
IMap<String, MyObject> map = instance.getMap(name);
MyObject myObjectExisting = new MyObject();
map.put("key", myObjectExisting);
NodeEngineImpl nodeEngine = HazelcastTestSupport.getNode(instance).getNodeEngine();
MapService mapService = nodeEngine.getService(serviceName);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
int partitionId = nodeEngine.getPartitionService().getPartitionId("key");
Data dataKey = mapServiceContext.toData("key");
RecordStore recordStore = mapServiceContext.getRecordStore(partitionId, name);
MapMergePolicy mergePolicy = mapServiceContext.getMergePolicyProvider().getMergePolicy(PutIfAbsentMapMergePolicy.class.getName());
EntryView<String, MyObject> mergingEntryView = new SimpleEntryView<String, MyObject>("key", new MyObject());
recordStore.merge(dataKey, mergingEntryView, mergePolicy);
int deSerializedCount = MyObject.deserializedCount;
assertEquals(0, deSerializedCount);
}
Aggregations