use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.
the class ClientMapIssueTest method testListenerRegistrations.
@Test
public void testListenerRegistrations() {
Config config = getConfig();
ClientConfig clientConfig = getClientConfig();
HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
final String mapName = randomMapName();
IMap<Object, Object> map = client.getMap(mapName);
map.addEntryListener(new EntryAdapter<>(), true);
HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance(config);
instance1.getLifecycleService().terminate();
instance1 = hazelcastFactory.newHazelcastInstance(config);
final EventService eventService1 = getNodeEngineImpl(instance1).getEventService();
final EventService eventService2 = getNodeEngineImpl(instance2).getEventService();
assertTrueEventually(() -> {
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());
});
}
use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.
the class ClientMapPartitionLostListenerTest method assertRegistrationEventually.
private static void assertRegistrationEventually(final HazelcastInstance instance, final String mapName, final boolean shouldBeRegistered) {
final EventService eventService = getNode(instance).getNodeEngine().getEventService();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
boolean registered = false;
for (EventRegistration registration : eventService.getRegistrations(SERVICE_NAME, mapName)) {
if (registration.getFilter() instanceof MapPartitionLostEventFilter) {
registered = true;
break;
}
}
if (shouldBeRegistered != registered) {
fail("shouldBeRegistered: " + shouldBeRegistered + " registered: " + registered);
}
}
});
}
use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.
the class AbstractCacheRecordStore method closeListeners.
protected void closeListeners() {
EventService eventService = cacheService.getNodeEngine().getEventService();
Collection<EventRegistration> candidates = eventService.getRegistrations(ICacheService.SERVICE_NAME, name);
for (EventRegistration eventRegistration : candidates) {
eventService.close(eventRegistration);
}
}
use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.
the class AbstractCacheService method registerListener.
@Override
public UUID registerListener(String cacheNameWithPrefix, CacheEventListener listener) {
EventService eventService = getNodeEngine().getEventService();
EventRegistration registration = eventService.registerListener(AbstractCacheService.SERVICE_NAME, cacheNameWithPrefix, listener);
return updateRegisteredListeners(listener, registration);
}
use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.
the class AbstractCacheService method registerLocalListener.
@Override
public UUID registerLocalListener(String cacheNameWithPrefix, CacheEventListener listener, EventFilter eventFilter) {
EventService eventService = getNodeEngine().getEventService();
EventRegistration registration = eventService.registerLocalListener(AbstractCacheService.SERVICE_NAME, cacheNameWithPrefix, eventFilter, listener);
if (registration == null) {
return null;
}
return updateRegisteredListeners(listener, registration);
}
Aggregations