Search in sources :

Example 1 with RecordMigrationInfo

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);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) AbstractReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.AbstractReplicatedRecordStore) RecordMigrationInfo(com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with RecordMigrationInfo

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();
}
Also used : Address(com.hazelcast.nio.Address) PartitionContainer(com.hazelcast.replicatedmap.impl.PartitionContainer) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ILogger(com.hazelcast.logging.ILogger) OperationService(com.hazelcast.spi.OperationService) RecordMigrationInfo(com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo)

Example 3 with RecordMigrationInfo

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);
}
Also used : ReplicatedMapEntryView(com.hazelcast.replicatedmap.impl.record.ReplicatedMapEntryView) RecordMigrationInfo(com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo) IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) ConstructorFunction(com.hazelcast.util.ConstructorFunction) ArrayDataSerializableFactory(com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory)

Example 4 with RecordMigrationInfo

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);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) RecordMigrationInfo(com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo) HashSet(java.util.HashSet)

Example 5 with RecordMigrationInfo

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());
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) RecordMigrationInfo(com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

RecordMigrationInfo (com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo)10 HashSet (java.util.HashSet)5 Set (java.util.Set)4 AbstractReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.AbstractReplicatedRecordStore)3 ReplicatedRecord (com.hazelcast.replicatedmap.impl.record.ReplicatedRecord)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ILogger (com.hazelcast.logging.ILogger)2 Data (com.hazelcast.nio.serialization.Data)2 ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)2 ReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)2 ArrayDataSerializableFactory (com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory)1 Address (com.hazelcast.nio.Address)1 IdentifiedDataSerializable (com.hazelcast.nio.serialization.IdentifiedDataSerializable)1 PartitionContainer (com.hazelcast.replicatedmap.impl.PartitionContainer)1 InternalReplicatedMapStorage (com.hazelcast.replicatedmap.impl.record.InternalReplicatedMapStorage)1 ReplicatedMapEntryView (com.hazelcast.replicatedmap.impl.record.ReplicatedMapEntryView)1 OperationService (com.hazelcast.spi.OperationService)1 SerializationService (com.hazelcast.spi.serialization.SerializationService)1 ConstructorFunction (com.hazelcast.util.ConstructorFunction)1