Search in sources :

Example 31 with EventService

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

the class TxnSetOperation method run.

@Override
public void run() {
    recordStore.unlock(dataKey, ownerUuid, threadId, getCallId());
    Record record = recordStore.getRecordOrNull(dataKey);
    if (record == null || version == record.getVersion()) {
        EventService eventService = getNodeEngine().getEventService();
        if (eventService.hasEventRegistration(MapService.SERVICE_NAME, getName())) {
            dataOldValue = record == null ? null : mapServiceContext.toData(record.getValue());
        }
        eventType = record == null ? EntryEventType.ADDED : EntryEventType.UPDATED;
        recordStore.set(dataKey, dataValue, ttl);
        shouldBackup = true;
    }
}
Also used : Record(com.hazelcast.map.impl.record.Record) EventService(com.hazelcast.spi.EventService)

Example 32 with EventService

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

the class ReplicatedMapEventPublishingService method fireMapClearedEvent.

public void fireMapClearedEvent(int deletedEntrySize, String name) {
    EventService eventService = nodeEngine.getEventService();
    Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, name);
    if (registrations.isEmpty()) {
        return;
    }
    MapEventData mapEventData = new MapEventData(name, name, nodeEngine.getThisAddress(), EntryEventType.CLEAR_ALL.getType(), deletedEntrySize);
    eventService.publishEvent(SERVICE_NAME, registrations, mapEventData, name.hashCode());
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) EventService(com.hazelcast.spi.EventService) MapEventData(com.hazelcast.map.impl.event.MapEventData)

Example 33 with EventService

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

the class QueueOperation method hasListener.

public 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)

Example 34 with EventService

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

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

Aggregations

EventService (com.hazelcast.spi.EventService)49 EventRegistration (com.hazelcast.spi.EventRegistration)37 Address (com.hazelcast.nio.Address)5 NodeEngine (com.hazelcast.spi.NodeEngine)5 QueryCacheEventService (com.hazelcast.map.impl.querycache.QueryCacheEventService)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Collection (java.util.Collection)4 Test (org.junit.Test)4 ClientEndpoint (com.hazelcast.client.ClientEndpoint)3 CollectionEventFilter (com.hazelcast.collection.impl.collection.CollectionEventFilter)3 Config (com.hazelcast.config.Config)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 MapEventData (com.hazelcast.map.impl.event.MapEventData)3 Data (com.hazelcast.nio.serialization.Data)3 CachePartitionLostEventFilter (com.hazelcast.cache.impl.event.CachePartitionLostEventFilter)2 CachePartitionLostListener (com.hazelcast.cache.impl.event.CachePartitionLostListener)2 InitialMembershipEvent (com.hazelcast.core.InitialMembershipEvent)2 ItemListener (com.hazelcast.core.ItemListener)2 Member (com.hazelcast.core.Member)2