Search in sources :

Example 1 with EventRegistration

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

the class AbstractCollectionProxyImpl method addItemListener.

@Nonnull
public UUID addItemListener(@Nonnull ItemListener<E> listener, boolean includeValue) {
    checkNotNull(listener, "Null listener is not allowed!");
    final EventService eventService = getNodeEngine().getEventService();
    final CollectionEventFilter filter = new CollectionEventFilter(includeValue);
    final EventRegistration registration = eventService.registerListener(getServiceName(), name, filter, listener);
    return registration.getId();
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService) Nonnull(javax.annotation.Nonnull)

Example 2 with EventRegistration

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

the class PartitionEventManager method addMigrationListenerAsync.

public CompletableFuture<UUID> addMigrationListenerAsync(@Nonnull MigrationListener listener) {
    checkNotNull(listener, "listener can't be null");
    final MigrationListenerAdapter adapter = new MigrationListenerAdapter(listener);
    EventService eventService = nodeEngine.getEventService();
    return eventService.registerListenerAsync(SERVICE_NAME, MIGRATION_EVENT_TOPIC, adapter).thenApplyAsync(EventRegistration::getId, CALLER_RUNS);
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 3 with EventRegistration

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

the class PartitionEventManager method addMigrationListener.

public UUID addMigrationListener(@Nonnull MigrationListener listener) {
    checkNotNull(listener, "listener can't be null");
    final MigrationListenerAdapter adapter = new MigrationListenerAdapter(listener);
    EventService eventService = nodeEngine.getEventService();
    EventRegistration registration = eventService.registerListener(SERVICE_NAME, MIGRATION_EVENT_TOPIC, adapter);
    return registration.getId();
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 4 with EventRegistration

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

the class PartitionEventManager method onPartitionLost.

public void onPartitionLost(IPartitionLostEvent event) {
    assert event instanceof PartitionLostEvent;
    EventService eventService = nodeEngine.getEventService();
    Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC);
    eventService.publishEvent(SERVICE_NAME, registrations, event, event.getPartitionId());
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) IPartitionLostEvent(com.hazelcast.internal.partition.IPartitionLostEvent) PartitionLostEvent(com.hazelcast.partition.PartitionLostEvent) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 5 with EventRegistration

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

the class PartitionEventManager method addPartitionLostListener.

public UUID addPartitionLostListener(@Nonnull PartitionLostListener listener) {
    checkNotNull(listener, "listener can't be null");
    final PartitionLostListenerAdapter adapter = new PartitionLostListenerAdapter(listener);
    EventService eventService = nodeEngine.getEventService();
    EventRegistration registration = eventService.registerListener(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC, adapter);
    return registration.getId();
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Aggregations

EventRegistration (com.hazelcast.spi.impl.eventservice.EventRegistration)67 EventService (com.hazelcast.spi.impl.eventservice.EventService)45 Data (com.hazelcast.internal.serialization.Data)8 EventFilter (com.hazelcast.spi.impl.eventservice.EventFilter)7 UUID (java.util.UUID)7 Address (com.hazelcast.cluster.Address)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 ListenerAdapters.createListenerAdapter (com.hazelcast.map.impl.ListenerAdapters.createListenerAdapter)4 QueryCacheListenerAdapter (com.hazelcast.map.impl.querycache.QueryCacheListenerAdapter)4 CachePartitionLostEventFilter (com.hazelcast.cache.impl.event.CachePartitionLostEventFilter)3 CollectionEventFilter (com.hazelcast.collection.impl.collection.CollectionEventFilter)3 MapPartitionLostEventFilter (com.hazelcast.map.impl.MapPartitionLostEventFilter)3 MapEventData (com.hazelcast.map.impl.event.MapEventData)3 Registration (com.hazelcast.spi.impl.eventservice.impl.Registration)3 InternalCachePartitionLostListenerAdapter (com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter)2 ItemListener (com.hazelcast.collection.ItemListener)2 EntryEventFilter (com.hazelcast.map.impl.EntryEventFilter)2 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)2 AssertTask (com.hazelcast.test.AssertTask)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2