Esempio n. 1
0
 public void publishEvent(
     Address caller,
     String mapName,
     EntryEventType eventType,
     Data dataKey,
     Data dataOldValue,
     Data dataValue) {
   Collection<EventRegistration> candidates =
       nodeEngine.getEventService().getRegistrations(SERVICE_NAME, mapName);
   Set<EventRegistration> registrationsWithValue = new HashSet<EventRegistration>();
   Set<EventRegistration> registrationsWithoutValue = new HashSet<EventRegistration>();
   if (candidates.isEmpty()) return;
   Object key = null;
   Object value = null;
   Object oldValue = null;
   for (EventRegistration candidate : candidates) {
     EventFilter filter = candidate.getFilter();
     if (filter instanceof EventServiceImpl.EmptyFilter) {
       registrationsWithValue.add(candidate);
     } else if (filter instanceof QueryEventFilter) {
       Object testValue;
       if (eventType == EntryEventType.REMOVED || eventType == EntryEventType.EVICTED) {
         oldValue = oldValue != null ? oldValue : toObject(dataOldValue);
         testValue = oldValue;
       } else {
         value = value != null ? value : toObject(dataValue);
         testValue = value;
       }
       key = key != null ? key : toObject(dataKey);
       QueryEventFilter queryEventFilter = (QueryEventFilter) filter;
       QueryEntry entry = new QueryEntry(getSerializationService(), dataKey, key, testValue);
       if (queryEventFilter.eval(entry)) {
         if (queryEventFilter.isIncludeValue()) {
           registrationsWithValue.add(candidate);
         } else {
           registrationsWithoutValue.add(candidate);
         }
       }
     } else if (filter.eval(dataKey)) {
       EntryEventFilter eventFilter = (EntryEventFilter) filter;
       if (eventFilter.isIncludeValue()) {
         registrationsWithValue.add(candidate);
       } else {
         registrationsWithoutValue.add(candidate);
       }
     }
   }
   if (registrationsWithValue.isEmpty() && registrationsWithoutValue.isEmpty()) return;
   String source = nodeEngine.getThisAddress().toString();
   if (eventType == EntryEventType.REMOVED || eventType == EntryEventType.EVICTED) {
     dataValue = dataValue != null ? dataValue : dataOldValue;
   }
   EventData event =
       new EventData(
           source, mapName, caller, dataKey, dataValue, dataOldValue, eventType.getType());
   int orderKey = dataKey.hashCode();
   nodeEngine
       .getEventService()
       .publishEvent(SERVICE_NAME, registrationsWithValue, event, orderKey);
   nodeEngine
       .getEventService()
       .publishEvent(
           SERVICE_NAME, registrationsWithoutValue, event.cloneWithoutValues(), orderKey);
 }
Esempio n. 2
0
 private List<Integer> getMemberPartitions() {
   InternalPartitionService partitionService = nodeEngine.getPartitionService();
   List<Integer> partitions = partitionService.getMemberPartitions(nodeEngine.getThisAddress());
   return Collections.unmodifiableList(partitions);
 }