integrated and added checks to avoid duplicate links
diff --git a/build.xml b/build.xml
index e46a36d..99afa03 100644
--- a/build.xml
+++ b/build.xml
@@ -234,12 +234,12 @@
<fileset dir="${python-src}">
<include name="**/*.py"/>
</fileset>
- <zipgroupfileset dir="${lib}">
- <patternset refid="lib"/>
- </zipgroupfileset>
<zipgroupfileset dir="${titanlib}">
<patternset refid="titanlib"/>
</zipgroupfileset>
+ <zipgroupfileset dir="${lib}">
+ <patternset refid="lib"/>
+ </zipgroupfileset>
</jar>
<jar destfile="${floodlight-test-jar}" filesetmanifest="mergewithoutmain">
<manifest>
diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
index 3592fbc..8a35b54 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
@@ -1431,6 +1431,9 @@
updateActiveSwitchInfo(sw);
swStore.update(sw.getStringId(), SwitchState.ACTIVE, DM_OPERATION.UPDATE);
+ for (OFPhysicalPort port: sw.getPorts()) {
+ swStore.addPort(sw.getStringId(), port);
+ }
SwitchUpdate update = new SwitchUpdate(sw, SwitchUpdateType.ADDED);
try {
this.updates.put(update);
diff --git a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
index 68633b1..3bb6c87 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
@@ -68,22 +68,26 @@
Vertex sw;
try {
if ((sw = graph.getVertices("dpid",dpid).iterator().next()) != null) {
- log.info("SwitchStorage:addPort dpid:{} port:{}", dpid, port);
+ log.info("SwitchStorage:addPort dpid:{} port:{}", dpid, port.getPortNumber());
// TODO: Check if port exists
- Vertex p = graph.addVertex(null);
- p.setProperty("type","port");
- p.setProperty("number",port.getPortNumber());
- p.setProperty("state",port.getState());
- p.setProperty("desc",port.getName());
- Edge e = graph.addEdge(null, sw, p, "on");
- e.setProperty("state","ACTIVE");
- e.setProperty("number", port.getPortNumber());
-
- graph.stopTransaction(Conclusion.SUCCESS);
+ if (sw.query().direction(Direction.OUT).labels("on").has("number",port.getPortNumber()).vertices().iterator().hasNext()) {
+ //TODO: Do nothing for now
+ } else {
+ Vertex p = graph.addVertex(null);
+ p.setProperty("type","port");
+ p.setProperty("number",port.getPortNumber());
+ p.setProperty("state",port.getState());
+ p.setProperty("desc",port.getName());
+ Edge e = graph.addEdge(null, sw, p, "on");
+ e.setProperty("state","ACTIVE");
+ e.setProperty("number", port.getPortNumber());
+
+ graph.stopTransaction(Conclusion.SUCCESS);
+ }
}
} catch (TitanException e) {
// TODO: handle exceptions
- log.info("SwitchStorage:addPort dpid:{} port:{}", dpid, port);
+ log.info("SwitchStorage:addPort dpid:{} port:{}", dpid, port.getPortNumber());
}
}
@@ -186,7 +190,7 @@
db.setProperty("storage.hostname","127.0.0.1");
graph = TitanFactory.open(db);
- // FIXME:
+ // FIXME: Creation on Indexes should be done only once
Set<String> s = graph.getIndexedKeys(Vertex.class);
if (!s.contains("dpid")) {
graph.createKeyIndex("dpid", Vertex.class);
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});