Committed by
Yuta Higuchi
LinkStores: Concurrent readable {src, dst}Links
resolves ONOS-473 Change-Id: Id9c684ded610b30b059c3d83097b0fe4a7f7350b
Showing
2 changed files
with
23 additions
and
4 deletions
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | package org.onosproject.store.link.impl; | 16 | package org.onosproject.store.link.impl; |
17 | 17 | ||
18 | import java.io.IOException; | 18 | import java.io.IOException; |
19 | +import java.util.Collection; | ||
19 | import java.util.Collections; | 20 | import java.util.Collections; |
20 | import java.util.HashMap; | 21 | import java.util.HashMap; |
21 | import java.util.HashSet; | 22 | import java.util.HashSet; |
... | @@ -71,9 +72,10 @@ import org.slf4j.Logger; | ... | @@ -71,9 +72,10 @@ import org.slf4j.Logger; |
71 | 72 | ||
72 | import com.google.common.base.Function; | 73 | import com.google.common.base.Function; |
73 | import com.google.common.collect.FluentIterable; | 74 | import com.google.common.collect.FluentIterable; |
74 | -import com.google.common.collect.HashMultimap; | ||
75 | import com.google.common.collect.ImmutableList; | 75 | import com.google.common.collect.ImmutableList; |
76 | +import com.google.common.collect.Multimaps; | ||
76 | import com.google.common.collect.SetMultimap; | 77 | import com.google.common.collect.SetMultimap; |
78 | +import com.google.common.collect.Sets; | ||
77 | 79 | ||
78 | import static com.google.common.base.Preconditions.checkNotNull; | 80 | import static com.google.common.base.Preconditions.checkNotNull; |
79 | import static com.google.common.base.Predicates.notNull; | 81 | import static com.google.common.base.Predicates.notNull; |
... | @@ -502,8 +504,15 @@ public class GossipLinkStore | ... | @@ -502,8 +504,15 @@ public class GossipLinkStore |
502 | } | 504 | } |
503 | } | 505 | } |
504 | 506 | ||
507 | + /** | ||
508 | + * Creates concurrent readable, synchronized HashMultimap. | ||
509 | + * | ||
510 | + * @return SetMultimap | ||
511 | + */ | ||
505 | private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { | 512 | private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { |
506 | - return synchronizedSetMultimap(HashMultimap.<K, V>create()); | 513 | + return synchronizedSetMultimap( |
514 | + Multimaps.newSetMultimap(new ConcurrentHashMap<K, Collection<V>>(), | ||
515 | + () -> Sets.newConcurrentHashSet())); | ||
507 | } | 516 | } |
508 | 517 | ||
509 | /** | 518 | /** | ... | ... |
... | @@ -17,8 +17,10 @@ package org.onosproject.store.trivial.impl; | ... | @@ -17,8 +17,10 @@ package org.onosproject.store.trivial.impl; |
17 | 17 | ||
18 | import com.google.common.base.Function; | 18 | import com.google.common.base.Function; |
19 | import com.google.common.collect.FluentIterable; | 19 | import com.google.common.collect.FluentIterable; |
20 | -import com.google.common.collect.HashMultimap; | 20 | +import com.google.common.collect.Multimaps; |
21 | import com.google.common.collect.SetMultimap; | 21 | import com.google.common.collect.SetMultimap; |
22 | +import com.google.common.collect.Sets; | ||
23 | + | ||
22 | import org.apache.felix.scr.annotations.Activate; | 24 | import org.apache.felix.scr.annotations.Activate; |
23 | import org.apache.felix.scr.annotations.Component; | 25 | import org.apache.felix.scr.annotations.Component; |
24 | import org.apache.felix.scr.annotations.Deactivate; | 26 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -42,6 +44,7 @@ import org.onosproject.net.provider.ProviderId; | ... | @@ -42,6 +44,7 @@ import org.onosproject.net.provider.ProviderId; |
42 | import org.onosproject.store.AbstractStore; | 44 | import org.onosproject.store.AbstractStore; |
43 | import org.slf4j.Logger; | 45 | import org.slf4j.Logger; |
44 | 46 | ||
47 | +import java.util.Collection; | ||
45 | import java.util.Collections; | 48 | import java.util.Collections; |
46 | import java.util.HashMap; | 49 | import java.util.HashMap; |
47 | import java.util.HashSet; | 50 | import java.util.HashSet; |
... | @@ -266,8 +269,15 @@ public class SimpleLinkStore | ... | @@ -266,8 +269,15 @@ public class SimpleLinkStore |
266 | } | 269 | } |
267 | } | 270 | } |
268 | 271 | ||
272 | + /** | ||
273 | + * Creates concurrent readable, synchronized HashMultimap. | ||
274 | + * | ||
275 | + * @return SetMultimap | ||
276 | + */ | ||
269 | private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { | 277 | private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { |
270 | - return synchronizedSetMultimap(HashMultimap.<K, V>create()); | 278 | + return synchronizedSetMultimap( |
279 | + Multimaps.newSetMultimap(new ConcurrentHashMap<K, Collection<V>>(), | ||
280 | + () -> Sets.newConcurrentHashSet())); | ||
271 | } | 281 | } |
272 | 282 | ||
273 | /** | 283 | /** | ... | ... |
-
Please register or login to post a comment