Search in sources :

Example 66 with EventService

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

the class PartitionEventManager method removeMigrationListener.

public boolean removeMigrationListener(@Nonnull UUID registrationId) {
    checkNotNull(registrationId, "registrationId can't be null");
    EventService eventService = nodeEngine.getEventService();
    return eventService.deregisterListener(SERVICE_NAME, MIGRATION_EVENT_TOPIC, registrationId);
}
Also used : EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 67 with EventService

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

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