Search in sources :

Example 31 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class RemoveOperation method run.

@Override
public void run() throws Exception {
    service = getService();
    ReplicatedRecordStore store = service.getReplicatedRecordStore(name, true, getPartitionId());
    Object removed = store.remove(key);
    oldValue = getNodeEngine().toData(removed);
    response = new VersionResponsePair(removed, store.getVersion());
    Address thisAddress = getNodeEngine().getThisAddress();
    if (!getCallerAddress().equals(thisAddress)) {
        sendUpdateCallerOperation(true);
    }
}
Also used : Address(com.hazelcast.cluster.Address) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)

Example 32 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class ReplicateUpdateToCallerOperation method run.

@Override
public void run() throws Exception {
    ILogger logger = getLogger();
    ReplicatedMapService service = getService();
    ReplicatedRecordStore store = service.getReplicatedRecordStore(name, true, getPartitionId());
    long currentVersion = store.getVersion();
    long updateVersion = response.getVersion();
    if (currentVersion >= updateVersion) {
        if (logger.isFineEnabled()) {
            logger.fine("Rejecting stale update received for replicated map '" + name + "' (partitionId " + getPartitionId() + ") (current version " + currentVersion + ") (update version " + updateVersion + ")");
        }
        return;
    }
    Object key = store.marshall(dataKey);
    Object value = store.marshall(dataValue);
    if (isRemove) {
        store.removeWithVersion(key, updateVersion);
    } else {
        store.putWithVersion(key, value, ttl, TimeUnit.MILLISECONDS, true, updateVersion);
    }
    publishEvent();
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ILogger(com.hazelcast.logging.ILogger)

Example 33 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class ContainsKeyOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    ReplicatedRecordStore store = service.getReplicatedRecordStore(name, false, getPartitionId());
    response = store != null && store.containsKey(key);
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService)

Example 34 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class EntrySetOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
    List<Map.Entry<Object, ReplicatedRecord>> entries = new ArrayList<>();
    for (ReplicatedRecordStore store : stores) {
        entries.addAll(store.entrySet(false));
    }
    ArrayList<Map.Entry<Data, Data>> dataEntries = new ArrayList<>(entries.size());
    SerializationService serializationService = getNodeEngine().getSerializationService();
    for (Map.Entry<Object, ReplicatedRecord> entry : entries) {
        Data key = serializationService.toData(entry.getKey());
        Data value = serializationService.toData(entry.getValue().getValue());
        dataEntries.add(new AbstractMap.SimpleImmutableEntry<>(key, value));
    }
    response = new MapEntries(dataEntries);
}
Also used : ReplicatedRecord(com.hazelcast.replicatedmap.impl.record.ReplicatedRecord) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ArrayList(java.util.ArrayList) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) AbstractMap(java.util.AbstractMap) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) MapEntries(com.hazelcast.map.impl.MapEntries) AbstractMap(java.util.AbstractMap) Map(java.util.Map)

Example 35 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class GetOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    ReplicatedRecordStore store = service.getReplicatedRecordStore(name, false, getPartitionId());
    if (store != null) {
        ReplicatedRecord record = store.getReplicatedRecord(key);
        if (record != null) {
            response = record.getValue();
        }
    }
}
Also used : ReplicatedRecord(com.hazelcast.replicatedmap.impl.record.ReplicatedRecord) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService)

Aggregations

ReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)38 ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)19 ReplicatedRecord (com.hazelcast.replicatedmap.impl.record.ReplicatedRecord)7 ArrayList (java.util.ArrayList)7 Data (com.hazelcast.internal.serialization.Data)5 ILogger (com.hazelcast.logging.ILogger)4 Nonnull (javax.annotation.Nonnull)4 Address (com.hazelcast.cluster.Address)3 SerializationService (com.hazelcast.internal.serialization.SerializationService)3 ReplicatedMapProxy (com.hazelcast.replicatedmap.impl.ReplicatedMapProxy)3 Map (java.util.Map)3 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)2 LocalReplicatedMapStatsImpl (com.hazelcast.internal.monitor.impl.LocalReplicatedMapStatsImpl)2 DataCollection (com.hazelcast.map.impl.DataCollection)2 PartitionContainer (com.hazelcast.replicatedmap.impl.PartitionContainer)2 AbstractBaseReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.AbstractBaseReplicatedRecordStore)2 AbstractReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.AbstractReplicatedRecordStore)2 RecordMigrationInfo (com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo)2 BitSet (java.util.BitSet)2 Member (com.hazelcast.cluster.Member)1