distributed link fixes
Change-Id: Iefede001a76834599a5629d843a4325283e42711
diff --git a/core/api/src/main/java/org/onlab/onos/net/link/DefaultLinkDescription.java b/core/api/src/main/java/org/onlab/onos/net/link/DefaultLinkDescription.java
index 65d8d6d..037b796 100644
--- a/core/api/src/main/java/org/onlab/onos/net/link/DefaultLinkDescription.java
+++ b/core/api/src/main/java/org/onlab/onos/net/link/DefaultLinkDescription.java
@@ -1,5 +1,6 @@
package org.onlab.onos.net.link;
+import com.google.common.base.MoreObjects;
import org.onlab.onos.net.AbstractDescription;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.Link;
@@ -46,4 +47,11 @@
return type;
}
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper("Link").add("src", src())
+ .add("dst", dst())
+ .add("type", type()).toString();
+ }
+
}
diff --git a/core/net/src/main/java/org/onlab/onos/net/link/impl/LinkManager.java b/core/net/src/main/java/org/onlab/onos/net/link/impl/LinkManager.java
index 7b35f1c..835c47e 100644
--- a/core/net/src/main/java/org/onlab/onos/net/link/impl/LinkManager.java
+++ b/core/net/src/main/java/org/onlab/onos/net/link/impl/LinkManager.java
@@ -201,10 +201,10 @@
ConnectPoint dst = linkDescription.dst();
// if we aren't master for the device associated with the ConnectPoint
// we probably shouldn't be doing this.
- if ((deviceService.getRole(src.deviceId()) != MastershipRole.MASTER) ||
- (deviceService.getRole(dst.deviceId()) != MastershipRole.MASTER)) {
- return;
- }
+
+// if (deviceService.getRole(dst.deviceId()) != MastershipRole.MASTER) {
+// return;
+// }
LinkEvent event = store.createOrUpdateLink(provider().id(),
linkDescription);
if (event != null) {
@@ -220,14 +220,8 @@
ConnectPoint src = linkDescription.src();
ConnectPoint dst = linkDescription.dst();
- // if we aren't master for the device associated with the ConnectPoint
- // we probably shouldn't be doing this.
- if ((deviceService.getRole(src.deviceId()) != MastershipRole.MASTER) ||
- (deviceService.getRole(dst.deviceId()) != MastershipRole.MASTER)) {
- return;
- }
- LinkEvent event = store.removeLink(linkDescription.src(),
- linkDescription.dst());
+
+ LinkEvent event = store.removeLink(src, dst);
if (event != null) {
log.info("Link {} vanished", linkDescription);
post(event);
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/link/impl/GossipLinkStore.java b/core/store/dist/src/main/java/org/onlab/onos/store/link/impl/GossipLinkStore.java
index 312d072..9e58904 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/link/impl/GossipLinkStore.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/link/impl/GossipLinkStore.java
@@ -239,11 +239,14 @@
LinkKey key = linkKey(linkDescription.src(), linkDescription.dst());
final LinkEvent event;
final Timestamped<LinkDescription> mergedDesc;
- synchronized (getOrCreateLinkDescriptions(key)) {
+ Map<ProviderId, Timestamped<LinkDescription>> map = getOrCreateLinkDescriptions(key);
+ synchronized (map) {
event = createOrUpdateLinkInternal(providerId, deltaDesc);
- mergedDesc = getOrCreateLinkDescriptions(key).get(providerId);
+ mergedDesc = map.get(providerId);
}
+
+
if (event != null) {
log.info("Notifying peers of a link update topology event from providerId: "
+ "{} between src: {} and dst: {}",
@@ -252,8 +255,8 @@
notifyPeers(new InternalLinkEvent(providerId, mergedDesc));
} catch (IOException e) {
log.info("Failed to notify peers of a link update topology event from providerId: "
- + "{} between src: {} and dst: {}",
- providerId, linkDescription.src(), linkDescription.dst());
+ + "{} between src: {} and dst: {}",
+ providerId, linkDescription.src(), linkDescription.dst());
}
}
return event;