HazelcastInstance instance2 = Hazelcast.newHazelcastInstance();
instance1.getLifecycleService().terminate();
instance1 = Hazelcast.newHazelcastInstance();
final EventService eventService1 = TestUtil.getNode(instance1).nodeEngine.getEventService();
final EventService eventService2 = TestUtil.getNode(instance2).nodeEngine.getEventService();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
Collection<EventRegistration> regs1 = eventService1.getRegistrations(MapService.SERVICE_NAME, mapName);
Collection<EventRegistration> regs2 = eventService2.getRegistrations(MapService.SERVICE_NAME, mapName);
assertEquals("there should be only one registration", 1, regs1.size());
assertEquals("there should be only one registration", 1, regs2.size());
}
}, 10);