Search in sources :

Example 6 with EventService

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

the class PartitionEventManager method removePartitionLostListenerAsync.

public CompletableFuture<Boolean> removePartitionLostListenerAsync(UUID registrationId) {
    checkNotNull(registrationId, "registrationId can't be null");
    EventService eventService = nodeEngine.getEventService();
    return eventService.deregisterListenerAsync(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC, registrationId);
}
Also used : EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 7 with EventService

use of com.hazelcast.spi.impl.eventservice.EventService 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 8 with EventService

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

the class PartitionEventManager method removePartitionLostListener.

public boolean removePartitionLostListener(@Nonnull UUID registrationId) {
    checkNotNull(registrationId, "registrationId can't be null");
    EventService eventService = nodeEngine.getEventService();
    return eventService.deregisterListener(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC, registrationId);
}
Also used : EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 9 with EventService

use of com.hazelcast.spi.impl.eventservice.EventService 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)

Example 10 with EventService

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

the class PublishAllOperation method run.

@Override
public void run() throws Exception {
    TopicService service = getService();
    EventService eventService = getNodeEngine().getEventService();
    Collection<EventRegistration> registrations = eventService.getRegistrations(TopicService.SERVICE_NAME, name);
    Lock lock = service.getOrderLock(name);
    lock.lock();
    try {
        for (Data item : messages) {
            TopicEvent topicEvent = new TopicEvent(name, item, getCallerAddress());
            eventService.publishEvent(TopicService.SERVICE_NAME, registrations, topicEvent, name.hashCode());
            service.incrementPublishes(name);
        }
    } finally {
        lock.unlock();
    }
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService) Data(com.hazelcast.internal.serialization.Data) Lock(java.util.concurrent.locks.Lock)

Aggregations

EventService (com.hazelcast.spi.impl.eventservice.EventService)67 EventRegistration (com.hazelcast.spi.impl.eventservice.EventRegistration)45 UUID (java.util.UUID)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 Address (com.hazelcast.cluster.Address)4 Config (com.hazelcast.config.Config)4 Data (com.hazelcast.internal.serialization.Data)4 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)4 CollectionEventFilter (com.hazelcast.collection.impl.collection.CollectionEventFilter)3 MapEventData (com.hazelcast.map.impl.event.MapEventData)3 AssertTask (com.hazelcast.test.AssertTask)3 CachePartitionLostEventFilter (com.hazelcast.cache.impl.event.CachePartitionLostEventFilter)2 CachePartitionLostListener (com.hazelcast.cache.impl.event.CachePartitionLostListener)2 ItemListener (com.hazelcast.collection.ItemListener)2 DistributedObject (com.hazelcast.core.DistributedObject)2 Nonnull (javax.annotation.Nonnull)2 CacheEventType (com.hazelcast.cache.CacheEventType)1