Search in sources :

Example 1 with MapEventPublisher

use of com.hazelcast.map.impl.event.MapEventPublisher in project hazelcast by hazelcast.

the class MapEvictAllMessageTask method reduce.

@Override
protected Object reduce(Map<Integer, Object> map) {
    MapService mapService = getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    int evictedTotal = 0;
    for (Object result : map.values()) {
        Integer size = (Integer) mapServiceContext.toObject(result);
        evictedTotal += size;
    }
    if (evictedTotal > 0) {
        Address thisAddress = mapServiceContext.getNodeEngine().getThisAddress();
        MapEventPublisher mapEventPublisher = mapServiceContext.getMapEventPublisher();
        mapEventPublisher.publishMapEvent(thisAddress, parameters.name, EVICT_ALL, evictedTotal);
    }
    return null;
}
Also used : Address(com.hazelcast.nio.Address) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapEventPublisher(com.hazelcast.map.impl.event.MapEventPublisher)

Example 2 with MapEventPublisher

use of com.hazelcast.map.impl.event.MapEventPublisher in project hazelcast by hazelcast.

the class EntryBackupOperation method publishWanReplicationEvent.

private void publishWanReplicationEvent(EntryEventType eventType) {
    final MapContainer mapContainer = this.mapContainer;
    if (!mapContainer.isWanReplicationEnabled()) {
        return;
    }
    final MapEventPublisher mapEventPublisher = mapContainer.getMapServiceContext().getMapEventPublisher();
    final Data key = dataKey;
    if (EntryEventType.REMOVED == eventType) {
        mapEventPublisher.publishWanReplicationRemoveBackup(name, key, Clock.currentTimeMillis());
    } else {
        final Record record = recordStore.getRecord(key);
        if (record != null) {
            dataValue = mapContainer.getMapServiceContext().toData(dataValue);
            final EntryView entryView = createSimpleEntryView(key, dataValue, record);
            mapEventPublisher.publishWanReplicationUpdateBackup(name, entryView);
        }
    }
}
Also used : EntryView(com.hazelcast.core.EntryView) EntryViews.createSimpleEntryView(com.hazelcast.map.impl.EntryViews.createSimpleEntryView) Data(com.hazelcast.nio.serialization.Data) Record(com.hazelcast.map.impl.record.Record) MapContainer(com.hazelcast.map.impl.MapContainer) MapEventPublisher(com.hazelcast.map.impl.event.MapEventPublisher)

Example 3 with MapEventPublisher

use of com.hazelcast.map.impl.event.MapEventPublisher in project hazelcast by hazelcast.

the class MapProxySupport method publishMapEvent.

private void publishMapEvent(int numberOfAffectedEntries, EntryEventType eventType) {
    MapEventPublisher mapEventPublisher = mapServiceContext.getMapEventPublisher();
    mapEventPublisher.publishMapEvent(thisAddress, name, eventType, numberOfAffectedEntries);
}
Also used : MapEventPublisher(com.hazelcast.map.impl.event.MapEventPublisher)

Example 4 with MapEventPublisher

use of com.hazelcast.map.impl.event.MapEventPublisher in project hazelcast by hazelcast.

the class PutFromLoadAllOperation method publishWanReplicationEvent.

private void publishWanReplicationEvent(Data key, Object value, Record record) {
    if (record == null || !mapContainer.isWanReplicationEnabled()) {
        return;
    }
    MapEventPublisher mapEventPublisher = mapServiceContext.getMapEventPublisher();
    value = mapServiceContext.toData(value);
    EntryView entryView = EntryViews.createSimpleEntryView(key, value, record);
    mapEventPublisher.publishWanReplicationUpdate(name, entryView);
}
Also used : EntryView(com.hazelcast.core.EntryView) MapEventPublisher(com.hazelcast.map.impl.event.MapEventPublisher)

Example 5 with MapEventPublisher

use of com.hazelcast.map.impl.event.MapEventPublisher in project hazelcast by hazelcast.

the class MapClearMessageTask method reduce.

@Override
protected Object reduce(Map<Integer, Object> map) {
    int clearedTotal = 0;
    for (Object affectedEntries : map.values()) {
        clearedTotal += (Integer) affectedEntries;
    }
    MapService service = getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = service.getMapServiceContext();
    if (clearedTotal > 0) {
        Address thisAddress = nodeEngine.getThisAddress();
        MapEventPublisher mapEventPublisher = mapServiceContext.getMapEventPublisher();
        mapEventPublisher.publishMapEvent(thisAddress, parameters.name, CLEAR_ALL, clearedTotal);
    }
    return null;
}
Also used : Address(com.hazelcast.nio.Address) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapEventPublisher(com.hazelcast.map.impl.event.MapEventPublisher)

Aggregations

MapEventPublisher (com.hazelcast.map.impl.event.MapEventPublisher)5 EntryView (com.hazelcast.core.EntryView)2 MapService (com.hazelcast.map.impl.MapService)2 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)2 Address (com.hazelcast.nio.Address)2 EntryViews.createSimpleEntryView (com.hazelcast.map.impl.EntryViews.createSimpleEntryView)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 Record (com.hazelcast.map.impl.record.Record)1 Data (com.hazelcast.nio.serialization.Data)1