Search in sources :

Example 56 with EventRegistration

use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.

the class CollectionOperation method publishEvent.

protected void publishEvent(ItemEventType eventType, Data data) {
    EventService eventService = getNodeEngine().getEventService();
    Collection<EventRegistration> registrations = eventService.getRegistrations(getServiceName(), name);
    final Address address = getNodeEngine().getThisAddress();
    for (EventRegistration registration : registrations) {
        CollectionEventFilter filter = (CollectionEventFilter) registration.getFilter();
        final boolean includeValue = filter.isIncludeValue();
        CollectionEvent event = new CollectionEvent(name, includeValue ? data : null, eventType, address);
        eventService.publishEvent(getServiceName(), registration, event, name.hashCode());
    }
}
Also used : CollectionEventFilter(com.hazelcast.collection.impl.collection.CollectionEventFilter) EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) Address(com.hazelcast.cluster.Address) CollectionEvent(com.hazelcast.collection.impl.collection.CollectionEvent) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 57 with EventRegistration

use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.

the class QueueOperation method publishEvent.

public void publishEvent(ItemEventType eventType, Data data) {
    EventService eventService = getNodeEngine().getEventService();
    Collection<EventRegistration> registrations = eventService.getRegistrations(getServiceName(), name);
    Address thisAddress = getNodeEngine().getThisAddress();
    for (EventRegistration registration : registrations) {
        QueueEventFilter filter = (QueueEventFilter) registration.getFilter();
        QueueEvent event = new QueueEvent(name, filter.isIncludeValue() ? data : null, eventType, thisAddress);
        eventService.publishEvent(getServiceName(), registration, event, name.hashCode());
    }
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) Address(com.hazelcast.cluster.Address) QueueEventFilter(com.hazelcast.collection.impl.queue.QueueEventFilter) QueueEvent(com.hazelcast.collection.impl.queue.QueueEvent) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 58 with EventRegistration

use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.

the class QueueOperation method hasListener.

public boolean hasListener() {
    EventService eventService = getNodeEngine().getEventService();
    Collection<EventRegistration> registrations = eventService.getRegistrations(getServiceName(), name);
    return registrations.size() > 0;
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 59 with EventRegistration

use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.

the class AddCPGroupAvailabilityListenerMessageTask method processInternal.

@Override
protected CompletableFuture<UUID> processInternal() {
    EventService eventService = clientEngine.getEventService();
    CPGroupAvailabilityListener listener = new ClientCPGroupAvailabilityListener(endpoint);
    boolean local = parameters;
    if (local) {
        UUID id = eventService.registerLocalListener(getServiceName(), TOPIC, listener).getId();
        return CompletableFuture.completedFuture(id);
    }
    return eventService.registerListenerAsync(getServiceName(), TOPIC, listener).thenApplyAsync(EventRegistration::getId, CALLER_RUNS);
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService) UUID(java.util.UUID) CPGroupAvailabilityListener(com.hazelcast.cp.event.CPGroupAvailabilityListener)

Example 60 with EventRegistration

use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.

the class AddCPMembershipListenerMessageTask method processInternal.

@Override
protected CompletableFuture<UUID> processInternal() {
    EventService eventService = clientEngine.getEventService();
    CPMembershipListener listener = new ClientCPMembershipListener(endpoint);
    boolean local = parameters;
    if (local) {
        UUID id = eventService.registerLocalListener(getServiceName(), TOPIC, listener).getId();
        return CompletableFuture.completedFuture(id);
    }
    return eventService.registerListenerAsync(getServiceName(), TOPIC, listener).thenApplyAsync(EventRegistration::getId, CALLER_RUNS);
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) CPMembershipListener(com.hazelcast.cp.event.CPMembershipListener) EventService(com.hazelcast.spi.impl.eventservice.EventService) UUID(java.util.UUID)

Aggregations

EventRegistration (com.hazelcast.spi.impl.eventservice.EventRegistration)67 EventService (com.hazelcast.spi.impl.eventservice.EventService)45 Data (com.hazelcast.internal.serialization.Data)8 EventFilter (com.hazelcast.spi.impl.eventservice.EventFilter)7 UUID (java.util.UUID)7 Address (com.hazelcast.cluster.Address)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 ListenerAdapters.createListenerAdapter (com.hazelcast.map.impl.ListenerAdapters.createListenerAdapter)4 QueryCacheListenerAdapter (com.hazelcast.map.impl.querycache.QueryCacheListenerAdapter)4 CachePartitionLostEventFilter (com.hazelcast.cache.impl.event.CachePartitionLostEventFilter)3 CollectionEventFilter (com.hazelcast.collection.impl.collection.CollectionEventFilter)3 MapPartitionLostEventFilter (com.hazelcast.map.impl.MapPartitionLostEventFilter)3 MapEventData (com.hazelcast.map.impl.event.MapEventData)3 Registration (com.hazelcast.spi.impl.eventservice.impl.Registration)3 InternalCachePartitionLostListenerAdapter (com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter)2 ItemListener (com.hazelcast.collection.ItemListener)2 EntryEventFilter (com.hazelcast.map.impl.EntryEventFilter)2 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)2 AssertTask (com.hazelcast.test.AssertTask)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2