mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-27 14:21:48 +01:00
Workaround for ConcurrentModificationException
- Workaround fix for ONOS-1193 - If locking the whole link collection damages the performance, apply the fix suggested on GossipLinkStore comment. Change-Id: Idd4d2e5b8e3a50843fe7abd10a615cfbd9a16478
This commit is contained in:
parent
dc9d7b85be
commit
4d973ebae6
@ -246,6 +246,18 @@ public class GossipLinkStore
|
||||
@Override
|
||||
public Set<Link> getEgressLinks(ConnectPoint src) {
|
||||
Set<Link> egress = new HashSet<>();
|
||||
//
|
||||
// Change `srcLinks` to ConcurrentMap<DeviceId, (Concurrent)Set>
|
||||
// to remove this synchronized block, if we hit performance issue.
|
||||
// SetMultiMap#get returns wrapped collection to provide modifiable-view.
|
||||
// And the wrapped collection is not concurrent access safe.
|
||||
//
|
||||
// Our use case here does not require returned collection to be modifiable,
|
||||
// so the wrapped collection forces us to lock the whole multiset,
|
||||
// for benefit we don't need.
|
||||
//
|
||||
// Same applies to `dstLinks`
|
||||
synchronized (srcLinks) {
|
||||
for (LinkKey linkKey : srcLinks.get(src.deviceId())) {
|
||||
if (linkKey.src().equals(src)) {
|
||||
Link link = links.get(linkKey);
|
||||
@ -256,12 +268,14 @@ public class GossipLinkStore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return egress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Link> getIngressLinks(ConnectPoint dst) {
|
||||
Set<Link> ingress = new HashSet<>();
|
||||
synchronized (dstLinks) {
|
||||
for (LinkKey linkKey : dstLinks.get(dst.deviceId())) {
|
||||
if (linkKey.dst().equals(dst)) {
|
||||
Link link = links.get(linkKey);
|
||||
@ -272,6 +286,7 @@ public class GossipLinkStore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ingress;
|
||||
}
|
||||
|
||||
|
||||
@ -146,22 +146,26 @@ public class SimpleLinkStore
|
||||
@Override
|
||||
public Set<Link> getEgressLinks(ConnectPoint src) {
|
||||
Set<Link> egress = new HashSet<>();
|
||||
synchronized (srcLinks) {
|
||||
for (LinkKey linkKey : srcLinks.get(src.deviceId())) {
|
||||
if (linkKey.src().equals(src)) {
|
||||
egress.add(links.get(linkKey));
|
||||
}
|
||||
}
|
||||
}
|
||||
return egress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Link> getIngressLinks(ConnectPoint dst) {
|
||||
Set<Link> ingress = new HashSet<>();
|
||||
synchronized (dstLinks) {
|
||||
for (LinkKey linkKey : dstLinks.get(dst.deviceId())) {
|
||||
if (linkKey.dst().equals(dst)) {
|
||||
ingress.add(links.get(linkKey));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ingress;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user