@Override public void run() throws Exception { final List<Data> keyValueSequence = this.keyValueSequence; if (keyValueSequence == null || keyValueSequence.isEmpty()) { return; } final int partitionId = getPartitionId(); final MapService mapService = this.mapService; final RecordStore recordStore = mapService.getRecordStore(partitionId, name); for (int i = 0; i < keyValueSequence.size(); i += 2) { final Data key = keyValueSequence.get(i); final Data value = keyValueSequence.get(i + 1); final Object object = mapService.toObject(value); recordStore.putFromLoad(key, object); } }
public void run() { backupRecordInfos = new ArrayList<RecordInfo>(); backupEntrySet = new ArrayList<Map.Entry<Data, Data>>(); int partitionId = getPartitionId(); final MapServiceContext mapServiceContext = mapService.getMapServiceContext(); RecordStore recordStore = mapServiceContext.getRecordStore(partitionId, name); Set<Map.Entry<Data, Data>> entries = entrySet.getEntrySet(); InternalPartitionService partitionService = getNodeEngine().getPartitionService(); Set<Data> keysToInvalidate = new HashSet<Data>(); for (Map.Entry<Data, Data> entry : entries) { Data dataKey = entry.getKey(); Data dataValue = entry.getValue(); if (partitionId == partitionService.getPartitionId(dataKey)) { Data dataOldValue = null; if (initialLoad) { recordStore.putFromLoad(dataKey, dataValue, -1); } else { dataOldValue = mapServiceContext.toData(recordStore.put(dataKey, dataValue, -1)); } mapServiceContext.interceptAfterPut(name, dataValue); EntryEventType eventType = dataOldValue == null ? EntryEventType.ADDED : EntryEventType.UPDATED; final MapEventPublisher mapEventPublisher = mapServiceContext.getMapEventPublisher(); mapEventPublisher.publishEvent( getCallerAddress(), name, eventType, dataKey, dataOldValue, dataValue); keysToInvalidate.add(dataKey); if (mapContainer.getWanReplicationPublisher() != null && mapContainer.getWanMergePolicy() != null) { Record record = recordStore.getRecord(dataKey); final Data dataValueAsData = mapServiceContext.toData(dataValue); final EntryView entryView = EntryViews.createSimpleEntryView(dataKey, dataValueAsData, record); mapEventPublisher.publishWanReplicationUpdate(name, entryView); } backupEntrySet.add(entry); RecordInfo replicationInfo = Records.buildRecordInfo(recordStore.getRecord(dataKey)); backupRecordInfos.add(replicationInfo); } } invalidateNearCaches(keysToInvalidate); }