Search in sources :

Example 21 with EventService

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

the class ClientServiceProxy method addClientListener.

@Nonnull
@Override
public UUID addClientListener(@Nonnull ClientListener clientListener) {
    checkNotNull(clientListener, "clientListener should not be null");
    EventService eventService = nodeEngine.getEventService();
    EventRegistration registration = eventService.registerLocalListener(ClientEngineImpl.SERVICE_NAME, ClientEngineImpl.SERVICE_NAME, clientListener);
    return registration.getId();
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService) Nonnull(javax.annotation.Nonnull)

Example 22 with EventService

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

the class SetAddListenerMessageTask method processInternal.

@Override
protected CompletableFuture<UUID> processInternal() {
    Data partitionKey = serializationService.toData(parameters.name);
    ItemListener listener = createItemListener(endpoint, partitionKey);
    EventService eventService = clientEngine.getEventService();
    CollectionEventFilter filter = new CollectionEventFilter(parameters.includeValue);
    if (parameters.localOnly) {
        return newCompletedFuture(eventService.registerLocalListener(getServiceName(), parameters.name, filter, listener).getId());
    }
    return eventService.registerListenerAsync(getServiceName(), parameters.name, filter, listener).thenApplyAsync(EventRegistration::getId, CALLER_RUNS);
}
Also used : CollectionEventFilter(com.hazelcast.collection.impl.collection.CollectionEventFilter) EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) Data(com.hazelcast.internal.serialization.Data) ItemListener(com.hazelcast.collection.ItemListener) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 23 with EventService

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

the class RemoveCPGroupAvailabilityListenerMessageTask method processInternal.

@Override
protected CompletableFuture<Boolean> processInternal() {
    UUID registrationId = parameters;
    endpoint.removeDestroyAction(registrationId);
    EventService eventService = clientEngine.getEventService();
    return eventService.deregisterListenerAsync(getServiceName(), EVENT_TOPIC_AVAILABILITY, registrationId);
}
Also used : EventService(com.hazelcast.spi.impl.eventservice.EventService) UUID(java.util.UUID)

Example 24 with EventService

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

the class TopicDestroyTest method assertRegistrationSize.

void assertRegistrationSize(int size) {
    EventService eventService = getNode(instance).getNodeEngine().getEventService();
    Collection<EventRegistration> regs = eventService.getRegistrations(TopicService.SERVICE_NAME, topicName);
    assertEquals(size, regs.size());
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 25 with EventService

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

the class PartitionLostListenerRegistrationTest method assertRegistrationsSizeEventually.

private static void assertRegistrationsSizeEventually(final HazelcastInstance instance, final int expectedSize) {
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertTrueEventually(new AssertTask() {

                @Override
                public void run() {
                    EventService eventService = getNode(instance).getNodeEngine().getEventService();
                    Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC);
                    assertEquals(expectedSize, registrations.size());
                }
            });
        }
    });
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) AssertTask(com.hazelcast.test.AssertTask) EventService(com.hazelcast.spi.impl.eventservice.EventService)

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