public IdentifiedDataSerializable createNew(Integer arg) { return new MapReplicationStateHolder(); } };
private void applyIndexesState() { if (mapIndexInfos != null) { for (MapIndexInfo mapIndexInfo : mapIndexInfos) { addIndexes(mapIndexInfo.getMapName(), mapIndexInfo.getIndexInfos()); } } }
@Override protected void readInternal(final ObjectDataInput in) throws IOException { mapReplicationStateHolder.readData(in); writeBehindStateHolder.readData(in); mapNearCacheStateHolder.readData(in); }
void applyState() { ThreadUtil.assertRunningOnPartitionThread(); applyIndexesState(); final SerializationService serializationService = mapContainer.getMapServiceContext().getNodeEngine() .getSerializationService(); final boolean indexesMustBePopulated = indexesMustBePopulated(indexes, operation); if (indexesMustBePopulated) {
@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); } } }
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); }
@Override public void run() { mapReplicationStateHolder.applyState(); writeBehindStateHolder.applyState(); if (getReplicaIndex() == 0) { mapNearCacheStateHolder.applyState(); } }
@Override protected void writeInternal(final ObjectDataOutput out) throws IOException { mapReplicationStateHolder.writeData(out); writeBehindStateHolder.writeData(out); mapNearCacheStateHolder.writeData(out); }
@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 readData(ObjectDataInput in) throws IOException { int size = in.readInt(); data = createHashMap(size); for (int i = 0; i < size; i++) { String name = in.readUTF(); int recordStoreSize = in.readInt(); Collection<RecordReplicationInfo> recordReplicationInfos = new ArrayList<RecordReplicationInfo>(recordStoreSize); for (int j = 0; j < recordStoreSize; j++) { RecordReplicationInfo recordReplicationInfo = in.readObject(); recordReplicationInfos.add(recordReplicationInfo); } data.put(name, recordReplicationInfos); } int loadedSize = in.readInt(); loaded = createHashMap(loadedSize); for (int i = 0; i < loadedSize; i++) { loaded.put(in.readUTF(), in.readBoolean()); } // RU_COMPAT_3_9 if (mustReadMapIndexInfos(in.getVersion())) { int mapIndexInfosSize = in.readInt(); mapIndexInfos = new ArrayList<MapIndexInfo>(mapIndexInfosSize); for (int i = 0; i < mapIndexInfosSize; i++) { MapIndexInfo mapIndexInfo = in.readObject(); mapIndexInfos.add(mapIndexInfo); } } }
ThreadUtil.assertRunningOnPartitionThread(); applyIndexesState(); final SerializationService serializationService = mapContainer.getMapServiceContext().getNodeEngine() .getSerializationService(); final boolean indexesMustBePopulated = indexesMustBePopulated(indexes, operation); if (indexesMustBePopulated) {
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); }
@Override public void run() { mapReplicationStateHolder.applyState(); writeBehindStateHolder.applyState(); if (getReplicaIndex() == 0) { mapNearCacheStateHolder.applyState(); } }
@Override protected void writeInternal(final ObjectDataOutput out) throws IOException { mapReplicationStateHolder.writeData(out); writeBehindStateHolder.writeData(out); mapNearCacheStateHolder.writeData(out); }
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); }
@Override protected void readInternal(final ObjectDataInput in) throws IOException { mapReplicationStateHolder.readData(in); writeBehindStateHolder.readData(in); mapNearCacheStateHolder.readData(in); }
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()); } }
public IdentifiedDataSerializable createNew(Integer arg) { return new MapReplicationStateHolder(); } };
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); }