use of com.hazelcast.replicatedmap.impl.ReplicatedMapService 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.ReplicatedMapService in project hazelcast by hazelcast.
the class SizeOperation method run.
@Override
public void run() throws Exception {
ReplicatedMapService service = getService();
Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
int size = 0;
for (ReplicatedRecordStore store : stores) {
size += store.size();
}
response = size;
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.
the class MergeOperation method run.
@Override
public void run() throws Exception {
ReplicatedMapService service = getService();
ReplicatedRecordStore store = service.getReplicatedRecordStore(name, true, key);
store.merge(key, entryView, policy);
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.
the class PutAllOperation method run.
@Override
public void run() throws Exception {
ReplicatedMapService service = getService();
ReplicatedRecordStore store = service.getReplicatedRecordStore(name, true, getPartitionId());
int partitionId = getPartitionId();
IPartitionService partitionService = getNodeEngine().getPartitionService();
ReplicatedMapEventPublishingService eventPublishingService = service.getEventPublishingService();
for (int i = 0; i < entries.size(); i++) {
Data key = entries.getKey(i);
Data value = entries.getValue(i);
if (partitionId != partitionService.getPartitionId(key)) {
continue;
}
Object putResult = store.put(key, value);
Data oldValue = getNodeEngine().toData(putResult);
eventPublishingService.fireEntryListenerEvent(key, oldValue, value, name, getCallerAddress());
VersionResponsePair response = new VersionResponsePair(putResult, store.getVersion());
publishReplicationMessage(key, value, response);
}
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.
the class ReplicateUpdateToCallerOperation method publishEvent.
private void publishEvent() {
ReplicatedMapService service = getService();
ReplicatedMapEventPublishingService eventPublishingService = service.getEventPublishingService();
Address thisAddress = getNodeEngine().getThisAddress();
Data dataOldValue = getNodeEngine().toData(response.getResponse());
if (isRemove) {
eventPublishingService.fireEntryListenerEvent(dataKey, dataOldValue, null, name, thisAddress);
} else {
eventPublishingService.fireEntryListenerEvent(dataKey, dataOldValue, dataValue, name, thisAddress);
}
}
Aggregations