use of com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo in project hazelcast by hazelcast.
the class ReplicationOperation method fillRecordStoreWithRecords.
private void fillRecordStoreWithRecords(ReplicatedMapService service) {
for (Map.Entry<String, Set<RecordMigrationInfo>> dataEntry : data.entrySet()) {
Set<RecordMigrationInfo> recordSet = dataEntry.getValue();
String name = dataEntry.getKey();
AbstractReplicatedRecordStore store = (AbstractReplicatedRecordStore) service.getReplicatedRecordStore(name, true, getPartitionId());
long version = versions.get(name);
store.putRecords(recordSet, version);
store.setLoaded(true);
}
}
use of com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo in project hazelcast by hazelcast.
the class RequestMapDataOperation method run.
@Override
public void run() throws Exception {
ILogger logger = getLogger();
int partitionId = getPartitionId();
Address callerAddress = getCallerAddress();
if (logger.isFineEnabled()) {
logger.fine("Caller { " + callerAddress + " } requested copy of map: " + name + " partitionId=" + partitionId);
}
ReplicatedMapService service = getService();
PartitionContainer container = service.getPartitionContainer(partitionId);
ReplicatedRecordStore store = container.getOrCreateRecordStore(name);
store.setLoaded(true);
if (getNodeEngine().getThisAddress().equals(callerAddress)) {
return;
}
long version = store.getVersion();
Set<RecordMigrationInfo> recordSet = getRecordSet(store);
SyncReplicatedMapDataOperation op = new SyncReplicatedMapDataOperation(name, recordSet, version);
op.setPartitionId(partitionId);
op.setValidateTarget(false);
OperationService operationService = getNodeEngine().getOperationService();
operationService.createInvocationBuilder(SERVICE_NAME, op, callerAddress).setTryCount(INVOCATION_TRY_COUNT).invoke();
}
use of com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo in project hazelcast by hazelcast.
the class ReplicatedMapDataSerializerHook method createFactoryInternal.
private static DataSerializableFactory createFactoryInternal() {
ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
constructors[CLEAR] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new ClearOperation();
}
};
constructors[ENTRY_VIEW] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new ReplicatedMapEntryView();
}
};
constructors[REPLICATE_UPDATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new ReplicateUpdateOperation();
}
};
constructors[REPLICATE_UPDATE_TO_CALLER] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new ReplicateUpdateToCallerOperation();
}
};
constructors[PUT_ALL] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new PutAllOperation();
}
};
constructors[PUT] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new PutOperation();
}
};
constructors[REMOVE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new RemoveOperation();
}
};
constructors[SIZE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new SizeOperation();
}
};
constructors[MERGE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new MergeOperation();
}
};
constructors[VERSION_RESPONSE_PAIR] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new VersionResponsePair();
}
};
constructors[GET] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new GetOperation();
}
};
constructors[CHECK_REPLICA_VERSION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new CheckReplicaVersionOperation();
}
};
constructors[CONTAINS_KEY] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new ContainsKeyOperation();
}
};
constructors[CONTAINS_VALUE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new ContainsValueOperation();
}
};
constructors[ENTRY_SET] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new EntrySetOperation();
}
};
constructors[EVICTION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new EvictionOperation();
}
};
constructors[IS_EMPTY] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new IsEmptyOperation();
}
};
constructors[KEY_SET] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new KeySetOperation();
}
};
constructors[REPLICATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new ReplicationOperation();
}
};
constructors[REQUEST_MAP_DATA] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new RequestMapDataOperation();
}
};
constructors[SYNC_REPLICATED_DATA] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new SyncReplicatedMapDataOperation();
}
};
constructors[VALUES] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new ValuesOperation();
}
};
constructors[CLEAR_OP_FACTORY] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new ClearOperationFactory();
}
};
constructors[PUT_ALL_OP_FACTORY] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new PutAllOperationFactory();
}
};
constructors[RECORD_MIGRATION_INFO] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new RecordMigrationInfo();
}
};
constructors[HIGHER_HITS_MERGE_POLICY] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return HigherHitsMapMergePolicy.INSTANCE;
}
};
constructors[LATEST_UPDATE_MERGE_POLICY] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return LatestUpdateMapMergePolicy.INSTANCE;
}
};
constructors[PASS_THROUGH_MERGE_POLICY] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return PassThroughMergePolicy.INSTANCE;
}
};
constructors[PUT_IF_ABSENT_MERGE_POLICY] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return PutIfAbsentMapMergePolicy.INSTANCE;
}
};
return new ArrayDataSerializableFactory(constructors);
}
use of com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo in project hazelcast by hazelcast.
the class ReplicationOperation method readInternal.
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
int size = in.readInt();
data = new HashMap<String, Set<RecordMigrationInfo>>(size);
for (int i = 0; i < size; i++) {
String name = in.readUTF();
int mapSize = in.readInt();
Set<RecordMigrationInfo> recordSet = new HashSet<RecordMigrationInfo>(mapSize);
for (int j = 0; j < mapSize; j++) {
RecordMigrationInfo record = new RecordMigrationInfo();
record.readData(in);
recordSet.add(record);
}
data.put(name, recordSet);
}
int versionsSize = in.readInt();
versions = new HashMap<String, Long>(versionsSize);
for (int i = 0; i < versionsSize; i++) {
String name = in.readUTF();
long version = in.readLong();
versions.put(name, version);
}
}
use of com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo in project hazelcast by hazelcast.
the class ReplicationOperation method writeInternal.
@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
out.writeInt(data.size());
for (Map.Entry<String, Set<RecordMigrationInfo>> entry : data.entrySet()) {
out.writeUTF(entry.getKey());
Set<RecordMigrationInfo> recordSet = entry.getValue();
out.writeInt(recordSet.size());
for (RecordMigrationInfo record : recordSet) {
record.writeData(out);
}
}
out.writeInt(versions.size());
for (Map.Entry<String, Long> entry : versions.entrySet()) {
out.writeUTF(entry.getKey());
out.writeLong(entry.getValue());
}
}
Aggregations