mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-23 13:21:21 +02:00
Synchronize Multimap access.
- ONOS-2626 Change-Id: I730b310e67ab858999a16565b05c2904d9d9481c
This commit is contained in:
parent
afce2ae599
commit
fe2122ce52
@ -68,7 +68,6 @@ import org.onosproject.store.service.StorageService;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Multimaps;
|
import com.google.common.collect.Multimaps;
|
||||||
import com.google.common.collect.SetMultimap;
|
import com.google.common.collect.SetMultimap;
|
||||||
@ -258,17 +257,23 @@ public class ECHostStore
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Host> getConnectedHosts(ConnectPoint connectPoint) {
|
public Set<Host> getConnectedHosts(ConnectPoint connectPoint) {
|
||||||
return ImmutableSet.copyOf(locations.get(connectPoint));
|
synchronized (locations) {
|
||||||
|
return ImmutableSet.copyOf(locations.get(connectPoint));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Host> getConnectedHosts(DeviceId deviceId) {
|
public Set<Host> getConnectedHosts(DeviceId deviceId) {
|
||||||
return ImmutableMultimap.copyOf(locations)
|
Set<Host> filtered;
|
||||||
.entries()
|
synchronized (locations) {
|
||||||
.stream()
|
filtered = locations
|
||||||
.filter(entry -> entry.getKey().deviceId().equals(deviceId))
|
.entries()
|
||||||
.map(entry -> entry.getValue())
|
.stream()
|
||||||
.collect(Collectors.toSet());
|
.filter(entry -> entry.getKey().deviceId().equals(deviceId))
|
||||||
|
.map(entry -> entry.getValue())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
return ImmutableSet.copyOf(filtered);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Host> filter(Collection<DefaultHost> collection, Predicate<DefaultHost> predicate) {
|
private Set<Host> filter(Collection<DefaultHost> collection, Predicate<DefaultHost> predicate) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user