@Test public void testIssue321() throws Exception { HazelcastClient hClient = getHazelcastClient(); final IMap<Integer, Integer> imap = hClient.getMap("testIssue321_1"); final BlockingQueue<EntryEvent<Integer, Integer>> events1 = new LinkedBlockingQueue<EntryEvent<Integer, Integer>>(); final BlockingQueue<EntryEvent<Integer, Integer>> events2 = new LinkedBlockingQueue<EntryEvent<Integer, Integer>>(); imap.addEntryListener( new EntryAdapter<Integer, Integer>() { @Override public void entryAdded(EntryEvent event) { events2.add(event); } }, false); imap.addEntryListener( new EntryAdapter<Integer, Integer>() { @Override public void entryAdded(EntryEvent event) { events1.add(event); } }, true); imap.put(1, 1); final EntryEvent<Integer, Integer> event1 = events1.poll(10, TimeUnit.MILLISECONDS); final EntryEvent<Integer, Integer> event2 = events2.poll(10, TimeUnit.MILLISECONDS); assertNotNull(event1); assertNotNull(event2); assertNotNull(event1.getValue()); assertNull(event2.getValue()); }
@SuppressWarnings("unchecked") public void dispatchEvent(EventData eventData, EntryListener listener) { Member member = nodeEngine.getClusterService().getMember(eventData.getCaller()); EntryEvent event = new DataAwareEntryEvent( member, eventData.getEventType(), eventData.getMapName(), eventData.getDataKey(), eventData.getDataNewValue(), eventData.getDataOldValue(), getSerializationService()); switch (event.getEventType()) { case ADDED: listener.entryAdded(event); break; case EVICTED: listener.entryEvicted(event); break; case UPDATED: listener.entryUpdated(event); break; case REMOVED: listener.entryRemoved(event); break; default: throw new IllegalArgumentException("Invalid event type: " + event.getEventType()); } MapContainer mapContainer = getMapContainer(eventData.getMapName()); if (mapContainer.getMapConfig().isStatisticsEnabled()) { getLocalMapStatsImpl(eventData.getMapName()).incrementReceivedEvents(); } }