Yuta HIGUCHI
Committed by Pavlin Radoslavov

LinkStores: Concurrent readable {src, dst}Links

resolves ONOS-473

[Merged from master]

Change-Id: Id9c684ded610b30b059c3d83097b0fe4a7f7350b
(cherry picked from commit 800fac66)
......@@ -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 org.slf4j.Logger;
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 @@ public class GossipLinkStore
}
}
/**
* 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()));
}
/**
......
......@@ -17,8 +17,10 @@ package org.onosproject.store.trivial.impl;
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.net.provider.ProviderId;
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 @@ public class SimpleLinkStore
}
}
/**
* 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()));
}
/**
......