Single Graph handle across all controller
diff --git a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
index f040881..b8197b7 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
@@ -48,7 +48,7 @@
log.info("SwitchStorage:setStatus dpid:{} state: {} done", dpid, state);
} else {
conn.endTx(Transaction.ROLLBACK);
- log.info("SwitchStorage:setStatus dpid:{} state: {} failed", dpid, state);
+ log.info("SwitchStorage:setStatus dpid:{} state: {} failed: switch not found", dpid, state);
}
}
@@ -83,9 +83,12 @@
conn.endTx(Transaction.COMMIT);
}
+ } else {
+ log.error("SwitchStorage:addPort dpid:{} port:{} : failed switch does not exist", dpid, port.getPortNumber());
}
} catch (Exception e) {
// TODO: handle exceptions
+ e.printStackTrace();
conn.endTx(Transaction.ROLLBACK);
log.error("SwitchStorage:addPort dpid:{} port:{} failed", dpid, port.getPortNumber());
}
@@ -115,32 +118,37 @@
log.info("SwitchStorage:addSwitch(): dpid {} ", dpid);
- try {
- ISwitchObject sw = conn.utils().searchSwitch(conn, dpid);
- if (sw != null) {
- /*
- * Do nothing or throw exception?
- */
-
- log.info("SwitchStorage:addSwitch dpid:{} already exists", dpid);
- sw.setState(SwitchState.ACTIVE.toString());
- conn.endTx(Transaction.COMMIT);
- } else {
- sw = conn.utils().newSwitch(conn);
+ try {
+ ISwitchObject sw = conn.utils().searchSwitch(conn, dpid);
+ if (sw != null) {
+ /*
+ * Do nothing or throw exception?
+ */
- sw.setType("switch");
- sw.setDPID(dpid);
- sw.setState(SwitchState.ACTIVE.toString());
- conn.endTx(Transaction.COMMIT);
- log.info("SwitchStorage:addSwitch dpid:{} added", dpid);
- }
- } catch (Exception e) {
- /*
- * retry?
- */
- conn.endTx(Transaction.ROLLBACK);
- log.info("SwitchStorage:addSwitch dpid:{} failed", dpid);
- }
+ log.info("SwitchStorage:addSwitch dpid:{} already exists", dpid);
+ sw.setState(SwitchState.ACTIVE.toString());
+ conn.endTx(Transaction.COMMIT);
+ } else {
+ sw = conn.utils().newSwitch(conn);
+
+ if (sw != null) {
+ sw.setType("switch");
+ sw.setDPID(dpid);
+ sw.setState(SwitchState.ACTIVE.toString());
+ conn.endTx(Transaction.COMMIT);
+ log.info("SwitchStorage:addSwitch dpid:{} added", dpid);
+ } else {
+ log.error("switchStorage:addSwitch dpid:{} failed -> newSwitch failed", dpid);
+ }
+ }
+ } catch (Exception e) {
+ /*
+ * retry?
+ */
+ e.printStackTrace();
+ conn.endTx(Transaction.ROLLBACK);
+ log.info("SwitchStorage:addSwitch dpid:{} failed", dpid);
+ }
}
@@ -160,6 +168,7 @@
}
} catch (Exception e) {
// TODO: handle exceptions
+ e.printStackTrace();
conn.endTx(Transaction.ROLLBACK);
log.error("SwitchStorage:deleteSwitch {} failed", dpid);
}
diff --git a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
index 9f63fd7..931802e 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
@@ -1,14 +1,14 @@
package net.floodlightcontroller.core.internal;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import net.floodlightcontroller.core.INetMapTopologyObjects.IPortObject;
import net.floodlightcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.floodlightcontroller.core.INetMapTopologyService.ITopoSwitchService;
import net.onrc.onos.util.GraphDBConnection;
import net.onrc.onos.util.GraphDBConnection.Transaction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class TopoSwitchServiceImpl implements ITopoSwitchService {
private GraphDBConnection conn;
@@ -21,7 +21,7 @@
@Override
public void close() {
- conn.endTx(Transaction.COMMIT);
+
conn.close();
}