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();
}
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()));
}
}
Aggregations