@Test public void testEntrySet() throws Exception { expectPeerMessage(clusterCommunicator); assertTrue(ecMap.entrySet().isEmpty()); Map<String, String> expectedValues = new HashMap<>(); for (int i = 1; i <= 10; i++) { expectedValues.put("" + i, "value" + i); } expectedValues.entrySet().forEach(e -> ecMap.put(e.getKey(), e.getValue())); assertTrue(entrySetsAreEqual(expectedValues, ecMap.entrySet())); Map.Entry<String, String> first = expectedValues.entrySet().iterator().next(); expectedValues.put(first.getKey(), "new-value"); ecMap.put(first.getKey(), "new-value"); assertTrue(entrySetsAreEqual(expectedValues, ecMap.entrySet())); String removeKey = expectedValues.keySet().iterator().next(); expectedValues.remove(removeKey); ecMap.remove(removeKey); assertTrue(entrySetsAreEqual(expectedValues, ecMap.entrySet())); }
@Override public Set<Map.Entry<K, V>> entrySet() { checkState(!destroyed, destroyedMessage); return Maps.filterValues(items, MapValue::isAlive) .entrySet() .stream() .map(e -> Pair.of(e.getKey(), e.getValue().get())) .collect(Collectors.toSet()); }
EventuallyConsistentMapImpl implements EventuallyConsistentMap<K, V> { @Override public Set<Map.Entry<K, V>> entrySet() { checkState(!destroyed, destroyedMessage); return Maps.filterValues(items, MapValue::isAlive) .entrySet() .stream() .map(e -> Pair.of(e.getKey(), e.getValue().get())) .collect(Collectors.toSet()); } }
EventuallyConsistentMapImpl implements EventuallyConsistentMap<K, V> { @Override public Set<Map.Entry<K, V>> entrySet() { checkState(!destroyed, destroyedMessage); return Maps.filterValues(items, MapValue::isAlive) .entrySet() .stream() .map(e -> Pair.of(e.getKey(), e.getValue().get())) .collect(Collectors.toSet()); } EventuallyConsistentMapImpl(String mapName,
                                ClusterService clusterService,
                                ClusterCommunicationService clusterCommunicator,
                                KryoNamespace ns,
                                BiFunction<K, V, Timestamp> timestampProvider,
                                BiFunction<K, V, Collection<NodeId>> peerUpdateFunction,
                                ExecutorService eventExecutor,
                                ExecutorService communicationExecutor,
                                ScheduledExecutorService backgroundExecutor,
                                boolean tombstonesDisabled,
                                long antiEntropyPeriod,
                                TimeUnit antiEntropyTimeUnit,
                                boolean convergeFaster,
                                boolean persistent,
                                PersistenceService persistenceService); }
EventuallyConsistentMapImpl implements EventuallyConsistentMap<K, V> { @Override public Set<Map.Entry<K, V>> entrySet() { checkState(!destroyed, destroyedMessage); return Maps.filterValues(items, MapValue::isAlive) .entrySet() .stream() .map(e -> Pair.of(e.getKey(), e.getValue().get())) .collect(Collectors.toSet()); } EventuallyConsistentMapImpl(String mapName,
                                ClusterService clusterService,
                                ClusterCommunicationService clusterCommunicator,
                                KryoNamespace ns,
                                BiFunction<K, V, Timestamp> timestampProvider,
                                BiFunction<K, V, Collection<NodeId>> peerUpdateFunction,
                                ExecutorService eventExecutor,
                                ExecutorService communicationExecutor,
                                ScheduledExecutorService backgroundExecutor,
                                boolean tombstonesDisabled,
                                long antiEntropyPeriod,
                                TimeUnit antiEntropyTimeUnit,
                                boolean convergeFaster,
                                boolean persistent,
                                PersistenceService persistenceService); @Override String name(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(K key); @Override boolean containsValue(V value); @Override V get(K key); @Override void put(K key, V value); @Override V remove(K key); @Override void remove(K key, V value); @Override V compute(K key, BiFunction<K, V, V> recomputeFunction); @Override void putAll(Map<? extends K, ? extends V> m); @Override void clear(); @Override Set<K> keySet(); @Override Collection<V> values(); @Override Set<Map.Entry<K, V>> entrySet(); @Override void addListener(EventuallyConsistentMapListener<K, V> listener); @Override void removeListener(EventuallyConsistentMapListener<K, V> listener); @Override CompletableFuture<Void> destroy(); }
EventuallyConsistentMapImpl implements EventuallyConsistentMap<K, V> { @Override public Set<Map.Entry<K, V>> entrySet() { checkState(!destroyed, destroyedMessage); return Maps.filterValues(items, MapValue::isAlive) .entrySet() .stream() .map(e -> Pair.of(e.getKey(), e.getValue().get())) .collect(Collectors.toSet()); } EventuallyConsistentMapImpl(String mapName,
                                ClusterService clusterService,
                                ClusterCommunicationService clusterCommunicator,
                                KryoNamespace ns,
                                BiFunction<K, V, Timestamp> timestampProvider,
                                BiFunction<K, V, Collection<NodeId>> peerUpdateFunction,
                                ExecutorService eventExecutor,
                                ExecutorService communicationExecutor,
                                ScheduledExecutorService backgroundExecutor,
                                boolean tombstonesDisabled,
                                long antiEntropyPeriod,
                                TimeUnit antiEntropyTimeUnit,
                                boolean convergeFaster,
                                boolean persistent,
                                PersistenceService persistenceService); @Override String name(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(K key); @Override boolean containsValue(V value); @Override V get(K key); @Override void put(K key, V value); @Override V remove(K key); @Override void remove(K key, V value); @Override V compute(K key, BiFunction<K, V, V> recomputeFunction); @Override void putAll(Map<? extends K, ? extends V> m); @Override void clear(); @Override Set<K> keySet(); @Override Collection<V> values(); @Override Set<Map.Entry<K, V>> entrySet(); @Override void addListener(EventuallyConsistentMapListener<K, V> listener); @Override void removeListener(EventuallyConsistentMapListener<K, V> listener); @Override CompletableFuture<Void> destroy();  }