use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class CachePartitionLostListenerConfigTest method testCachePartitionLostListener_registeredViaImplementationInConfigObject.
@Test
public void testCachePartitionLostListener_registeredViaImplementationInConfigObject() {
final String cacheName = "myCache";
Config config = new Config();
CacheSimpleConfig cacheConfig = config.getCacheConfig(cacheName);
CachePartitionLostListener listener = mock(CachePartitionLostListener.class);
cacheConfig.addCachePartitionLostListenerConfig(new CachePartitionLostListenerConfig(listener));
cacheConfig.setBackupCount(0);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance instance = factory.newHazelcastInstance(config);
HazelcastServerCachingProvider cachingProvider = createServerCachingProvider(instance);
CacheManager cacheManager = cachingProvider.getCacheManager();
cacheManager.getCache(cacheName);
final EventService eventService = getNode(instance).getNodeEngine().getEventService();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
Collection<EventRegistration> registrations = eventService.getRegistrations(CacheService.SERVICE_NAME, cacheName);
assertFalse(registrations.isEmpty());
}
});
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class DestroyQueryCacheOperation method removeAllListeners.
private void removeAllListeners() {
EventService eventService = getNodeEngine().getEventService();
eventService.deregisterAllListeners(MapService.SERVICE_NAME, cacheId);
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class MultiMapService method addListenerAsync.
public CompletableFuture<UUID> addListenerAsync(String name, @Nonnull EventListener listener, Data key, boolean includeValue) {
EventService eventService = nodeEngine.getEventService();
MultiMapEventFilter filter = new MultiMapEventFilter(includeValue, key);
return eventService.registerListenerAsync(SERVICE_NAME, name, filter, listener).thenApplyAsync(EventRegistration::getId, CALLER_RUNS);
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class MultiMapService method addListener.
public UUID addListener(String name, @Nonnull EventListener listener, Data key, boolean includeValue) {
EventService eventService = nodeEngine.getEventService();
MultiMapEventFilter filter = new MultiMapEventFilter(includeValue, key);
return eventService.registerListener(SERVICE_NAME, name, filter, listener).getId();
}
use of com.hazelcast.spi.impl.eventservice.EventService in project hazelcast by hazelcast.
the class MultiMapEventsPublisher method publishEntryEvent.
public final void publishEntryEvent(String multiMapName, EntryEventType eventType, Data key, Object newValue, Object oldValue) {
EventService eventService = nodeEngine.getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(MultiMapService.SERVICE_NAME, multiMapName);
for (EventRegistration registration : registrations) {
MultiMapEventFilter filter = (MultiMapEventFilter) registration.getFilter();
if (filter.getKey() == null || filter.getKey().equals(key)) {
Data dataNewValue = filter.isIncludeValue() ? nodeEngine.toData(newValue) : null;
Data dataOldValue = filter.isIncludeValue() ? nodeEngine.toData(oldValue) : null;
Address caller = nodeEngine.getThisAddress();
String source = caller.toString();
EntryEventData event = new EntryEventData(source, multiMapName, caller, key, dataNewValue, dataOldValue, eventType.getType());
eventService.publishEvent(MultiMapService.SERVICE_NAME, registration, event, multiMapName.hashCode());
}
}
}
Aggregations