LinkStores: Concurrent readable {src, dst}Links
resolves ONOS-473
[Merged from master]
Change-Id: Id9c684ded610b30b059c3d83097b0fe4a7f7350b
(cherry picked from commit 800fac669f61e0e6f8d620c8dae563bc3fe0c4fd)
diff --git a/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java b/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java
index 01bdc36..2b6c1c8 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java
@@ -16,6 +16,7 @@
package org.onosproject.store.link.impl;
import java.io.IOException;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -71,9 +72,10 @@
import com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
-import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap;
+import com.google.common.collect.Sets;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Predicates.notNull;
@@ -502,8 +504,15 @@
}
}
+ /**
+ * Creates concurrent readable, synchronized HashMultimap.
+ *
+ * @return SetMultimap
+ */
private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() {
- return synchronizedSetMultimap(HashMultimap.<K, V>create());
+ return synchronizedSetMultimap(
+ Multimaps.newSetMultimap(new ConcurrentHashMap<K, Collection<V>>(),
+ () -> Sets.newConcurrentHashSet()));
}
/**
diff --git a/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleLinkStore.java b/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleLinkStore.java
index c553dfa..7d58f12 100644
--- a/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleLinkStore.java
+++ b/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleLinkStore.java
@@ -17,8 +17,10 @@
import com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
-import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap;
+import com.google.common.collect.Sets;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -42,6 +44,7 @@
import org.onosproject.store.AbstractStore;
import org.slf4j.Logger;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -266,8 +269,15 @@
}
}
+ /**
+ * Creates concurrent readable, synchronized HashMultimap.
+ *
+ * @return SetMultimap
+ */
private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() {
- return synchronizedSetMultimap(HashMultimap.<K, V>create());
+ return synchronizedSetMultimap(
+ Multimaps.newSetMultimap(new ConcurrentHashMap<K, Collection<V>>(),
+ () -> Sets.newConcurrentHashSet()));
}
/**