Modified how to get DBOperator object
diff --git a/src/main/java/net/onrc/onos/graph/GraphDBManager.java b/src/main/java/net/onrc/onos/graph/GraphDBManager.java
index f2ae376..fb5c0d8 100644
--- a/src/main/java/net/onrc/onos/graph/GraphDBManager.java
+++ b/src/main/java/net/onrc/onos/graph/GraphDBManager.java
@@ -15,7 +15,8 @@
*/
public class GraphDBManager {
private static ThreadLocal<HashMap<String, DBConnection>> connections = new ThreadLocal<HashMap<String, DBConnection>>();
-
+ private static DBOperation operation = null;
+
static Map<String, DBConnection> getConnectionMap() {
if (connections.get() == null) {
connections.set(new HashMap<String, DBConnection>());
@@ -24,15 +25,16 @@
}
public static DBOperation getDBOperation(final String dbStore, final String dbConfigFile) {
- DBOperation operation = null;
- if (dbStore.equals("ramcloud")) {
- operation = new RamCloudDBOperation();
- } else if (dbStore.equals("titan")) {
- operation = new TitanDBOperation();
- }
- if (operation != null) {
- operation.conn = GraphDBManager.getConnection(dbStore, dbConfigFile);
- }
+ if (operation == null){
+ if (dbStore.equals("ramcloud")) {
+ operation = new RamCloudDBOperation();
+ } else if (dbStore.equals("titan")) {
+ operation = new TitanDBOperation();
+ }
+ if (operation != null) {
+ operation.conn = GraphDBManager.getConnection(dbStore, dbConfigFile);
+ }
+ }
return operation;
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/internal/TopoLinkServiceImpl.java b/src/main/java/net/onrc/onos/ofcontroller/core/internal/TopoLinkServiceImpl.java
index b692e8e..5892ef8 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/internal/TopoLinkServiceImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/internal/TopoLinkServiceImpl.java
@@ -4,7 +4,7 @@
import java.util.List;
import net.floodlightcontroller.routing.Link;
-import net.onrc.onos.graph.GraphDBOperation;
+import net.onrc.onos.graph.DBOperation;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoLinkService;
import net.onrc.onos.ofcontroller.core.internal.LinkStorageImpl.ExtractLink;
@@ -14,10 +14,11 @@
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.gremlin.java.GremlinPipeline;
+import net.onrc.onos.graph.GraphDBManager;
public class TopoLinkServiceImpl implements ITopoLinkService {
- protected GraphDBOperation op;
+ protected DBOperation dbop;
protected final static Logger log = LoggerFactory.getLogger(TopoLinkServiceImpl.class);
public void finalize() {
@@ -26,15 +27,15 @@
@Override
public void close() {
- op.close();
+ dbop.close();
}
@Override
public List<Link> getActiveLinks() {
// TODO Auto-generated method stub
- op = new GraphDBOperation("");
- op.commit(); //Commit to ensure we see latest data
- Iterable<ISwitchObject> switches = op.getActiveSwitches();
+ dbop = GraphDBManager.getDBOperation("", "");
+ dbop.commit(); //Commit to ensure we see latest data
+ Iterable<ISwitchObject> switches = dbop.getActiveSwitches();
List<Link> links = new ArrayList<Link>();
for (ISwitchObject sw : switches) {
GremlinPipeline<Vertex, Link> pipe = new GremlinPipeline<Vertex, Link>();
@@ -50,7 +51,7 @@
}
}
- op.commit();
+ dbop.commit();
return links;
}
@@ -58,7 +59,7 @@
public List<Link> getLinksOnSwitch(String dpid) {
// TODO Auto-generated method stub
List<Link> links = new ArrayList<Link>();
- ISwitchObject sw = op.searchSwitch(dpid);
+ ISwitchObject sw = dbop.searchSwitch(dpid);
GremlinPipeline<Vertex, Link> pipe = new GremlinPipeline<Vertex, Link>();
ExtractLink extractor = new ExtractLink();