Search in sources :

Example 66 with EventRegistration

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

the class PartitionEventManager method registerLocalListener.

private UUID registerLocalListener(PartitionEventListener<?> adapter, String topic) {
    EventService eventService = nodeEngine.getEventService();
    EventRegistration registration = eventService.registerLocalListener(SERVICE_NAME, topic, adapter);
    return registration.getId();
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 67 with EventRegistration

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

the class EventServiceTest method test_registration_whileNewMemberJoining.

@Test
public void test_registration_whileNewMemberJoining() throws Exception {
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    HazelcastInstance hz1 = factory.newHazelcastInstance(newConfigWithDummyService());
    HazelcastInstance hz2 = factory.newHazelcastInstance(newConfigWithDummyService());
    Future<HazelcastInstance> future = spawn(() -> factory.newHazelcastInstance(newConfigWithDummyService()));
    EventService eventService = getEventService(hz2);
    Set<UUID> registrationIds = new HashSet<UUID>();
    Object listener = new Object();
    while (getClusterService(hz2).getSize() < 3) {
        EventRegistration registration = eventService.registerListener(serviceName, topic, listener);
        registrationIds.add(registration.getId());
    }
    HazelcastInstance hz3 = future.get();
    EventService eventService3 = getEventService(hz3);
    Collection<EventRegistration> registrations = eventService3.getRegistrations(serviceName, topic);
    assertEquals(registrationIds.size(), registrations.size());
    for (EventRegistration registration : registrations) {
        assertThat(registrationIds, hasItem(registration.getId()));
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService) UUID(java.util.UUID) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) HashSet(java.util.HashSet) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

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