use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class PartitionEventManager method addPartitionLostListener.
public String addPartitionLostListener(PartitionLostListener listener) {
if (listener == null) {
throw new NullPointerException("listener can't be null");
}
final PartitionLostListenerAdapter adapter = new PartitionLostListenerAdapter(listener);
EventService eventService = nodeEngine.getEventService();
EventRegistration registration = eventService.registerListener(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC, adapter);
return registration.getId();
}
use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class PartitionEventManager method onPartitionLost.
public void onPartitionLost(IPartitionLostEvent event) {
final PartitionLostEvent partitionLostEvent = new PartitionLostEvent(event.getPartitionId(), event.getLostReplicaIndex(), event.getEventSource());
final EventService eventService = nodeEngine.getEventService();
final Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC);
eventService.publishEvent(SERVICE_NAME, registrations, partitionLostEvent, event.getPartitionId());
}
use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class PartitionEventManager method addMigrationListener.
public String addMigrationListener(MigrationListener listener) {
if (listener == null) {
throw new NullPointerException("listener can't be null");
}
final MigrationListenerAdapter adapter = new MigrationListenerAdapter(listener);
EventService eventService = nodeEngine.getEventService();
EventRegistration registration = eventService.registerListener(SERVICE_NAME, MIGRATION_EVENT_TOPIC, adapter);
return registration.getId();
}
use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class MapServiceContextImpl method addListenerAdapter.
@Override
public String addListenerAdapter(String cacheName, ListenerAdapter listenerAdaptor) {
EventService eventService = getNodeEngine().getEventService();
EventRegistration registration = eventService.registerListener(MapService.SERVICE_NAME, cacheName, TrueEventFilter.INSTANCE, listenerAdaptor);
return registration.getId();
}
use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class NodeQueryCacheEventService method addListener.
@Override
public String addListener(String mapName, String cacheName, MapListener listener, EventFilter filter) {
checkHasText(mapName, "mapName");
checkHasText(cacheName, "cacheName");
checkNotNull(listener, "listener cannot be null");
ListenerAdapter queryCacheListenerAdaptor = createQueryCacheListenerAdaptor(listener);
ListenerAdapter listenerAdaptor = new SimpleQueryCacheListenerAdapter(queryCacheListenerAdaptor);
NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
EventService eventService = nodeEngine.getEventService();
String listenerName = generateListenerName(mapName, cacheName);
EventRegistration registration;
if (filter == null) {
registration = eventService.registerLocalListener(MapService.SERVICE_NAME, listenerName, listenerAdaptor);
} else {
registration = eventService.registerLocalListener(MapService.SERVICE_NAME, listenerName, filter, listenerAdaptor);
}
return registration.getId();
}
Aggregations