public IdentifiedDataSerializable createNew(Integer arg) { return new MapReplicationOperation(); } };
RecordStore getRecordStore(String mapName) { final boolean skipLoadingOnRecordStoreCreate = true; MapService mapService = getService(); MapServiceContext mapServiceContext = mapService.getMapServiceContext(); return mapServiceContext.getRecordStore(getPartitionId(), mapName, skipLoadingOnRecordStoreCreate); }
private static boolean indexesMustBePopulated(Indexes indexes, MapReplicationOperation operation) { if (!indexes.hasIndex()) { // no indexes to populate return false; } if (indexes.isGlobal()) { // global indexes are populated during migration finalization return false; } if (operation.getReplicaIndex() != 0) { // backup partitions have no indexes to populate return false; } return true; } }
private void addIndexes(String mapName, Collection<IndexInfo> indexInfos) { if (indexInfos == null) { return; } RecordStore recordStore = operation.getRecordStore(mapName); MapContainer mapContainer = recordStore.getMapContainer(); if (mapContainer.isGlobalIndexEnabled()) { // creating global indexes on partition thread in case they do not exist for (IndexInfo indexInfo : indexInfos) { Indexes indexes = mapContainer.getIndexes(); // optimisation not to synchronize each partition thread on the addOrGetIndex method if (indexes.getIndex(indexInfo.getAttributeName()) == null) { indexes.addOrGetIndex(indexInfo.getAttributeName(), indexInfo.isOrdered()); } } } else { Indexes indexes = mapContainer.getIndexes(operation.getPartitionId()); for (IndexInfo indexInfo : indexInfos) { indexes.addOrGetIndex(indexInfo.getAttributeName(), indexInfo.isOrdered()); } } }
public MapReplicationOperation(PartitionContainer container, Collection<ServiceNamespace> namespaces, int partitionId, int replicaIndex) { setPartitionId(partitionId).setReplicaIndex(replicaIndex); this.mapReplicationStateHolder.prepare(container, namespaces, replicaIndex); this.writeBehindStateHolder.prepare(container, namespaces, replicaIndex); this.mapNearCacheStateHolder.prepare(container, namespaces, replicaIndex); }
void applyState() { for (Map.Entry<String, List<DelayedEntry>> entry : delayedEntries.entrySet()) { String mapName = entry.getKey(); RecordStore recordStore = mapReplicationOperation.getRecordStore(mapName); WriteBehindStore mapDataStore = (WriteBehindStore) recordStore.getMapDataStore(); mapDataStore.reset(); mapDataStore.setFlushSequences(flushSequences.get(mapName)); Collection<DelayedEntry> replicatedEntries = entry.getValue(); for (DelayedEntry delayedEntry : replicatedEntries) { mapDataStore.add(delayedEntry); mapDataStore.setSequence(delayedEntry.getSequence()); } } }
@Override public void writeData(ObjectDataOutput out) throws IOException { out.writeInt(storesByMapName.size()); for (Map.Entry<String, RecordStore<Record>> entry : storesByMapName.entrySet()) { String mapName = entry.getKey(); RecordStore recordStore = entry.getValue(); SerializationService ss = getSerializationService(recordStore); out.writeUTF(mapName); out.writeInt(recordStore.size()); Iterator<Record> iterator = recordStore.iterator(); while (iterator.hasNext()) { Record record = iterator.next(); RecordReplicationInfo replicationInfo = operation.toReplicationInfo(record, ss); out.writeObject(replicationInfo); } } out.writeInt(loaded.size()); for (Map.Entry<String, Boolean> loadedEntry : loaded.entrySet()) { out.writeUTF(loadedEntry.getKey()); out.writeBoolean(loadedEntry.getValue()); } out.writeInt(mapIndexInfos.size()); for (MapIndexInfo mapIndexInfo : mapIndexInfos) { out.writeObject(mapIndexInfo); } }
@Override public void writeData(ObjectDataOutput out) throws IOException { MapService mapService = mapReplicationOperation.getService(); MapServiceContext mapServiceContext = mapService.getMapServiceContext(); out.writeInt(delayedEntries.size()); for (Map.Entry<String, List<DelayedEntry>> entry : delayedEntries.entrySet()) { out.writeUTF(entry.getKey()); List<DelayedEntry> delayedEntryList = entry.getValue(); out.writeInt(delayedEntryList.size()); for (DelayedEntry e : delayedEntryList) { Data key = mapServiceContext.toData(e.getKey()); Data value = mapServiceContext.toData(e.getValue()); out.writeData(key); out.writeData(value); out.writeLong(e.getStoreTime()); out.writeInt(e.getPartitionId()); out.writeLong(e.getSequence()); } } out.writeInt(flushSequences.size()); for (Map.Entry<String, Queue<WriteBehindStore.Sequence>> entry : flushSequences.entrySet()) { out.writeUTF(entry.getKey()); Queue<WriteBehindStore.Sequence> queue = entry.getValue(); out.writeInt(queue.size()); for (WriteBehindStore.Sequence sequence : queue) { out.writeLong(sequence.getSequence()); out.writeBoolean(sequence.isFullFlush()); } } }
private boolean mustWriteIndexInfos(Version clusterVersion) { // 3.10 OS always writes mapIndexInfos // 3.10 EE on cluster version 3.10 must write index info if (!getBuildInfo().isEnterprise() || clusterVersion.isGreaterOrEqual(V3_10)) { return true; } ClusterService clusterService = operation.getNodeEngine().getClusterService(); Member targetMember = clusterService.getMember(target); // When cluster version is 3.9, only write mapIndexInfo if target member is 3.9 EE. Reasoning: // 3.9 EE expects to read mapIndexInfos when object data input comes with 3.9+ version. This is // the case when the object stream originates from a versioned 3.10 member. return targetMember.getVersion().asVersion().isEqualTo(V3_9) && clusterVersion.isEqualTo(V3_9); }
private void addIndexes(String mapName, Collection<IndexInfo> indexInfos) { if (indexInfos == null) { return; } RecordStore recordStore = operation.getRecordStore(mapName); MapContainer mapContainer = recordStore.getMapContainer(); if (mapContainer.isGlobalIndexEnabled()) { // creating global indexes on partition thread in case they do not exist for (IndexInfo indexInfo : indexInfos) { Indexes indexes = mapContainer.getIndexes(); // optimisation not to synchronize each partition thread on the addOrGetIndex method if (indexes.getIndex(indexInfo.getName()) == null) { indexes.addOrGetIndex(indexInfo.getName(), indexInfo.isOrdered()); } } } else { Indexes indexes = mapContainer.getIndexes(operation.getPartitionId()); for (IndexInfo indexInfo : indexInfos) { indexes.addOrGetIndex(indexInfo.getName(), indexInfo.isOrdered()); } } }
public MapReplicationOperation(PartitionContainer container, Collection<ServiceNamespace> namespaces, int partitionId, int replicaIndex) { setPartitionId(partitionId).setReplicaIndex(replicaIndex); this.mapReplicationStateHolder.prepare(container, namespaces, replicaIndex); this.writeBehindStateHolder.prepare(container, namespaces, replicaIndex); this.mapNearCacheStateHolder.prepare(container, namespaces, replicaIndex); }
void applyState() { for (Map.Entry<String, List<DelayedEntry>> entry : delayedEntries.entrySet()) { String mapName = entry.getKey(); RecordStore recordStore = mapReplicationOperation.getRecordStore(mapName); WriteBehindStore mapDataStore = (WriteBehindStore) recordStore.getMapDataStore(); mapDataStore.reset(); mapDataStore.setFlushSequences(flushSequences.get(mapName)); Collection<DelayedEntry> replicatedEntries = entry.getValue(); for (DelayedEntry delayedEntry : replicatedEntries) { mapDataStore.add(delayedEntry); mapDataStore.setSequence(delayedEntry.getSequence()); } } }
@Override public void writeData(ObjectDataOutput out) throws IOException { out.writeInt(storesByMapName.size()); for (Map.Entry<String, RecordStore<Record>> entry : storesByMapName.entrySet()) { String mapName = entry.getKey(); RecordStore recordStore = entry.getValue(); SerializationService ss = getSerializationService(recordStore); out.writeUTF(mapName); out.writeInt(recordStore.size()); Iterator<Record> iterator = recordStore.iterator(); while (iterator.hasNext()) { Record record = iterator.next(); RecordReplicationInfo replicationInfo = operation.toReplicationInfo(record, ss); out.writeObject(replicationInfo); } } out.writeInt(loaded.size()); for (Map.Entry<String, Boolean> loadedEntry : loaded.entrySet()) { out.writeUTF(loadedEntry.getKey()); out.writeBoolean(loadedEntry.getValue()); } // RU_COMPAT_3_9 if (mustWriteIndexInfos(out.getVersion())) { out.writeInt(mapIndexInfos.size()); for (MapIndexInfo mapIndexInfo : mapIndexInfos) { out.writeObject(mapIndexInfo); } } }
@Override public void writeData(ObjectDataOutput out) throws IOException { MapService mapService = mapReplicationOperation.getService(); MapServiceContext mapServiceContext = mapService.getMapServiceContext(); out.writeInt(delayedEntries.size()); for (Map.Entry<String, List<DelayedEntry>> entry : delayedEntries.entrySet()) { out.writeUTF(entry.getKey()); List<DelayedEntry> delayedEntryList = entry.getValue(); out.writeInt(delayedEntryList.size()); for (DelayedEntry e : delayedEntryList) { Data key = mapServiceContext.toData(e.getKey()); Data value = mapServiceContext.toData(e.getValue()); out.writeData(key); out.writeData(value); out.writeLong(e.getStoreTime()); out.writeInt(e.getPartitionId()); out.writeLong(e.getSequence()); } } out.writeInt(flushSequences.size()); for (Map.Entry<String, Queue<WriteBehindStore.Sequence>> entry : flushSequences.entrySet()) { out.writeUTF(entry.getKey()); Queue<WriteBehindStore.Sequence> queue = entry.getValue(); out.writeInt(queue.size()); for (WriteBehindStore.Sequence sequence : queue) { out.writeLong(sequence.getSequence()); out.writeBoolean(sequence.isFullFlush()); } } }
RecordStore getRecordStore(String mapName) { final boolean skipLoadingOnRecordStoreCreate = true; MapService mapService = getService(); MapServiceContext mapServiceContext = mapService.getMapServiceContext(); return mapServiceContext.getRecordStore(getPartitionId(), mapName, skipLoadingOnRecordStoreCreate); }
Collection<RecordReplicationInfo> recordReplicationInfos = dataEntry.getValue(); final String mapName = dataEntry.getKey(); RecordStore recordStore = operation.getRecordStore(mapName); recordStore.reset(); recordStore.setPreMigrationLoadedStatus(loaded.get(mapName)); .getPartitionContainer(operation.getPartitionId()); for (Map.Entry<String, Boolean> indexDefinition : mapContainer.getIndexDefinitions().entrySet()) { Indexes indexes = mapContainer.getIndexes(partitionContainer.getPartitionId());
public IdentifiedDataSerializable createNew(Integer arg) { return new MapReplicationOperation(); } };
public MapReplicationOperation(PartitionContainer container, int partitionId, int replicaIndex) { setPartitionId(partitionId).setReplicaIndex(replicaIndex); Collection<ServiceNamespace> namespaces = container.getAllNamespaces(replicaIndex); this.mapReplicationStateHolder.prepare(container, namespaces, replicaIndex); this.writeBehindStateHolder.prepare(container, namespaces, replicaIndex); this.mapNearCacheStateHolder.prepare(container, namespaces, replicaIndex); }
private static boolean indexesMustBePopulated(Indexes indexes, MapReplicationOperation operation) { if (!indexes.haveAtLeastOneIndex()) { // no indexes to populate return false; } if (indexes.isGlobal()) { // global indexes are populated during migration finalization return false; } if (operation.getReplicaIndex() != 0) { // backup partitions have no indexes to populate return false; } return true; } }
private void applyIndexesState() { if (mapIndexInfos != null) { for (MapIndexInfo mapIndexInfo : mapIndexInfos) { addIndexes(mapIndexInfo.getMapName(), mapIndexInfo.getIndexInfos()); } } // RU_COMPAT_3_9 // Old nodes (3.9-) won't send mapIndexInfos to new nodes (3.9+) in the map-replication operation. // This is the reason why we pick up the mapContainer.getIndexesToAdd() that were added by the PostJoinMapOperation // and we add them to the map, before we add data for (String mapName : data.keySet()) { RecordStore recordStore = operation.getRecordStore(mapName); MapContainer mapContainer = recordStore.getMapContainer(); addIndexes(mapName, mapContainer.getPartitionIndexesToAdd()); } }