Search in sources :

Example 16 with EventService

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();
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) EventService(com.hazelcast.spi.EventService)

Example 17 with EventService

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());
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) IPartitionLostEvent(com.hazelcast.spi.partition.IPartitionLostEvent) PartitionLostEvent(com.hazelcast.partition.PartitionLostEvent) EventService(com.hazelcast.spi.EventService)

Example 18 with EventService

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();
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) EventService(com.hazelcast.spi.EventService)

Example 19 with EventService

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();
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) EventService(com.hazelcast.spi.EventService)

Example 20 with EventService

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();
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) QueryCacheListenerAdapter(com.hazelcast.map.impl.querycache.QueryCacheListenerAdapter) ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter) EventRegistration(com.hazelcast.spi.EventRegistration) QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService) EventService(com.hazelcast.spi.EventService)

Aggregations

EventService (com.hazelcast.spi.EventService)49 EventRegistration (com.hazelcast.spi.EventRegistration)37 Address (com.hazelcast.nio.Address)5 NodeEngine (com.hazelcast.spi.NodeEngine)5 QueryCacheEventService (com.hazelcast.map.impl.querycache.QueryCacheEventService)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Collection (java.util.Collection)4 Test (org.junit.Test)4 ClientEndpoint (com.hazelcast.client.ClientEndpoint)3 CollectionEventFilter (com.hazelcast.collection.impl.collection.CollectionEventFilter)3 Config (com.hazelcast.config.Config)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 MapEventData (com.hazelcast.map.impl.event.MapEventData)3 Data (com.hazelcast.nio.serialization.Data)3 CachePartitionLostEventFilter (com.hazelcast.cache.impl.event.CachePartitionLostEventFilter)2 CachePartitionLostListener (com.hazelcast.cache.impl.event.CachePartitionLostListener)2 InitialMembershipEvent (com.hazelcast.core.InitialMembershipEvent)2 ItemListener (com.hazelcast.core.ItemListener)2 Member (com.hazelcast.core.Member)2