Madan Jampani
Committed by Gerrit Code Review

Added destroy() method to DistributedPrimitive interface

Implement replace method in ConsistentMap
Using Versioned#valueOrNull in place of Versioned#valueOrElse where appropriate

Change-Id: Ief3f3547d589d35f5c821a1c47035f91078e8316
...@@ -112,9 +112,4 @@ public class VtnEventuallyConsistentMapAdapter<K, V> implements EventuallyConsis ...@@ -112,9 +112,4 @@ public class VtnEventuallyConsistentMapAdapter<K, V> implements EventuallyConsis
112 public void removeListener(EventuallyConsistentMapListener<K, V> listener) { 112 public void removeListener(EventuallyConsistentMapListener<K, V> listener) {
113 113
114 } 114 }
115 -
116 - @Override
117 - public void destroy() {
118 -
119 - }
120 } 115 }
......
...@@ -42,6 +42,11 @@ public class DefaultPartition implements Partition { ...@@ -42,6 +42,11 @@ public class DefaultPartition implements Partition {
42 this.members = ImmutableSet.copyOf(members); 42 this.members = ImmutableSet.copyOf(members);
43 } 43 }
44 44
45 + public DefaultPartition(Partition other) {
46 + this.id = checkNotNull(other.getId());
47 + this.members = ImmutableSet.copyOf(other.getMembers());
48 + }
49 +
45 @Override 50 @Override
46 public PartitionId getId() { 51 public PartitionId getId() {
47 return this.id; 52 return this.id;
......
...@@ -37,12 +37,12 @@ import java.util.function.Predicate; ...@@ -37,12 +37,12 @@ import java.util.function.Predicate;
37 * a temporary disruption in network connectivity between participating nodes 37 * a temporary disruption in network connectivity between participating nodes
38 * or due to a node being temporarily down. 38 * or due to a node being temporarily down.
39 * </p><p> 39 * </p><p>
40 - * All values stored in this map are versioned and the API supports optimistic 40 + * All values stored in this map are {@link Versioned versioned} and the API
41 - * concurrency by allowing conditional updates that take into consideration 41 + * supports optimistic concurrency by allowing conditional updates that take into
42 - * the version or value that was previously read. 42 + * consideration the version or value that was previously read.
43 * </p><p> 43 * </p><p>
44 * This map does not allow null values. All methods can throw a ConsistentMapException 44 * This map does not allow null values. All methods can throw a ConsistentMapException
45 - * (which extends RuntimeException) to indicate failures. 45 + * (which extends {@code RuntimeException}) to indicate failures.
46 * <p> 46 * <p>
47 * All methods of this interface return a {@link CompletableFuture future} immediately 47 * All methods of this interface return a {@link CompletableFuture future} immediately
48 * after a successful invocation. The operation itself is executed asynchronous and 48 * after a successful invocation. The operation itself is executed asynchronous and
...@@ -56,6 +56,11 @@ public interface AsyncConsistentMap<K, V> extends DistributedPrimitive { ...@@ -56,6 +56,11 @@ public interface AsyncConsistentMap<K, V> extends DistributedPrimitive {
56 return DistributedPrimitive.Type.CONSISTENT_MAP; 56 return DistributedPrimitive.Type.CONSISTENT_MAP;
57 } 57 }
58 58
59 + @Override
60 + default CompletableFuture<Void> destroy() {
61 + return clear();
62 + }
63 +
59 /** 64 /**
60 * Returns the number of entries in the map. 65 * Returns the number of entries in the map.
61 * 66 *
......
...@@ -25,24 +25,11 @@ import java.util.function.Function; ...@@ -25,24 +25,11 @@ import java.util.function.Function;
25 import java.util.function.Predicate; 25 import java.util.function.Predicate;
26 26
27 /** 27 /**
28 - * A distributed, strongly consistent key-value map. 28 + * {@code ConsistentMap} provides the same functionality as {@link AsyncConsistentMap} with
29 - * <p> 29 + * the only difference that all its methods block until the corresponding operation completes.
30 - * This map offers strong read-after-update (where update == create/update/delete)
31 - * consistency. All operations to the map are serialized and applied in a consistent
32 - * manner.
33 - * <p>
34 - * The stronger consistency comes at the expense of availability in
35 - * the event of a network partition. A network partition can be either due to
36 - * a temporary disruption in network connectivity between participating nodes
37 - * or due to a node being temporarily down.
38 - * </p><p>
39 - * All values stored in this map are versioned and the API supports optimistic
40 - * concurrency by allowing conditional updates that take into consideration
41 - * the version or value that was previously read.
42 - * </p><p>
43 - * This map does not allow null values. All methods can throw a ConsistentMapException
44 - * (which extends RuntimeException) to indicate failures.
45 * 30 *
31 + * @param <K> type of key
32 + * @param <V> type of value
46 */ 33 */
47 public interface ConsistentMap<K, V> extends DistributedPrimitive { 34 public interface ConsistentMap<K, V> extends DistributedPrimitive {
48 35
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
15 */ 15 */
16 package org.onosproject.store.service; 16 package org.onosproject.store.service;
17 17
18 +import java.util.concurrent.CompletableFuture;
19 +
18 import org.onosproject.core.ApplicationId; 20 import org.onosproject.core.ApplicationId;
19 21
20 /** 22 /**
...@@ -76,4 +78,15 @@ public interface DistributedPrimitive { ...@@ -76,4 +78,15 @@ public interface DistributedPrimitive {
76 default ApplicationId applicationId() { 78 default ApplicationId applicationId() {
77 return null; 79 return null;
78 } 80 }
81 +
82 + /**
83 + * Purges state associated with this primitive.
84 + * <p>
85 + * Implementations can override and provide appropriate clean up logic for purging
86 + * any state state associated with the primitive. Whether modifications made within the
87 + * destroy method have local or global visibility is left unspecified.
88 + */
89 + default CompletableFuture<Void> destroy() {
90 + return CompletableFuture.completedFuture(null);
91 + }
79 } 92 }
......
...@@ -201,12 +201,4 @@ public interface EventuallyConsistentMap<K, V> extends DistributedPrimitive { ...@@ -201,12 +201,4 @@ public interface EventuallyConsistentMap<K, V> extends DistributedPrimitive {
201 * @param listener listener to deregister for events 201 * @param listener listener to deregister for events
202 */ 202 */
203 void removeListener(EventuallyConsistentMapListener<K, V> listener); 203 void removeListener(EventuallyConsistentMapListener<K, V> listener);
204 -
205 - /**
206 - * Shuts down the map and breaks communication between different instances.
207 - * This allows the map objects to be cleaned up and garbage collected.
208 - * Calls to any methods on the map subsequent to calling destroy() will
209 - * throw a {@link java.lang.RuntimeException}.
210 - */
211 - void destroy();
212 } 204 }
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
15 */ 15 */
16 package org.onosproject.store.service; 16 package org.onosproject.store.service;
17 17
18 +import java.util.concurrent.CompletableFuture;
19 +
18 /** 20 /**
19 * DistributedPrimitive that is a synchronous (blocking) version of 21 * DistributedPrimitive that is a synchronous (blocking) version of
20 * another. 22 * another.
...@@ -38,4 +40,9 @@ public abstract class Synchronous<T extends DistributedPrimitive> implements Dis ...@@ -38,4 +40,9 @@ public abstract class Synchronous<T extends DistributedPrimitive> implements Dis
38 public Type type() { 40 public Type type() {
39 return primitive.type(); 41 return primitive.type();
40 } 42 }
43 +
44 + @Override
45 + public CompletableFuture<Void> destroy() {
46 + return primitive.destroy();
47 + }
41 } 48 }
......
...@@ -18,6 +18,7 @@ package org.onosproject.store.service; ...@@ -18,6 +18,7 @@ package org.onosproject.store.service;
18 import java.util.Collection; 18 import java.util.Collection;
19 import java.util.Map; 19 import java.util.Map;
20 import java.util.Set; 20 import java.util.Set;
21 +import java.util.concurrent.CompletableFuture;
21 import java.util.function.BiFunction; 22 import java.util.function.BiFunction;
22 23
23 import org.onosproject.store.service.DistributedPrimitive.Type; 24 import org.onosproject.store.service.DistributedPrimitive.Type;
...@@ -118,7 +119,7 @@ public class EventuallyConsistentMapAdapter<K, V> implements EventuallyConsisten ...@@ -118,7 +119,7 @@ public class EventuallyConsistentMapAdapter<K, V> implements EventuallyConsisten
118 } 119 }
119 120
120 @Override 121 @Override
121 - public void destroy() { 122 + public CompletableFuture<Void> destroy() {
122 - 123 + return CompletableFuture.completedFuture(null);
123 } 124 }
124 } 125 }
......
...@@ -30,7 +30,7 @@ import com.google.common.collect.Collections2; ...@@ -30,7 +30,7 @@ import com.google.common.collect.Collections2;
30 import com.google.common.collect.Maps; 30 import com.google.common.collect.Maps;
31 31
32 /** 32 /**
33 - * Standard java Map backed by a ConsistentMap. 33 + * Standard java {@link Map} backed by a {@link ConsistentMap}.
34 * 34 *
35 * @param <K> key type 35 * @param <K> key type
36 * @param <V> value type 36 * @param <V> value type
...@@ -65,7 +65,7 @@ public final class ConsistentMapBackedJavaMap<K, V> implements Map<K, V> { ...@@ -65,7 +65,7 @@ public final class ConsistentMapBackedJavaMap<K, V> implements Map<K, V> {
65 65
66 @Override 66 @Override
67 public V get(Object key) { 67 public V get(Object key) {
68 - return Versioned.valueOrElse(backingMap.get((K) key), null); 68 + return Versioned.valueOrNull(backingMap.get((K) key));
69 } 69 }
70 70
71 @Override 71 @Override
...@@ -75,17 +75,17 @@ public final class ConsistentMapBackedJavaMap<K, V> implements Map<K, V> { ...@@ -75,17 +75,17 @@ public final class ConsistentMapBackedJavaMap<K, V> implements Map<K, V> {
75 75
76 @Override 76 @Override
77 public V put(K key, V value) { 77 public V put(K key, V value) {
78 - return Versioned.valueOrElse(backingMap.put(key, value), null); 78 + return Versioned.valueOrNull(backingMap.put(key, value));
79 } 79 }
80 80
81 @Override 81 @Override
82 public V putIfAbsent(K key, V value) { 82 public V putIfAbsent(K key, V value) {
83 - return Versioned.valueOrElse(backingMap.putIfAbsent(key, value), null); 83 + return Versioned.valueOrNull(backingMap.putIfAbsent(key, value));
84 } 84 }
85 85
86 @Override 86 @Override
87 public V remove(Object key) { 87 public V remove(Object key) {
88 - return Versioned.valueOrElse(backingMap.remove((K) key), null); 88 + return Versioned.valueOrNull(backingMap.remove((K) key));
89 } 89 }
90 90
91 @Override 91 @Override
...@@ -95,7 +95,7 @@ public final class ConsistentMapBackedJavaMap<K, V> implements Map<K, V> { ...@@ -95,7 +95,7 @@ public final class ConsistentMapBackedJavaMap<K, V> implements Map<K, V> {
95 95
96 @Override 96 @Override
97 public V replace(K key, V value) { 97 public V replace(K key, V value) {
98 - throw new UnsupportedOperationException(); 98 + return Versioned.valueOrNull(backingMap.replace(key, value));
99 } 99 }
100 100
101 @Override 101 @Override
...@@ -117,17 +117,17 @@ public final class ConsistentMapBackedJavaMap<K, V> implements Map<K, V> { ...@@ -117,17 +117,17 @@ public final class ConsistentMapBackedJavaMap<K, V> implements Map<K, V> {
117 117
118 @Override 118 @Override
119 public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { 119 public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
120 - return Versioned.valueOrElse(backingMap.compute(key, remappingFunction), null); 120 + return Versioned.valueOrNull(backingMap.compute(key, remappingFunction));
121 } 121 }
122 122
123 @Override 123 @Override
124 public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) { 124 public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
125 - return Versioned.valueOrElse(backingMap.computeIfAbsent(key, mappingFunction), null); 125 + return Versioned.valueOrNull(backingMap.computeIfAbsent(key, mappingFunction));
126 } 126 }
127 127
128 @Override 128 @Override
129 public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { 129 public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
130 - return Versioned.valueOrElse(backingMap.computeIfPresent(key, remappingFunction), null); 130 + return Versioned.valueOrNull(backingMap.computeIfPresent(key, remappingFunction));
131 } 131 }
132 132
133 @Override 133 @Override
......
...@@ -16,24 +16,10 @@ ...@@ -16,24 +16,10 @@
16 16
17 package org.onosproject.store.primitives.impl; 17 package org.onosproject.store.primitives.impl;
18 18
19 -import com.google.common.cache.CacheBuilder; 19 +import static com.google.common.base.Preconditions.checkNotNull;
20 -import com.google.common.cache.CacheLoader; 20 +import static org.onosproject.store.primitives.impl.StateMachineUpdate.Target.MAP_UPDATE;
21 -import com.google.common.cache.LoadingCache; 21 +import static org.onosproject.store.primitives.impl.StateMachineUpdate.Target.TX_COMMIT;
22 -import com.google.common.collect.Maps; 22 +import static org.slf4j.LoggerFactory.getLogger;
23 -
24 -import org.onlab.util.HexString;
25 -import org.onlab.util.Match;
26 -import org.onlab.util.SharedExecutors;
27 -import org.onlab.util.Tools;
28 -import org.onosproject.core.ApplicationId;
29 -import org.onosproject.store.service.AsyncConsistentMap;
30 -import org.onosproject.store.service.ConsistentMapException;
31 -import org.onosproject.store.service.ConsistentMapException.ConcurrentModification;
32 -import org.onosproject.store.service.MapEvent;
33 -import org.onosproject.store.service.MapEventListener;
34 -import org.onosproject.store.service.Serializer;
35 -import org.onosproject.store.service.Versioned;
36 -import org.slf4j.Logger;
37 23
38 import java.util.Collection; 24 import java.util.Collection;
39 import java.util.Collections; 25 import java.util.Collections;
...@@ -49,10 +35,24 @@ import java.util.function.Function; ...@@ -49,10 +35,24 @@ import java.util.function.Function;
49 import java.util.function.Predicate; 35 import java.util.function.Predicate;
50 import java.util.stream.Collectors; 36 import java.util.stream.Collectors;
51 37
52 -import static com.google.common.base.Preconditions.checkNotNull; 38 +import org.onlab.util.HexString;
53 -import static org.onosproject.store.primitives.impl.StateMachineUpdate.Target.MAP_UPDATE; 39 +import org.onlab.util.Match;
54 -import static org.onosproject.store.primitives.impl.StateMachineUpdate.Target.TX_COMMIT; 40 +import org.onlab.util.SharedExecutors;
55 -import static org.slf4j.LoggerFactory.getLogger; 41 +import org.onlab.util.Tools;
42 +import org.onosproject.core.ApplicationId;
43 +import org.onosproject.store.service.AsyncConsistentMap;
44 +import org.onosproject.store.service.ConsistentMapException;
45 +import org.onosproject.store.service.ConsistentMapException.ConcurrentModification;
46 +import org.onosproject.store.service.MapEvent;
47 +import org.onosproject.store.service.MapEventListener;
48 +import org.onosproject.store.service.Serializer;
49 +import org.onosproject.store.service.Versioned;
50 +import org.slf4j.Logger;
51 +
52 +import com.google.common.cache.CacheBuilder;
53 +import com.google.common.cache.CacheLoader;
54 +import com.google.common.cache.LoadingCache;
55 +import com.google.common.collect.Maps;
56 56
57 /** 57 /**
58 * AsyncConsistentMap implementation that is backed by a Raft consensus 58 * AsyncConsistentMap implementation that is backed by a Raft consensus
......
...@@ -19,6 +19,7 @@ package org.onosproject.store.primitives.impl; ...@@ -19,6 +19,7 @@ package org.onosproject.store.primitives.impl;
19 import java.util.Collection; 19 import java.util.Collection;
20 import java.util.Map; 20 import java.util.Map;
21 import java.util.Map.Entry; 21 import java.util.Map.Entry;
22 +import java.util.Set;
22 import java.util.concurrent.CompletableFuture; 23 import java.util.concurrent.CompletableFuture;
23 import java.util.concurrent.ExecutionException; 24 import java.util.concurrent.ExecutionException;
24 import java.util.concurrent.TimeUnit; 25 import java.util.concurrent.TimeUnit;
...@@ -26,7 +27,6 @@ import java.util.concurrent.TimeoutException; ...@@ -26,7 +27,6 @@ import java.util.concurrent.TimeoutException;
26 import java.util.function.BiFunction; 27 import java.util.function.BiFunction;
27 import java.util.function.Function; 28 import java.util.function.Function;
28 import java.util.function.Predicate; 29 import java.util.function.Predicate;
29 -import java.util.Set;
30 30
31 import org.onosproject.store.service.AsyncConsistentMap; 31 import org.onosproject.store.service.AsyncConsistentMap;
32 import org.onosproject.store.service.ConsistentMap; 32 import org.onosproject.store.service.ConsistentMap;
...@@ -36,8 +36,7 @@ import org.onosproject.store.service.Synchronous; ...@@ -36,8 +36,7 @@ import org.onosproject.store.service.Synchronous;
36 import org.onosproject.store.service.Versioned; 36 import org.onosproject.store.service.Versioned;
37 37
38 /** 38 /**
39 - * ConsistentMap implementation that is backed by a Raft consensus 39 + * Default implementation of {@code ConsistentMap}.
40 - * based database.
41 * 40 *
42 * @param <K> type of key. 41 * @param <K> type of key.
43 * @param <V> type of value. 42 * @param <V> type of value.
...@@ -46,10 +45,10 @@ public class DefaultConsistentMap<K, V> extends Synchronous<AsyncConsistentMap<K ...@@ -46,10 +45,10 @@ public class DefaultConsistentMap<K, V> extends Synchronous<AsyncConsistentMap<K
46 45
47 private static final int OPERATION_TIMEOUT_MILLIS = 5000; 46 private static final int OPERATION_TIMEOUT_MILLIS = 5000;
48 47
49 - private final DefaultAsyncConsistentMap<K, V> asyncMap; 48 + private final AsyncConsistentMap<K, V> asyncMap;
50 private Map<K, V> javaMap; 49 private Map<K, V> javaMap;
51 50
52 - public DefaultConsistentMap(DefaultAsyncConsistentMap<K, V> asyncMap) { 51 + public DefaultConsistentMap(AsyncConsistentMap<K, V> asyncMap) {
53 super(asyncMap); 52 super(asyncMap);
54 this.asyncMap = asyncMap; 53 this.asyncMap = asyncMap;
55 } 54 }
...@@ -169,31 +168,14 @@ public class DefaultConsistentMap<K, V> extends Synchronous<AsyncConsistentMap<K ...@@ -169,31 +168,14 @@ public class DefaultConsistentMap<K, V> extends Synchronous<AsyncConsistentMap<K
169 return complete(asyncMap.replace(key, oldVersion, newValue)); 168 return complete(asyncMap.replace(key, oldVersion, newValue));
170 } 169 }
171 170
172 - private static <T> T complete(CompletableFuture<T> future) {
173 - try {
174 - return future.get(OPERATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
175 - } catch (InterruptedException e) {
176 - Thread.currentThread().interrupt();
177 - throw new ConsistentMapException.Interrupted();
178 - } catch (TimeoutException e) {
179 - throw new ConsistentMapException.Timeout();
180 - } catch (ExecutionException e) {
181 - if (e.getCause() instanceof ConsistentMapException) {
182 - throw (ConsistentMapException) e.getCause();
183 - } else {
184 - throw new ConsistentMapException(e.getCause());
185 - }
186 - }
187 - }
188 -
189 @Override 171 @Override
190 public void addListener(MapEventListener<K, V> listener) { 172 public void addListener(MapEventListener<K, V> listener) {
191 - asyncMap.addListener(listener); 173 + complete(asyncMap.addListener(listener));
192 } 174 }
193 175
194 @Override 176 @Override
195 public void removeListener(MapEventListener<K, V> listener) { 177 public void removeListener(MapEventListener<K, V> listener) {
196 - asyncMap.addListener(listener); 178 + complete(asyncMap.addListener(listener));
197 } 179 }
198 180
199 @Override 181 @Override
...@@ -205,4 +187,21 @@ public class DefaultConsistentMap<K, V> extends Synchronous<AsyncConsistentMap<K ...@@ -205,4 +187,21 @@ public class DefaultConsistentMap<K, V> extends Synchronous<AsyncConsistentMap<K
205 } 187 }
206 return javaMap; 188 return javaMap;
207 } 189 }
190 +
191 + private static <T> T complete(CompletableFuture<T> future) {
192 + try {
193 + return future.get(OPERATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
194 + } catch (InterruptedException e) {
195 + Thread.currentThread().interrupt();
196 + throw new ConsistentMapException.Interrupted();
197 + } catch (TimeoutException e) {
198 + throw new ConsistentMapException.Timeout();
199 + } catch (ExecutionException e) {
200 + if (e.getCause() instanceof ConsistentMapException) {
201 + throw (ConsistentMapException) e.getCause();
202 + } else {
203 + throw new ConsistentMapException(e.getCause());
204 + }
205 + }
206 + }
208 } 207 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -15,12 +15,6 @@ ...@@ -15,12 +15,6 @@
15 */ 15 */
16 package org.onosproject.store.primitives.impl; 16 package org.onosproject.store.primitives.impl;
17 17
18 -import org.onosproject.store.service.AsyncDistributedSet;
19 -import org.onosproject.store.service.ConsistentMapException;
20 -import org.onosproject.store.service.DistributedSet;
21 -import org.onosproject.store.service.SetEventListener;
22 -import org.onosproject.store.service.Synchronous;
23 -
24 import java.lang.reflect.Array; 18 import java.lang.reflect.Array;
25 import java.util.Collection; 19 import java.util.Collection;
26 import java.util.Iterator; 20 import java.util.Iterator;
...@@ -29,6 +23,12 @@ import java.util.concurrent.ExecutionException; ...@@ -29,6 +23,12 @@ import java.util.concurrent.ExecutionException;
29 import java.util.concurrent.TimeUnit; 23 import java.util.concurrent.TimeUnit;
30 import java.util.concurrent.TimeoutException; 24 import java.util.concurrent.TimeoutException;
31 25
26 +import org.onosproject.store.service.AsyncDistributedSet;
27 +import org.onosproject.store.service.DistributedSet;
28 +import org.onosproject.store.service.SetEventListener;
29 +import org.onosproject.store.service.StorageException;
30 +import org.onosproject.store.service.Synchronous;
31 +
32 /** 32 /**
33 * Implementation of {@link DistributedSet} that merely delegates to a {@link AsyncDistributedSet} 33 * Implementation of {@link DistributedSet} that merely delegates to a {@link AsyncDistributedSet}
34 * and waits for the operation to complete. 34 * and waits for the operation to complete.
...@@ -51,14 +51,14 @@ public class DefaultDistributedSet<E> extends Synchronous<AsyncDistributedSet<E> ...@@ -51,14 +51,14 @@ public class DefaultDistributedSet<E> extends Synchronous<AsyncDistributedSet<E>
51 return future.get(OPERATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); 51 return future.get(OPERATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
52 } catch (InterruptedException e) { 52 } catch (InterruptedException e) {
53 Thread.currentThread().interrupt(); 53 Thread.currentThread().interrupt();
54 - throw new ConsistentMapException.Interrupted(); 54 + throw new StorageException.Interrupted();
55 } catch (TimeoutException e) { 55 } catch (TimeoutException e) {
56 - throw new ConsistentMapException.Timeout(); 56 + throw new StorageException.Timeout();
57 } catch (ExecutionException e) { 57 } catch (ExecutionException e) {
58 - if (e.getCause() instanceof ConsistentMapException) { 58 + if (e.getCause() instanceof StorageException) {
59 - throw (ConsistentMapException) e.getCause(); 59 + throw (StorageException) e.getCause();
60 } else { 60 } else {
61 - throw new ConsistentMapException(e.getCause()); 61 + throw new StorageException(e.getCause());
62 } 62 }
63 } 63 }
64 } 64 }
......
...@@ -31,6 +31,7 @@ import java.util.Objects; ...@@ -31,6 +31,7 @@ import java.util.Objects;
31 import java.util.Optional; 31 import java.util.Optional;
32 import java.util.Set; 32 import java.util.Set;
33 import java.util.Timer; 33 import java.util.Timer;
34 +import java.util.concurrent.CompletableFuture;
34 import java.util.concurrent.ExecutorService; 35 import java.util.concurrent.ExecutorService;
35 import java.util.concurrent.Executors; 36 import java.util.concurrent.Executors;
36 import java.util.concurrent.ScheduledExecutorService; 37 import java.util.concurrent.ScheduledExecutorService;
...@@ -502,7 +503,7 @@ public class EventuallyConsistentMapImpl<K, V> ...@@ -502,7 +503,7 @@ public class EventuallyConsistentMapImpl<K, V>
502 } 503 }
503 504
504 @Override 505 @Override
505 - public void destroy() { 506 + public CompletableFuture<Void> destroy() {
506 destroyed = true; 507 destroyed = true;
507 508
508 executor.shutdown(); 509 executor.shutdown();
...@@ -513,6 +514,7 @@ public class EventuallyConsistentMapImpl<K, V> ...@@ -513,6 +514,7 @@ public class EventuallyConsistentMapImpl<K, V>
513 514
514 clusterCommunicator.removeSubscriber(updateMessageSubject); 515 clusterCommunicator.removeSubscriber(updateMessageSubject);
515 clusterCommunicator.removeSubscriber(antiEntropyAdvertisementSubject); 516 clusterCommunicator.removeSubscriber(antiEntropyAdvertisementSubject);
517 + return CompletableFuture.completedFuture(null);
516 } 518 }
517 519
518 private void notifyListeners(EventuallyConsistentMapEvent<K, V> event) { 520 private void notifyListeners(EventuallyConsistentMapEvent<K, V> event) {
......