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);
}
}
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);
}
}
}
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);
}
}
}
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);
}
}
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);
}
Aggregations