Search in sources :

Example 51 with EventRegistration

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

the class ProxyRegistry method publish.

private void publish(DistributedObjectEventPacket event) {
    EventService eventService = proxyService.nodeEngine.getEventService();
    Collection<EventRegistration> registrations = eventService.getRegistrations(ProxyServiceImpl.SERVICE_NAME, ProxyServiceImpl.SERVICE_NAME);
    eventService.publishRemoteEvent(ProxyServiceImpl.SERVICE_NAME, registrations, event, event.getName().hashCode());
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 52 with EventRegistration

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

the class TopicService method publishMessage.

public void publishMessage(String topicName, Object payload, boolean multithreaded) {
    Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, topicName);
    if (!registrations.isEmpty()) {
        Data payloadData = nodeEngine.toData(payload);
        TopicEvent topicEvent = new TopicEvent(topicName, payloadData, localAddress);
        int partitionId = multithreaded ? counter.incrementAndGet() : topicName.hashCode();
        eventService.publishEvent(SERVICE_NAME, registrations, topicEvent, partitionId);
    }
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) Data(com.hazelcast.internal.serialization.Data)

Example 53 with EventRegistration

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

the class PublishOperation method run.

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

Example 54 with EventRegistration

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

the class ClientMigrationListenerTest method assertRegistrationsSizeEventually.

private void assertRegistrationsSizeEventually(HazelcastInstance instance, int size) {
    assertTrueEventually(() -> {
        EventService eventService = getNode(instance).getNodeEngine().getEventService();
        Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, MIGRATION_EVENT_TOPIC);
        assertEquals(size, registrations.size());
    });
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 55 with EventRegistration

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

the class ClientPartitionLostListenerTest method assertRegistrationsSizeEventually.

private void assertRegistrationsSizeEventually(final HazelcastInstance instance, final int size) {
    assertTrueEventually(() -> {
        final EventService eventService = getNode(instance).getNodeEngine().getEventService();
        final Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC);
        assertEquals(size, registrations.size());
    });
}
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