integrated and added checks to avoid duplicate links
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
index 6f7c9b7..e227b71 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
@@ -191,7 +191,7 @@
int lldpTimeCount = 0;
// Storage
- protected LinkStorageImplStubs linkStore;
+ protected LinkStorageImpl linkStore;
/**
* Flag to indicate if automatic port fast is enabled or not.
@@ -1868,7 +1868,7 @@
}
// Initialize the link storage connector to the network map
- this.linkStore = new LinkStorageImplStubs();
+ this.linkStore = new LinkStorageImpl();
this.linkStore.init("");
ScheduledExecutorService ses = threadPool.getScheduledExecutor();
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
index af99506..1fb80e9 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
@@ -86,8 +86,13 @@
}
if (vportSrc != null && vportDst != null) {
- graph.addEdge(null, vportSrc, vportDst, "link");
- graph.stopTransaction(Conclusion.SUCCESS);
+ //TODO: If Edge already exists should we remove and add again?
+ if (vportSrc.query().direction(Direction.OUT).labels("link").vertices().iterator().equals(vportDst)) {
+ //FIXME: Succeed silently for now
+ } else {
+ graph.addEdge(null, vportSrc, vportDst, "link");
+ graph.stopTransaction(Conclusion.SUCCESS);
+ }
log.debug("addLink(): link added {} src {} dst {}", new Object[]{lt, vportSrc, vportDst});
} else {
log.error("addLink(): failed {} src {} dst {}", new Object[]{lt, vportSrc, vportDst});