use of com.hazelcast.replicatedmap.impl.ReplicatedMapService 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();
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.
the class SyncReplicatedMapDataOperation method run.
@Override
public void run() throws Exception {
ILogger logger = getLogger();
if (logger.isFineEnabled()) {
logger.fine("Syncing " + recordSet.size() + " records and version: " + version + " for map: " + name + " partitionId=" + getPartitionId() + " from: " + getCallerAddress() + " to: " + getNodeEngine().getThisAddress());
}
ReplicatedMapService service = getService();
AbstractReplicatedRecordStore store = (AbstractReplicatedRecordStore) service.getReplicatedRecordStore(name, true, getPartitionId());
InternalReplicatedMapStorage<K, V> newStorage = new InternalReplicatedMapStorage<K, V>();
for (RecordMigrationInfo record : recordSet) {
K key = (K) store.marshall(record.getKey());
V value = (V) store.marshall(record.getValue());
ReplicatedRecord<K, V> replicatedRecord = buildReplicatedRecord(key, value, record.getTtl());
ReplicatedRecord oldRecord = store.getReplicatedRecord(key);
if (oldRecord != null) {
replicatedRecord.setHits(oldRecord.getHits());
}
newStorage.put(key, replicatedRecord);
if (record.getTtl() > 0) {
store.scheduleTtlEntry(record.getTtl(), key, value);
}
}
newStorage.syncVersion(version);
AtomicReference<InternalReplicatedMapStorage<K, V>> storageRef = store.getStorageRef();
storageRef.set(newStorage);
store.setLoaded(true);
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.
the class ValuesOperation method run.
@Override
public void run() throws Exception {
ReplicatedMapService service = getService();
Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
Collection<ReplicatedRecord> values = new ArrayList<ReplicatedRecord>();
for (ReplicatedRecordStore store : stores) {
values.addAll(store.values(false));
}
Collection<Data> dataValues = new ArrayList<Data>(values.size());
SerializationService serializationService = getNodeEngine().getSerializationService();
for (ReplicatedRecord value : values) {
dataValues.add(serializationService.toData(value.getValue()));
}
response = new ReplicatedMapValueCollection(dataValues);
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.
the class CheckReplicaVersionOperation method run.
@Override
public void run() throws Exception {
ILogger logger = getLogger();
int partitionId = getPartitionId();
ReplicatedMapService service = getService();
PartitionContainer container = service.getPartitionContainer(getPartitionId());
ConcurrentMap<String, ReplicatedRecordStore> stores = container.getStores();
for (Map.Entry<String, Long> entry : versions.entrySet()) {
String name = entry.getKey();
Long version = entry.getValue();
ReplicatedRecordStore store = stores.get(name);
if (store == null) {
if (logger.isFineEnabled()) {
logger.fine("Missing store on the replica ! map: " + name + " owner version:" + version + " partitionId=" + partitionId);
}
requestDataFromOwner(name);
} else if (store.isStale(version)) {
if (logger.isFineEnabled()) {
logger.fine("Stale replica! map: " + name + " owner version: " + version + " replica version: " + store.getVersion() + " partitionId=" + partitionId);
}
requestDataFromOwner(name);
}
}
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.
the class ClearOperation method run.
@Override
public void run() throws Exception {
if (getNodeEngine().getConfig().isLiteMember()) {
return;
}
ReplicatedMapService service = getService();
ReplicatedRecordStore store = service.getReplicatedRecordStore(mapName, false, getPartitionId());
if (store == null) {
return;
}
response = store.size();
if (replicateClear) {
store.clear();
replicateClearOperation(version);
} else {
store.clearWithVersion(version);
}
}
Aggregations