Search in sources :

Example 6 with EventService

use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.

the class CacheEventHandler method publishEvent.

void publishEvent(String cacheName, CacheEventSet eventSet, int orderKey) {
    final EventService eventService = nodeEngine.getEventService();
    final Collection<EventRegistration> candidates = eventService.getRegistrations(SERVICE_NAME, cacheName);
    if (candidates.isEmpty()) {
        return;
    }
    eventService.publishEvent(SERVICE_NAME, candidates, eventSet, orderKey);
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) EventService(com.hazelcast.spi.EventService)

Example 7 with EventService

use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.

the class ClientServiceProxy method addClientListener.

@Override
public String addClientListener(ClientListener clientListener) {
    checkNotNull(clientListener, "clientListener should not be null");
    EventService eventService = nodeEngine.getEventService();
    EventRegistration registration = eventService.registerLocalListener(ClientEngineImpl.SERVICE_NAME, ClientEngineImpl.SERVICE_NAME, clientListener);
    return registration.getId();
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) EventService(com.hazelcast.spi.EventService)

Example 8 with EventService

use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.

the class ClientServiceProxy method removeClientListener.

@Override
public boolean removeClientListener(String registrationId) {
    checkNotNull(registrationId, "registrationId should not be null");
    EventService eventService = nodeEngine.getEventService();
    return eventService.deregisterListener(ClientEngineImpl.SERVICE_NAME, ClientEngineImpl.SERVICE_NAME, registrationId);
}
Also used : EventService(com.hazelcast.spi.EventService)

Example 9 with EventService

use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.

the class ClientEngineImpl method sendClientEvent.

private void sendClientEvent(ClientEvent event) {
    final EventService eventService = nodeEngine.getEventService();
    final Collection<EventRegistration> regs = eventService.getRegistrations(SERVICE_NAME, SERVICE_NAME);
    String uuid = event.getUuid();
    eventService.publishEvent(SERVICE_NAME, regs, event, uuid.hashCode());
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) EventService(com.hazelcast.spi.EventService)

Example 10 with EventService

use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.

the class AbstractCacheService method publishCachePartitionLostEvent.

protected void publishCachePartitionLostEvent(String cacheName, int partitionId) {
    Collection<EventRegistration> registrations = new LinkedList<EventRegistration>();
    for (EventRegistration registration : getRegistrations(cacheName)) {
        if (registration.getFilter() instanceof CachePartitionLostEventFilter) {
            registrations.add(registration);
        }
    }
    if (registrations.isEmpty()) {
        return;
    }
    Member member = nodeEngine.getLocalMember();
    CacheEventData eventData = new CachePartitionEventData(cacheName, partitionId, member);
    EventService eventService = nodeEngine.getEventService();
    eventService.publishEvent(SERVICE_NAME, registrations, eventData, partitionId);
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) EventService(com.hazelcast.spi.EventService) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) Member(com.hazelcast.core.Member) LinkedList(java.util.LinkedList)

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