Search in sources :

Example 21 with EventRegistration

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

the class TopicDestroyTest method assertRegistrationSize.

void assertRegistrationSize(int size) {
    EventService eventService = getNode(instance).getNodeEngine().getEventService();
    Collection<EventRegistration> regs = eventService.getRegistrations(TopicService.SERVICE_NAME, topicName);
    assertEquals(size, regs.size());
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 22 with EventRegistration

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

the class PartitionLostListenerRegistrationTest method assertRegistrationsSizeEventually.

private static void assertRegistrationsSizeEventually(final HazelcastInstance instance, final int expectedSize) {
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertTrueEventually(new AssertTask() {

                @Override
                public void run() {
                    EventService eventService = getNode(instance).getNodeEngine().getEventService();
                    Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC);
                    assertEquals(expectedSize, registrations.size());
                }
            });
        }
    });
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) AssertTask(com.hazelcast.test.AssertTask) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 23 with EventRegistration

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

the class EventServiceTest method test_deregistration_whileNewMemberJoining.

@Test
public void test_deregistration_whileNewMemberJoining() throws Exception {
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    HazelcastInstance hz1 = factory.newHazelcastInstance(newConfigWithDummyService());
    HazelcastInstance hz2 = factory.newHazelcastInstance(newConfigWithDummyService());
    EventService eventService = getEventService(hz2);
    Set<UUID> registrationIds = new HashSet<UUID>();
    Object listener = new Object();
    for (int i = 0; i < 500; i++) {
        EventRegistration registration = eventService.registerListener(serviceName, topic, listener);
        registrationIds.add(registration.getId());
    }
    Future<HazelcastInstance> future = spawn(() -> factory.newHazelcastInstance(newConfigWithDummyService()));
    for (UUID registrationId : registrationIds) {
        eventService.deregisterListener(serviceName, topic, registrationId);
    }
    assertThat(eventService.getRegistrations(serviceName, topic), Matchers.empty());
    HazelcastInstance hz3 = future.get();
    EventService eventService3 = getEventService(hz3);
    assertThat(eventService3.getRegistrations(serviceName, topic), Matchers.empty());
}
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)

Example 24 with EventRegistration

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

the class EventRegistrationTest method assertEventRegistrations.

private static void assertEventRegistrations(int expected, HazelcastInstance... instances) {
    assertTrueEventually(() -> {
        for (HazelcastInstance instance : instances) {
            Collection<EventRegistration> regs = getNodeEngineImpl(instance).getEventService().getRegistrations(ProxyServiceImpl.SERVICE_NAME, ProxyServiceImpl.SERVICE_NAME);
            assertEquals(instance + ": " + regs, expected, regs.size());
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration)

Example 25 with EventRegistration

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

the class BasicClusterStateTest method assertRegistrationsSizeEventually.

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

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