use of com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService in project hazelcast by hazelcast.
the class AbstractReplicatedRecordStore method evict.
@Override
@SuppressWarnings("unchecked")
public void evict(Object key) {
isNotNull(key, "key");
long startNanos = Timer.nanos();
V oldValue;
K marshalledKey = (K) marshall(key);
InternalReplicatedMapStorage<K, V> storage = getStorage();
ReplicatedRecord<K, V> current = storage.get(marshalledKey);
if (current == null) {
oldValue = null;
} else {
oldValue = current.getValueInternal();
storage.remove(marshalledKey, current);
}
Data dataKey = nodeEngine.toData(key);
Data dataOldValue = nodeEngine.toData(oldValue);
ReplicatedMapEventPublishingService eventPublishingService = replicatedMapService.getEventPublishingService();
eventPublishingService.fireEntryListenerEvent(dataKey, dataOldValue, null, EVICTED, name, nodeEngine.getThisAddress());
if (replicatedMapConfig.isStatisticsEnabled()) {
getStats().incrementRemovesNanos(Timer.nanosElapsed(startNanos));
}
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService 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.ReplicatedMapEventPublishingService in project hazelcast by hazelcast.
the class PutOperation method afterRun.
@Override
public void afterRun() throws Exception {
sendReplicationOperation(false);
ReplicatedMapEventPublishingService eventPublishingService = service.getEventPublishingService();
eventPublishingService.fireEntryListenerEvent(key, oldValue, value, name, getCallerAddress());
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService 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);
}
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService in project hazelcast by hazelcast.
the class AbstractReplicatedMapAddEntryListenerMessageTask method call.
@Override
protected Object call() {
ReplicatedMapService service = getService(ReplicatedMapService.SERVICE_NAME);
ReplicatedMapEventPublishingService eventPublishingService = service.getEventPublishingService();
String registrationId;
Predicate predicate = getPredicate();
if (predicate == null) {
registrationId = eventPublishingService.addEventListener(this, new ReplicatedEntryEventFilter(getKey()), getDistributedObjectName());
} else {
registrationId = eventPublishingService.addEventListener(this, new ReplicatedQueryEventFilter(getKey(), predicate), getDistributedObjectName());
}
endpoint.addListenerDestroyAction(ReplicatedMapService.SERVICE_NAME, getDistributedObjectName(), registrationId);
return registrationId;
}
Aggregations