Search in sources :

Example 1 with ReplicatedMapEventPublishingService

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));
    }
}
Also used : Data(com.hazelcast.internal.serialization.Data) ReplicatedMapEventPublishingService(com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)

Example 2 with ReplicatedMapEventPublishingService

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);
    }
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) IPartitionService(com.hazelcast.internal.partition.IPartitionService) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) Data(com.hazelcast.internal.serialization.Data) ReplicatedMapEventPublishingService(com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)

Example 3 with ReplicatedMapEventPublishingService

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());
}
Also used : ReplicatedMapEventPublishingService(com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)

Example 4 with ReplicatedMapEventPublishingService

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);
    }
}
Also used : Address(com.hazelcast.cluster.Address) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) Data(com.hazelcast.internal.serialization.Data) ReplicatedMapEventPublishingService(com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)

Example 5 with ReplicatedMapEventPublishingService

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;
}
Also used : ReplicatedQueryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter) ReplicatedEntryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedEntryEventFilter) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ReplicatedMapEventPublishingService(com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService) Predicate(com.hazelcast.query.Predicate)

Aggregations

ReplicatedMapEventPublishingService (com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)10 ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)7 Data (com.hazelcast.internal.serialization.Data)4 Predicate (com.hazelcast.query.Predicate)2 ReplicatedEntryEventFilter (com.hazelcast.replicatedmap.impl.record.ReplicatedEntryEventFilter)2 ReplicatedQueryEventFilter (com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter)2 Address (com.hazelcast.cluster.Address)1 IPartitionService (com.hazelcast.internal.partition.IPartitionService)1 ReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)1