public void run() { SimpleEntryView entryView = (SimpleEntryView) mergingEntry; entryView.setKey(mapService.toObject(mergingEntry.getKey())); entryView.setValue(mapService.toObject(mergingEntry.getValue())); merged = recordStore.merge(dataKey, mergingEntry, mergePolicy); if (merged) { Record record = recordStore.getRecord(dataKey); if (record != null) dataValue = mapService.toData(record.getValue()); } }
@Override public void onReplicationEvent(WanReplicationEvent replicationEvent) { Object eventObject = replicationEvent.getEventObject(); if (eventObject instanceof MapReplicationUpdate) { MapReplicationUpdate replicationUpdate = (MapReplicationUpdate) eventObject; EntryView entryView = replicationUpdate.getEntryView(); MapMergePolicy mergePolicy = replicationUpdate.getMergePolicy(); String mapName = replicationUpdate.getMapName(); MapContainer mapContainer = getMapContainer(mapName); MergeOperation operation = new MergeOperation( mapName, toData(entryView.getKey(), mapContainer.getPartitioningStrategy()), entryView, mergePolicy); 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); } } else if (eventObject instanceof MapReplicationRemove) { MapReplicationRemove replicationRemove = (MapReplicationRemove) eventObject; WanOriginatedDeleteOperation operation = new WanOriginatedDeleteOperation( replicationRemove.getMapName(), replicationRemove.getKey()); try { int partitionId = nodeEngine.getPartitionService().getPartitionId(replicationRemove.getKey()); Future f = nodeEngine .getOperationService() .invokeOnPartition(SERVICE_NAME, operation, partitionId); f.get(); } catch (Throwable t) { throw ExceptionUtil.rethrow(t); } } }