Search in sources :

Example 1 with Registration

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

the class NodeQueryCacheEventService method publishLocalEvent.

// TODO needs refactoring.
private void publishLocalEvent(String mapName, String cacheName, Object eventData) {
    String listenerName = generateListenerName(mapName, cacheName);
    Collection<EventRegistration> eventRegistrations = getRegistrations(listenerName);
    if (eventRegistrations.isEmpty()) {
        return;
    }
    for (EventRegistration eventRegistration : eventRegistrations) {
        Registration registration = (Registration) eventRegistration;
        Object listener = registration.getListener();
        if (!(listener instanceof QueryCacheListenerAdapter)) {
            continue;
        }
        Object eventDataToPublish = eventData;
        int orderKey = -1;
        if (eventDataToPublish instanceof LocalCacheWideEventData) {
            orderKey = listenerName.hashCode();
        } else if (eventDataToPublish instanceof LocalEntryEventData) {
            LocalEntryEventData localEntryEventData = (LocalEntryEventData) eventDataToPublish;
            if (localEntryEventData.getEventType() != EventLostEvent.EVENT_TYPE) {
                EventFilter filter = registration.getFilter();
                if (!canPassFilter(localEntryEventData, filter)) {
                    continue;
                } else {
                    boolean includeValue = isIncludeValue(filter);
                    eventDataToPublish = includeValue ? localEntryEventData : localEntryEventData.cloneWithoutValue();
                    Data keyData = localEntryEventData.getKeyData();
                    orderKey = keyData == null ? -1 : keyData.hashCode();
                }
            }
        }
        publishEventInternal(registration, eventDataToPublish, orderKey);
    }
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) LocalEntryEventData(com.hazelcast.map.impl.querycache.event.LocalEntryEventData) Registration(com.hazelcast.spi.impl.eventservice.impl.Registration) EventRegistration(com.hazelcast.spi.EventRegistration) QueryCacheListenerAdapter(com.hazelcast.map.impl.querycache.QueryCacheListenerAdapter) LocalCacheWideEventData(com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData) EventData(com.hazelcast.map.impl.event.EventData) Data(com.hazelcast.nio.serialization.Data) LocalEntryEventData(com.hazelcast.map.impl.querycache.event.LocalEntryEventData) EntryEventFilter(com.hazelcast.map.impl.EntryEventFilter) TrueEventFilter(com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter) EventFilter(com.hazelcast.spi.EventFilter) LocalCacheWideEventData(com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData)

Example 2 with Registration

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

the class PostJoinRegistrationOperation method writeInternal.

@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
    super.writeInternal(out);
    int len = registrations != null ? registrations.size() : 0;
    out.writeInt(len);
    if (len > 0) {
        for (Registration reg : registrations) {
            reg.writeData(out);
        }
    }
}
Also used : Registration(com.hazelcast.spi.impl.eventservice.impl.Registration)

Example 3 with Registration

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

the class PostJoinRegistrationOperation method readInternal.

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    super.readInternal(in);
    int len = in.readInt();
    if (len > 0) {
        registrations = new ArrayList<Registration>(len);
        for (int i = 0; i < len; i++) {
            Registration reg = new Registration();
            registrations.add(reg);
            reg.readData(in);
        }
    }
}
Also used : Registration(com.hazelcast.spi.impl.eventservice.impl.Registration)

Example 4 with Registration

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

the class PostJoinRegistrationOperation method run.

@Override
public void run() throws Exception {
    if (registrations == null || registrations.size() <= 0) {
        return;
    }
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    EventServiceImpl eventService = (EventServiceImpl) nodeEngine.getEventService();
    for (Registration reg : registrations) {
        eventService.handleRegistration(reg);
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Registration(com.hazelcast.spi.impl.eventservice.impl.Registration) EventServiceImpl(com.hazelcast.spi.impl.eventservice.impl.EventServiceImpl)

Example 5 with Registration

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

the class RegistrationOperation method readInternal.

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    registration = new Registration();
    registration.readData(in);
}
Also used : Registration(com.hazelcast.spi.impl.eventservice.impl.Registration)

Aggregations

Registration (com.hazelcast.spi.impl.eventservice.impl.Registration)7 QueryCacheListenerAdapter (com.hazelcast.map.impl.querycache.QueryCacheListenerAdapter)3 EventRegistration (com.hazelcast.spi.EventRegistration)3 EntryEventFilter (com.hazelcast.map.impl.EntryEventFilter)1 EventData (com.hazelcast.map.impl.event.EventData)1 LocalCacheWideEventData (com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData)1 LocalEntryEventData (com.hazelcast.map.impl.querycache.event.LocalEntryEventData)1 Data (com.hazelcast.nio.serialization.Data)1 EventFilter (com.hazelcast.spi.EventFilter)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1 EventServiceImpl (com.hazelcast.spi.impl.eventservice.impl.EventServiceImpl)1 TrueEventFilter (com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter)1