addPort fails occassionally...do better exception handling
diff --git a/src/main/java/net/floodlightcontroller/core/INetMapTopologyObjects.java b/src/main/java/net/floodlightcontroller/core/INetMapTopologyObjects.java
index 4f11c6c..e29e8e1 100644
--- a/src/main/java/net/floodlightcontroller/core/INetMapTopologyObjects.java
+++ b/src/main/java/net/floodlightcontroller/core/INetMapTopologyObjects.java
@@ -46,7 +46,7 @@
public Iterable<IPortObject> getPorts();
@JsonIgnore
- @GremlinGroovy("_().out('on').has('number',portnum)")
+ @GremlinGroovy("_().out('on').has('number',port_num)")
public IPortObject getPort(final short port_num);
@Adjacency(label="on")
@@ -109,9 +109,16 @@
@Incidence(label="outport",direction = Direction.IN)
public Iterable<IFlowEntry> getOutFlowEntries();
+ @JsonIgnore
+ @Adjacency(label="link")
+ public Iterable<IPortObject> getLinkedPorts();
+
@Adjacency(label="link")
public void removeLink(final IPortObject dest_port);
+ @Adjacency(label="link")
+ public void setLinkPort(final IPortObject dest_port);
+
// @JsonIgnore
// @Adjacency(label="link")
// public Iterable<ILinkObject> getLinks();
diff --git a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
index 17ab274..f040881 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
@@ -178,7 +178,7 @@
log.info("SwitchStorage:deletePort dpid:{} port:{} found and deleted", dpid, port);
sw.removePort(p);
conn.utils().removePort(conn, p);
- conn.endTx(Transaction.COMMIT,GenerateEvent.TRUE);
+ conn.endTx(Transaction.COMMIT);
}
}
} catch (Exception e) {
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
index 33ae22a..e67ecac 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
@@ -36,6 +36,7 @@
public class LinkStorageImpl implements ILinkStorage {
public TitanGraph graph;
protected static Logger log = LoggerFactory.getLogger(LinkStorageImpl.class);
+ protected String conf;
@Override
public void update(Link link, DM_OPERATION op) {
@@ -76,7 +77,8 @@
}
public void addOrUpdateLink(Link lt, LinkInfo linkinfo, DM_OPERATION op) {
- Vertex vportSrc = null, vportDst = null;
+ GraphDBConnection conn = GraphDBConnection.getInstance(this.conf);
+ IPortObject vportSrc = null, vportDst = null;
log.trace("addOrUpdateLink(): op {} {} {}", new Object[]{op, lt, linkinfo});
@@ -84,18 +86,19 @@
// get source port vertex
String dpid = HexString.toHexString(lt.getSrc());
short port = lt.getSrcPort();
- vportSrc = getPortVertex(dpid, port);
+ vportSrc = conn.utils().searchPort(conn, dpid, port);
// get dest port vertex
dpid = HexString.toHexString(lt.getDst());
port = lt.getDstPort();
- vportDst = getPortVertex(dpid, port);
+ vportDst = conn.utils().searchPort(conn, dpid, port);
if (vportSrc != null && vportDst != null) {
+
// check if the link exists
List<Vertex> currLinks = new ArrayList<Vertex>();
- for (Vertex V : vportSrc.query().direction(Direction.OUT).labels("link").vertices()) {
+ for (Vertex V : vportSrc.asVertex().query().direction(Direction.OUT).labels("link").vertices()) {
currLinks.add(V);
}
@@ -106,7 +109,7 @@
new Object[]{op, lt, vportSrc, vportDst});
}
} else {
- graph.addEdge(null, vportSrc, vportDst, "link");
+ graph.addEdge(null, vportSrc.asVertex(), vportDst.asVertex(), "link");
graph.stopTransaction(Conclusion.SUCCESS);
log.debug("addOrUpdateLink(): link added {} {} src {} dst {}", new Object[]{op, lt, vportSrc, vportDst});
}
@@ -134,7 +137,7 @@
@Override
public void deleteLink(Link lt) {
- GraphDBConnection conn = GraphDBConnection.getInstance("");
+ GraphDBConnection conn = GraphDBConnection.getInstance(this.conf);
IPortObject vportSrc = null, vportDst = null;
int count = 0;
@@ -164,7 +167,7 @@
}
}*/
vportSrc.removeLink(vportDst);
- conn.endTx(Transaction.COMMIT, GenerateEvent.TRUE);
+ conn.endTx(Transaction.COMMIT);
log.debug("deleteLink(): deleted edges src {} dst {}", new Object[]{
lt, vportSrc, vportDst});
@@ -204,7 +207,8 @@
public void init(String conf) {
//TODO extract the DB location from properties
- graph = TitanFactory.open(conf);
+ this.conf = conf;
+ graph = TitanFactory.open(this.conf);
// FIXME: These keys are not needed for Links but we better create it before using it as per titan
Set<String> s = graph.getIndexedKeys(Vertex.class);