add another GraphDBOperation constructor which creates an instance directry from GraphDBConnection configuration path.
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
index f8f50a3..5373d99 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
@@ -8,7 +8,6 @@
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.linkdiscovery.ILinkStorage;
-import net.onrc.onos.util.GraphDBConnection;
import net.onrc.onos.util.GraphDBOperation;
import org.openflow.util.HexString;
@@ -166,9 +165,7 @@
// TODO: Fix me
@Override
public List<Link> getLinks(Long dpid, short port) {
- IPortObject vportSrc, vportDst;
- List<Link> links = null;
- Link lt;
+ IPortObject vportSrc;
vportSrc = dbop.searchPort(HexString.toHexString(dpid), port);
if (vportSrc != null) {
@@ -185,7 +182,7 @@
@Override
public void init(String conf) {
//TODO extract the DB location from properties
- this.dbop = new GraphDBOperation(GraphDBConnection.getInstance(conf));
+ this.dbop = new GraphDBOperation(conf);
}
@Override
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
index ea7fdf0..2e9ea60 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
@@ -5,7 +5,6 @@
import net.onrc.onos.ofcontroller.core.ISwitchStorage;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
-import net.onrc.onos.util.GraphDBConnection;
import net.onrc.onos.util.GraphDBOperation;
import org.openflow.protocol.OFPhysicalPort;
@@ -201,8 +200,7 @@
@Override
public void init(String conf) {
- GraphDBConnection conn = GraphDBConnection.getInstance(conf);
- op = new GraphDBOperation(conn);
+ op = new GraphDBOperation(conf);
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/internal/TopoSwitchServiceImpl.java b/src/main/java/net/onrc/onos/ofcontroller/core/internal/TopoSwitchServiceImpl.java
index e279422..c1659fb 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/internal/TopoSwitchServiceImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/internal/TopoSwitchServiceImpl.java
@@ -3,7 +3,6 @@
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoSwitchService;
-import net.onrc.onos.util.GraphDBConnection;
import net.onrc.onos.util.GraphDBOperation;
import org.slf4j.Logger;
@@ -15,7 +14,7 @@
protected static Logger log = LoggerFactory.getLogger(TopoSwitchServiceImpl.class);
public TopoSwitchServiceImpl(String conf) {
- op = new GraphDBOperation(GraphDBConnection.getInstance(conf));
+ op = new GraphDBOperation(conf);
}
public TopoSwitchServiceImpl() {
diff --git a/src/main/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImpl.java b/src/main/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImpl.java
index 98b4a88..0428779 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImpl.java
@@ -15,8 +15,6 @@
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.internal.SwitchStorageImpl;
import net.onrc.onos.ofcontroller.devicemanager.IDeviceStorage;
-import net.onrc.onos.util.GraphDBConnection;
-import net.onrc.onos.util.GraphDBConnection.Transaction;
import net.onrc.onos.util.GraphDBOperation;
/**
@@ -25,7 +23,6 @@
*/
public class DeviceStorageImpl implements IDeviceStorage {
- private GraphDBConnection conn;
private GraphDBOperation ope;
protected static Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
@@ -36,10 +33,7 @@
@Override
public void init(String conf) {
try{
- if((conn = GraphDBConnection.getInstance(conf)) != null)
- {
- ope = new GraphDBOperation(conn);
- }
+ ope = new GraphDBOperation(conf);
} catch(Exception e) {
log.error(e.getMessage());
}
@@ -51,7 +45,7 @@
*/
@Override
public void close() {
- conn.close();
+ ope.close();
}
/***
diff --git a/src/main/java/net/onrc/onos/ofcontroller/devicemanager/web/TopoDevicesResource.java b/src/main/java/net/onrc/onos/ofcontroller/devicemanager/web/TopoDevicesResource.java
index 1cd6b90..97ecfcc 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/devicemanager/web/TopoDevicesResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/devicemanager/web/TopoDevicesResource.java
@@ -3,7 +3,6 @@
import java.util.Iterator;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
-import net.onrc.onos.util.GraphDBConnection;
import net.onrc.onos.util.GraphDBOperation;
import org.restlet.resource.Get;
@@ -13,12 +12,8 @@
@Get("json")
public Iterator<IDeviceObject> retrieve() {
-
- GraphDBConnection conn = GraphDBConnection.getInstance("");
- GraphDBOperation op = new GraphDBOperation(conn);
+ GraphDBOperation op = new GraphDBOperation("");
return op.getDevices().iterator();
-
}
-
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/FlowManager.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/FlowManager.java
index 125acf3..c464b89 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/FlowManager.java
@@ -49,7 +49,6 @@
import net.onrc.onos.ofcontroller.util.IPv4Net;
import net.onrc.onos.ofcontroller.util.Port;
import net.onrc.onos.ofcontroller.util.SwitchPort;
-import net.onrc.onos.util.GraphDBConnection;
import net.onrc.onos.util.GraphDBOperation;
import org.openflow.protocol.OFFlowMod;
@@ -413,7 +412,7 @@
@Override
public void init(String conf) {
- op = new GraphDBOperation(GraphDBConnection.getInstance(conf));
+ op = new GraphDBOperation(conf);
}
public void finalize() {
diff --git a/src/main/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java b/src/main/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java
index 1fe12c4..e134aeb 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java
@@ -8,7 +8,6 @@
import net.floodlightcontroller.routing.Link;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoLinkService;
-import net.onrc.onos.util.GraphDBConnection;
import net.onrc.onos.util.GraphDBOperation;
import org.slf4j.Logger;
@@ -34,8 +33,8 @@
@Override
public List<Link> getActiveLinks() {
// TODO Auto-generated method stub
- op = new GraphDBOperation(GraphDBConnection.getInstance(""));
- op.close(); //Commit to ensure we see latest data
+ op = new GraphDBOperation("");
+ op.commit(); //Commit to ensure we see latest data
Iterable<ISwitchObject> switches = op.getActiveSwitches();
List<Link> links = new ArrayList<Link>();
for (ISwitchObject sw : switches) {
diff --git a/src/main/java/net/onrc/onos/ofcontroller/onoslistener/OnosPublisher.java b/src/main/java/net/onrc/onos/ofcontroller/onoslistener/OnosPublisher.java
index 6a9d433..854b291 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/onoslistener/OnosPublisher.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/onoslistener/OnosPublisher.java
@@ -29,11 +29,9 @@
import net.floodlightcontroller.threadpool.IThreadPoolService;
import net.onrc.onos.ofcontroller.core.ISwitchStorage;
import net.onrc.onos.ofcontroller.core.INetMapStorage.DM_OPERATION;
-import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.core.ISwitchStorage.SwitchState;
import net.onrc.onos.ofcontroller.core.internal.SwitchStorageImpl;
-import net.onrc.onos.ofcontroller.core.internal.TopoSwitchServiceImpl;
import net.onrc.onos.ofcontroller.devicemanager.IDeviceStorage;
import net.onrc.onos.ofcontroller.devicemanager.internal.DeviceStorageImpl;
import net.onrc.onos.ofcontroller.linkdiscovery.ILinkStorage;
@@ -253,7 +251,7 @@
// TODO Auto-generated method stub
Map<String, String> configMap = context.getConfigParams(this);
String conf = configMap.get(DBConfigFile);
- op = new GraphDBOperation(GraphDBConnection.getInstance(conf));
+ op = new GraphDBOperation(conf);
log = LoggerFactory.getLogger(OnosPublisher.class);
floodlightProvider =
diff --git a/src/main/java/net/onrc/onos/ofcontroller/routing/TopoRouteService.java b/src/main/java/net/onrc/onos/ofcontroller/routing/TopoRouteService.java
index a051d4c..0184915 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/routing/TopoRouteService.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/routing/TopoRouteService.java
@@ -23,8 +23,6 @@
import net.onrc.onos.ofcontroller.util.FlowEntry;
import net.onrc.onos.ofcontroller.util.Port;
import net.onrc.onos.ofcontroller.util.SwitchPort;
-import net.onrc.onos.util.GraphDBConnection;
-import net.onrc.onos.util.GraphDBConnection.Transaction;
import net.onrc.onos.util.GraphDBOperation;
import org.openflow.util.HexString;
@@ -32,7 +30,6 @@
import org.slf4j.LoggerFactory;
import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.TransactionalGraph.Conclusion;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.pipes.PipeFunction;
import com.tinkerpop.pipes.branch.LoopPipe.LoopBundle;
@@ -135,7 +132,7 @@
public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
// TODO: Add the appropriate initialization
- op = new GraphDBOperation(GraphDBConnection.getInstance(""));
+ op = new GraphDBOperation("");
}
@Override
diff --git a/src/main/java/net/onrc/onos/util/GraphDBOperation.java b/src/main/java/net/onrc/onos/util/GraphDBOperation.java
index 858a17e..da41dbd 100644
--- a/src/main/java/net/onrc/onos/util/GraphDBOperation.java
+++ b/src/main/java/net/onrc/onos/util/GraphDBOperation.java
@@ -24,6 +24,10 @@
public GraphDBOperation(GraphDBConnection dbConnection) {
this.conn = dbConnection;
}
+
+ public GraphDBOperation(final String dbConfPath) {
+ this.conn = GraphDBConnection.getInstance(dbConfPath);
+ }
@Override
public ISwitchObject newSwitch(String dpid) {
diff --git a/src/test/java/net/onrc/onos/util/GraphDBOperationTest.java b/src/test/java/net/onrc/onos/util/GraphDBOperationTest.java
index 4bfcf14..cd56378 100644
--- a/src/test/java/net/onrc/onos/util/GraphDBOperationTest.java
+++ b/src/test/java/net/onrc/onos/util/GraphDBOperationTest.java
@@ -43,7 +43,6 @@
@PrepareForTest({TitanFactory.class})
public class GraphDBOperationTest extends TestCase {
private static TitanGraph testdb;
- private static GraphDBConnection conn;
private static GraphDBOperation op;
/**
@@ -75,8 +74,7 @@
EasyMock.expect(TitanFactory.open(dummyPath)).andReturn(testdb);
PowerMock.replay(TitanFactory.class);
- conn = GraphDBConnection.getInstance(dummyPath);
- op = new GraphDBOperation(conn);
+ op = new GraphDBOperation(dummyPath);
}
/**
@@ -84,7 +82,7 @@
*/
@After
public void tearDown() throws Exception {
- conn.close();
+ op.close();
testdb.shutdown();
PowerMock.verifyAll();
}