Search in sources :

Example 51 with EventRegistration

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

the class QueueOperation method publishEvent.

public void publishEvent(ItemEventType eventType, Data data) {
    EventService eventService = getNodeEngine().getEventService();
    Collection<EventRegistration> registrations = eventService.getRegistrations(getServiceName(), name);
    Address thisAddress = getNodeEngine().getThisAddress();
    for (EventRegistration registration : registrations) {
        QueueEventFilter filter = (QueueEventFilter) registration.getFilter();
        QueueEvent event = new QueueEvent(name, filter.isIncludeValue() ? data : null, eventType, thisAddress);
        eventService.publishEvent(getServiceName(), registration, event, name.hashCode());
    }
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) Address(com.hazelcast.nio.Address) QueueEventFilter(com.hazelcast.collection.impl.queue.QueueEventFilter) QueueEvent(com.hazelcast.collection.impl.queue.QueueEvent) EventService(com.hazelcast.spi.EventService)

Example 52 with EventRegistration

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

the class AbstractPromotionOperation method sendMigrationEvent.

void sendMigrationEvent(final MigrationStatus status) {
    final int partitionId = getPartitionId();
    final NodeEngine nodeEngine = getNodeEngine();
    final Member localMember = nodeEngine.getLocalMember();
    final MigrationEvent event = new MigrationEvent(partitionId, null, localMember, status);
    final EventService eventService = nodeEngine.getEventService();
    final Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, MIGRATION_EVENT_TOPIC);
    eventService.publishEvent(SERVICE_NAME, registrations, event, partitionId);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) EventRegistration(com.hazelcast.spi.EventRegistration) EventService(com.hazelcast.spi.EventService) Member(com.hazelcast.core.Member) MigrationEvent(com.hazelcast.core.MigrationEvent) PartitionMigrationEvent(com.hazelcast.spi.PartitionMigrationEvent)

Example 53 with EventRegistration

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

the class PartitionEventManager method addLocalPartitionLostListener.

public String addLocalPartitionLostListener(PartitionLostListener listener) {
    if (listener == null) {
        throw new NullPointerException("listener can't be null");
    }
    final PartitionLostListenerAdapter adapter = new PartitionLostListenerAdapter(listener);
    EventService eventService = nodeEngine.getEventService();
    EventRegistration registration = eventService.registerLocalListener(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC, adapter);
    return registration.getId();
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) EventService(com.hazelcast.spi.EventService)

Example 54 with EventRegistration

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

the class PartitionEventManager method sendMigrationEvent.

void sendMigrationEvent(final MigrationInfo migrationInfo, final MigrationEvent.MigrationStatus status) {
    if (migrationInfo.getSourceCurrentReplicaIndex() != 0 && migrationInfo.getDestinationNewReplicaIndex() != 0) {
        // only fire events for 0th replica migrations
        return;
    }
    ClusterServiceImpl clusterService = node.getClusterService();
    MemberImpl current = clusterService.getMember(migrationInfo.getSource());
    MemberImpl newOwner = clusterService.getMember(migrationInfo.getDestination());
    MigrationEvent event = new MigrationEvent(migrationInfo.getPartitionId(), current, newOwner, status);
    EventService eventService = nodeEngine.getEventService();
    Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, MIGRATION_EVENT_TOPIC);
    eventService.publishEvent(SERVICE_NAME, registrations, event, event.getPartitionId());
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) MemberImpl(com.hazelcast.instance.MemberImpl) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) EventService(com.hazelcast.spi.EventService) MigrationEvent(com.hazelcast.core.MigrationEvent)

Example 55 with EventRegistration

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

the class MultiMapOperation method hasListener.

public final boolean hasListener() {
    EventService eventService = getNodeEngine().getEventService();
    Collection<EventRegistration> registrations = eventService.getRegistrations(getServiceName(), name);
    return registrations.size() > 0;
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) EventService(com.hazelcast.spi.EventService)

Aggregations

EventRegistration (com.hazelcast.spi.EventRegistration)55 EventService (com.hazelcast.spi.EventService)37 Data (com.hazelcast.nio.serialization.Data)7 EventFilter (com.hazelcast.spi.EventFilter)7 Address (com.hazelcast.nio.Address)5 TrueEventFilter (com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter)5 QueryCacheListenerAdapter (com.hazelcast.map.impl.querycache.QueryCacheListenerAdapter)4 CachePartitionLostEventFilter (com.hazelcast.cache.impl.event.CachePartitionLostEventFilter)3 ClientEndpoint (com.hazelcast.client.ClientEndpoint)3 CollectionEventFilter (com.hazelcast.collection.impl.collection.CollectionEventFilter)3 EntryEventFilter (com.hazelcast.map.impl.EntryEventFilter)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 InitialMembershipEvent (com.hazelcast.core.InitialMembershipEvent)2 ItemListener (com.hazelcast.core.ItemListener)2 Member (com.hazelcast.core.Member)2 MigrationEvent (com.hazelcast.core.MigrationEvent)2 MemberImpl (com.hazelcast.instance.MemberImpl)2