private void simulateCacheInserts(Cache cache) { EntryListener EntryListener = EntryListeners.get(cache); if (EntryListener != null) { if (cache instanceof CacheWrapper) { Cache wrapped = ((CacheWrapper) cache).getWrappedCache(); if (wrapped instanceof ClusteredCache) { ClusteredCache clusteredCache = (ClusteredCache) wrapped; for (Map.Entry entry : (Set<Map.Entry>) cache.entrySet()) { EntryEvent event = new EntryEvent(clusteredCache.map.getName(), cluster.getLocalMember(), EntryEventType.ADDED.getType(), entry.getKey(), null, entry.getValue()); EntryListener.entryAdded(event); } } } } }
public synchronized void removeListener(String name, Object key, EntryListener<?, ?> entryListener) { Map<Object, List<EntryListenerHolder>> m = entryListeners.get(name); if (m != null) { key = toKey(key); List<EntryListenerHolder> list = m.get(key); if (list != null) { for (final Iterator<EntryListenerHolder> it = list.iterator(); it.hasNext(); ) { final EntryListenerHolder entryListenerHolder = it.next(); if (entryListenerHolder.listener.equals(entryListener)) { list.remove(entryListenerHolder); } } if (m.get(key).isEmpty()) { m.remove(key); } } if (m.isEmpty()) { entryListeners.remove(name); } } }
private void simulateCacheInserts(Cache cache) { EntryListener EntryListener = EntryListeners.get(cache); if (EntryListener != null) { if (cache instanceof CacheWrapper) { Cache wrapped = ((CacheWrapper) cache).getWrappedCache(); if (wrapped instanceof ClusteredCache) { ClusteredCache clusteredCache = (ClusteredCache) wrapped; for (Map.Entry entry : (Set<Map.Entry>) cache.entrySet()) { EntryEvent event = new EntryEvent(clusteredCache.map.getName(), cluster.getLocalMember(), EntryEvent.TYPE_ADDED, entry.getKey(), null, entry.getValue()); EntryListener.entryAdded(event); } } } } }
@Override @SuppressWarnings("unchecked") protected void trainHazelcastInstance(HazelcastInstance hazelcastInstance) { when(hazelcastInstance.getReplicatedMap("rm")).thenReturn(map); argument = ArgumentCaptor.forClass(EntryListener.class); when(map.addEntryListener(argument.capture(), eq(true))).thenReturn("foo"); }
@Override @SuppressWarnings("unchecked") protected void trainHazelcastInstance(HazelcastInstance hazelcastInstance) { when(hazelcastInstance.getMultiMap("mm")).thenReturn(map); argument = ArgumentCaptor.forClass(EntryListener.class); when(map.addEntryListener(argument.capture(), eq(true))).thenReturn("foo"); }
/** * {@inheritDoc} * * @deprecated not implemented yet * @throws UnsupportedOperationException not implemented yet */ @Deprecated @Override public String addLocalEntryListener(EntryListener<K, V> listener, Predicate<K, V> predicate, boolean includeValue) { throw new UnsupportedOperationException(); }
/** * {@inheritDoc} * * @deprecated not implemented yet * @throws UnsupportedOperationException not implemented yet */ @Deprecated @Override public String addLocalEntryListener(EntryListener<K, V> listener, Predicate<K, V> predicate, K key, boolean includeValue) { throw new UnsupportedOperationException(); }
/** * {@inheritDoc} * * @deprecated not implemented yet * @throws UnsupportedOperationException not implemented yet */ @Deprecated @Override public String addEntryListener(EntryListener<K, V> listener, Predicate<K, V> predicate, boolean includeValue) { throw new UnsupportedOperationException(); }
/** * {@inheritDoc} * * @deprecated not implemented yet * @throws UnsupportedOperationException not implemented yet */ @Deprecated @Override public String addEntryListener(EntryListener<K, V> listener, Predicate<K, V> predicate, K key, boolean includeValue) { throw new UnsupportedOperationException(); }
private void addEntryListener(Cache cache, EntryListener listener) { if (cache instanceof CacheWrapper) { Cache wrapped = ((CacheWrapper)cache).getWrappedCache(); if (wrapped instanceof ClusteredCache) { ((ClusteredCache)wrapped).addEntryListener(listener, false); // Keep track of the listener that we added to the cache EntryListeners.put(cache, listener); } } }
public void addEntryListener(EntryListener<K, V> listener, K key, boolean includeValue) { check(listener); Boolean noEntryListenerRegistered = entryListenerManager().noListenerRegistered(key, name, includeValue); if (noEntryListenerRegistered == null) { proxyHelper.doOp(ClusterOperation.REMOVE_LISTENER, key, null); noEntryListenerRegistered = Boolean.TRUE; } if (noEntryListenerRegistered.booleanValue()) { Call c = entryListenerManager().createNewAddListenerCall(proxyHelper, key, includeValue); proxyHelper.doCall(c); } entryListenerManager().registerListener(name, key, includeValue, listener); }
public synchronized void registerListener(String name, Object key, boolean includeValue, EntryListener<?, ?> entryListener) { ConcurrentHashMap<Object, List<EntryListenerHolder>> map = entryListeners.get(name); key = toKey(key); if (map == null) { map = new ConcurrentHashMap<Object, List<EntryListenerHolder>>(); final ConcurrentHashMap<Object, List<EntryListenerHolder>> map2 = entryListeners.putIfAbsent(name, map); if (map2 != null) { map = map2; } } if (!map.contains(key)) { map.putIfAbsent(key, new CopyOnWriteArrayList<EntryListenerHolder>()); } map.get(key).add(new EntryListenerHolder(entryListener, includeValue)); }
public void addEntryListener(EntryListener<K, V> listener, K key, boolean includeValue) { check(listener); Boolean noEntryListenerRegistered = listenerManager().noListenerRegistered(key, name, includeValue); if (noEntryListenerRegistered == null) { proxyHelper.doOp(ClusterOperation.REMOVE_LISTENER, key, null); noEntryListenerRegistered = Boolean.TRUE; } if (noEntryListenerRegistered) { Call c = listenerManager().createNewAddListenerCall(proxyHelper, key, includeValue); proxyHelper.doCall(c); } listenerManager().registerListener(name, key, includeValue, listener); }
@Override @SuppressWarnings("unchecked") protected void verifyHazelcastInstance(HazelcastInstance hazelcastInstance) { verify(hazelcastInstance).getReplicatedMap("rm"); verify(map).addEntryListener(any(EntryListener.class), eq(true)); }
@Override @SuppressWarnings("unchecked") protected void verifyHazelcastInstance(HazelcastInstance hazelcastInstance) { verify(hazelcastInstance).getMultiMap("mm"); verify(map).addEntryListener(any(EntryListener.class), eq(true)); }
@Override public String addLocalEntryListener(EntryListener<K, V> listener) { return m.addLocalEntryListener(new BaseEntryListener(listener)); }
@Override public String addEntryListener(EntryListener<K, V> listener, boolean includeValue) { return m.addEntryListener(new BaseEntryListener(listener), includeValue); }
@Override public String addEntryListener(EntryListener<K, V> listener, K key, boolean includeValue) { return m.addEntryListener(new BaseEntryListener(listener), serializeKey(key), includeValue); }
public BaseEntryListener(EntryListener<K, V> listener) { this.listener = listener; }
@Override public String addLocalEntryListener(EntryListener listener) { return map.addLocalEntryListener(listener); }
@Override public String addLocalEntryListener(EntryListener listener, Predicate<K, V> predicate, boolean includeValue) { return map.addLocalEntryListener(listener, predicate, includeValue); }
@Override public String addLocalEntryListener(EntryListener listener, Predicate<K, V> predicate, K key, boolean includeValue) { return map.addLocalEntryListener(listener, predicate, key, includeValue); }
@Override public String addEntryListener(EntryListener listener, boolean includeValue) { return map.addEntryListener(listener, includeValue); }
@Override public String addEntryListener(EntryListener listener, K key, boolean includeValue) { return map.addEntryListener(listener, key, includeValue); }
@Override public String addEntryListener(EntryListener listener, Predicate<K, V> predicate, boolean includeValue) { return map.addEntryListener(listener, predicate, includeValue); }
@Override public String addEntryListener(EntryListener listener, Predicate<K, V> predicate, K key, boolean includeValue) { return map.addEntryListener(listener, predicate, key, includeValue); }
@Override public String addLocalEntryListener(EntryListener listener) { return null; }
@Override public String addLocalEntryListener(EntryListener listener, Predicate predicate, boolean includeValue) { return null; }
@Override public String addLocalEntryListener(EntryListener listener, Predicate predicate, Object key, boolean includeValue) { return null; }
@Override public String addEntryListener(EntryListener listener, boolean includeValue) { return null; }
@Override public String addEntryListener(EntryListener listener, Object key, boolean includeValue) { return null; }
@Override public String addEntryListener(EntryListener listener, Predicate predicate, boolean includeValue) { return null; }
@Override public String addEntryListener(EntryListener listener, Predicate predicate, Object key, boolean includeValue) { return null; }
public void addEntryListener(EntryListener listener, boolean includeValue) { registrations.put(listener, map.addEntryListener(listener, includeValue)); }