@Test public void testDestroy() throws Exception { clusterCommunicator.removeSubscriber(UPDATE_MESSAGE_SUBJECT); clusterCommunicator.removeSubscriber(UPDATE_REQUEST_SUBJECT); clusterCommunicator.removeSubscriber(ANTI_ENTROPY_MESSAGE_SUBJECT); replay(clusterCommunicator); ecMap.destroy(); verify(clusterCommunicator); try { ecMap.get(KEY1); fail("get after destroy should throw exception"); } catch (IllegalStateException e) { assertTrue(true); } try { ecMap.put(KEY1, VALUE1); fail("put after destroy should throw exception"); } catch (IllegalStateException e) { assertTrue(true); } }
@Override public CompletableFuture<Void> destroy() { destroyed = true; executor.shutdown(); backgroundExecutor.shutdown(); communicationExecutor.shutdown(); listeners.clear(); clusterCommunicator.removeSubscriber(updateMessageSubject); clusterCommunicator.removeSubscriber(updateRequestSubject); clusterCommunicator.removeSubscriber(antiEntropyAdvertisementSubject); return CompletableFuture.completedFuture(null); }
EventuallyConsistentMapImpl implements EventuallyConsistentMap<K, V> { @Override public CompletableFuture<Void> destroy() { destroyed = true; executor.shutdown(); backgroundExecutor.shutdown(); communicationExecutor.shutdown(); listeners.clear(); clusterCommunicator.removeSubscriber(updateMessageSubject); clusterCommunicator.removeSubscriber(updateRequestSubject); clusterCommunicator.removeSubscriber(antiEntropyAdvertisementSubject); return CompletableFuture.completedFuture(null); } }
EventuallyConsistentMapImpl implements EventuallyConsistentMap<K, V> { @Override public CompletableFuture<Void> destroy() { destroyed = true; executor.shutdown(); backgroundExecutor.shutdown(); communicationExecutor.shutdown(); listeners.clear(); clusterCommunicator.removeSubscriber(updateMessageSubject); clusterCommunicator.removeSubscriber(updateRequestSubject); clusterCommunicator.removeSubscriber(antiEntropyAdvertisementSubject); return CompletableFuture.completedFuture(null); } 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 CompletableFuture<Void> destroy() { destroyed = true; executor.shutdown(); backgroundExecutor.shutdown(); communicationExecutor.shutdown(); listeners.clear(); clusterCommunicator.removeSubscriber(updateMessageSubject); clusterCommunicator.removeSubscriber(updateRequestSubject); clusterCommunicator.removeSubscriber(antiEntropyAdvertisementSubject); return CompletableFuture.completedFuture(null); } 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 CompletableFuture<Void> destroy() { destroyed = true; executor.shutdown(); backgroundExecutor.shutdown(); communicationExecutor.shutdown(); listeners.clear(); clusterCommunicator.removeSubscriber(updateMessageSubject); clusterCommunicator.removeSubscriber(updateRequestSubject); clusterCommunicator.removeSubscriber(antiEntropyAdvertisementSubject); return CompletableFuture.completedFuture(null); } 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();  }