Search in sources :

Example 51 with EventService

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

the class ClientPartitionLostListenerTest method assertRegistrationsSizeEventually.

private void assertRegistrationsSizeEventually(final HazelcastInstance instance, final int size) {
    assertTrueEventually(() -> {
        final EventService eventService = getNode(instance).getNodeEngine().getEventService();
        final Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC);
        assertEquals(size, registrations.size());
    });
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 52 with EventService

use of com.hazelcast.spi.impl.eventservice.EventService 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 53 with EventService

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

the class QueueService method addLocalItemListener.

public UUID addLocalItemListener(String name, ItemListener listener, boolean includeValue) {
    EventService eventService = nodeEngine.getEventService();
    QueueEventFilter filter = new QueueEventFilter(includeValue);
    return eventService.registerLocalListener(QueueService.SERVICE_NAME, name, filter, listener).getId();
}
Also used : EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 54 with EventService

use of com.hazelcast.spi.impl.eventservice.EventService 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 55 with EventService

use of com.hazelcast.spi.impl.eventservice.EventService 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)

Aggregations

EventService (com.hazelcast.spi.impl.eventservice.EventService)67 EventRegistration (com.hazelcast.spi.impl.eventservice.EventRegistration)45 UUID (java.util.UUID)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 Address (com.hazelcast.cluster.Address)4 Config (com.hazelcast.config.Config)4 Data (com.hazelcast.internal.serialization.Data)4 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)4 CollectionEventFilter (com.hazelcast.collection.impl.collection.CollectionEventFilter)3 MapEventData (com.hazelcast.map.impl.event.MapEventData)3 AssertTask (com.hazelcast.test.AssertTask)3 CachePartitionLostEventFilter (com.hazelcast.cache.impl.event.CachePartitionLostEventFilter)2 CachePartitionLostListener (com.hazelcast.cache.impl.event.CachePartitionLostListener)2 ItemListener (com.hazelcast.collection.ItemListener)2 DistributedObject (com.hazelcast.core.DistributedObject)2 Nonnull (javax.annotation.Nonnull)2 CacheEventType (com.hazelcast.cache.CacheEventType)1