Merge branch 'master' into RAMCloud
Conflicts:
conf/onos.properties
src/main/java/net/onrc/onos/flow/FlowManagerImpl.java
src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java
src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
src/main/java/net/onrc/onos/ofcontroller/core/ILinkStorage.java
src/main/java/net/onrc/onos/ofcontroller/core/ISwitchStorage.java
src/main/java/net/onrc/onos/ofcontroller/core/internal/DeviceStorageImpl.java
src/main/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImpl.java
src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/NetworkGraphPublisher.java
src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
src/main/java/net/onrc/onos/ofcontroller/topology/ShortestPath.java
src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java
src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTest.java
src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTestBB.java
src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTest.java
src/test/java/net/onrc/onos/ofcontroller/topology/TopologyManagerTest.java
diff --git a/conf/onos.properties b/conf/onos.properties
index f7bffb2..ada6f14 100644
--- a/conf/onos.properties
+++ b/conf/onos.properties
@@ -19,3 +19,5 @@
net.floodlightcontroller.forwarding.Forwarding.hardtimeout = 0
net.onrc.onos.ofcontroller.floodlightlistener.NetworkGraphPublisher.dbconf = /tmp/cassandra.titan
net.onrc.onos.datagrid.HazelcastDatagrid.datagridConfig = conf/hazelcast.xml
+#net.onrc.onos.ofcontroller.floodlightlistener.NetworkGraphPublisher.dbconf = /tmp/ramcloud.conf
+#net.onrc.onos.ofcontroller.floodlightlistener.NetworkGraphPublisher.graph_db_store = ramcloud
diff --git a/pom.xml b/pom.xml
index a8730a5..cd28064 100644
--- a/pom.xml
+++ b/pom.xml
@@ -251,13 +251,16 @@
<artifactId>frames</artifactId>
<version>2.3.1</version>
</dependency>
- <!--
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-core</artifactId>
- <version>2.3.0</version>
+ <version>2.4.0</version>
</dependency>
- -->
+ <dependency>
+ <groupId>com.hazelcast</groupId>
+ <artifactId>hazelcast</artifactId>
+ <version>3.0.2</version>
+ </dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
@@ -368,7 +371,7 @@
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
- <version>3.1</version>
+ <version>3.2</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -424,5 +427,12 @@
<version>0.1.0</version>
</dependency>
-->
+ <dependency>
+ <groupId>com.tinkerpop.blueprints.impls.ramcloud</groupId>
+ <artifactId>blueprints-ramcloud-graph</artifactId>
+ <version>2.4.0</version>
+ <scope>system</scope>
+ <systemPath>${project.basedir}/lib/blueprints-ramcloud-graph-2.4.0.jar</systemPath>
+ </dependency>
</dependencies>
</project>
diff --git a/src/main/java/net/onrc/onos/flow/FlowManagerImpl.java b/src/main/java/net/onrc/onos/flow/FlowManagerImpl.java
index 9865deb..92948b7 100644
--- a/src/main/java/net/onrc/onos/flow/FlowManagerImpl.java
+++ b/src/main/java/net/onrc/onos/flow/FlowManagerImpl.java
@@ -18,7 +18,7 @@
import com.tinkerpop.blueprints.Vertex;
import net.floodlightcontroller.core.IOFSwitch;
-import net.onrc.onos.graph.GraphDBOperation;
+import net.onrc.onos.graph.DBOperation;
import net.onrc.onos.graph.LocalTopologyEventListener;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
@@ -37,7 +37,7 @@
public class FlowManagerImpl implements IFlowManager {
protected final static Logger log = LoggerFactory.getLogger(LocalTopologyEventListener.class);
- protected GraphDBOperation op;
+ protected DBOperation op;
@Override
public void createFlow(IPortObject src_port, IPortObject dest_port) {
@@ -85,10 +85,8 @@
String dst_dpid = flow.getDstSwitch();
Short src_port = flow.getSrcPort();
Short dst_port = flow.getDstPort();
- IPortObject src = null;
- IPortObject dst = null;
- src = op.searchPort(src_dpid, src_port);
- dst = op.searchPort(dst_dpid, dst_port);
+ IPortObject src = op.searchPort(src_dpid, src_port);
+ IPortObject dst = op.searchPort(dst_dpid, dst_port);
if (src != null && dst != null) {
FlowPath newFlow = this.computeFlowPath(src,dst);
installFlow(newFlow);
diff --git a/src/main/java/net/onrc/onos/graph/DBConnection.java b/src/main/java/net/onrc/onos/graph/DBConnection.java
new file mode 100644
index 0000000..dee458a
--- /dev/null
+++ b/src/main/java/net/onrc/onos/graph/DBConnection.java
@@ -0,0 +1,19 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.onrc.onos.graph;
+
+/**
+ *
+ * @author nickkaranatsios
+ */
+public abstract class DBConnection implements IDBConnection {
+ public enum Transaction {
+ COMMIT, ROLLBACK
+ }
+
+ public enum GenerateEvent {
+ TRUE, FALSE
+ }
+}
diff --git a/src/main/java/net/onrc/onos/graph/DBOperation.java b/src/main/java/net/onrc/onos/graph/DBOperation.java
new file mode 100644
index 0000000..db3dad7
--- /dev/null
+++ b/src/main/java/net/onrc/onos/graph/DBOperation.java
@@ -0,0 +1,186 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.onrc.onos.graph;
+
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.tinkerpop.blueprints.Vertex;
+import com.tinkerpop.frames.FramedGraph;
+import com.tinkerpop.frames.structures.FramedVertexIterable;
+import com.tinkerpop.gremlin.java.GremlinPipeline;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
+import net.onrc.onos.ofcontroller.core.ISwitchStorage;
+import net.onrc.onos.ofcontroller.util.FlowId;
+
+/**
+ *
+ * @author nickkaranatsios
+ */
+public abstract class DBOperation implements IDBOperation {
+
+ protected DBConnection conn;
+
+ @Override
+ public ISwitchObject searchActiveSwitch(String dpid) {
+ ISwitchObject sw = searchSwitch(dpid);
+ if ((sw != null)
+ && sw.getState().equals(ISwitchStorage.SwitchState.ACTIVE.toString())) {
+ return sw;
+ }
+ return null;
+ }
+
+ @Override
+ public ISwitchObject newSwitch(final String dpid) {
+ ISwitchObject obj = (ISwitchObject) conn.getFramedGraph().addVertex(null, ISwitchObject.class);
+ if (obj != null) {
+ obj.setType("switch");
+ obj.setDPID(dpid);
+ }
+ return obj;
+ }
+
+ @Override
+ public Iterable<ISwitchObject> getAllSwitches() {
+ Iterable<ISwitchObject> switches = conn.getFramedGraph().getVertices("type", "switch", ISwitchObject.class);
+ return switches;
+ }
+
+ @Override
+ public Iterable<ISwitchObject> getInactiveSwitches() {
+ Iterable<ISwitchObject> switches = conn.getFramedGraph().getVertices("type", "switch", ISwitchObject.class);
+ List<ISwitchObject> inactiveSwitches = new ArrayList<ISwitchObject>();
+
+ for (ISwitchObject sw : switches) {
+ if (sw.getState().equals(ISwitchStorage.SwitchState.INACTIVE.toString())) {
+ inactiveSwitches.add(sw);
+ }
+ }
+ return inactiveSwitches;
+ }
+
+ @Override
+ public Iterable<INetMapTopologyObjects.IFlowEntry> getAllSwitchNotUpdatedFlowEntries() {
+ //TODO: Should use an enum for flow_switch_state
+ return conn.getFramedGraph().getVertices("switch_state", "FE_SWITCH_NOT_UPDATED", INetMapTopologyObjects.IFlowEntry.class);
+
+ }
+
+ @Override
+ public void removeSwitch(ISwitchObject sw) {
+ conn.getFramedGraph().removeVertex(sw.asVertex());
+ }
+
+ @Override
+ public IPortObject newPort(String dpid, Short portNum) {
+ IPortObject obj = (IPortObject) conn.getFramedGraph().addVertex(null, IPortObject.class);
+ if (obj != null) {
+ obj.setType("port");
+ String id = dpid + portNum.toString();
+ obj.setPortId(id);
+ obj.setNumber(portNum);
+ }
+ return obj;
+ }
+
+ public IPortObject searchPort(String dpid, Short number, final FramedGraph fg) {
+ String id = dpid + number.toString();
+ return (fg != null && fg.getVertices("port_id", id).iterator().hasNext())
+ ? (IPortObject) fg.getVertices("port_id", id, IPortObject.class).iterator().next() : null;
+
+ }
+
+ @Override
+ public IDeviceObject newDevice() {
+ IDeviceObject obj = (IDeviceObject) conn.getFramedGraph().addVertex(null, IDeviceObject.class);
+ if (obj != null) {
+ obj.setType("device");
+ }
+ return obj;
+ }
+
+ @Override
+ public IFlowPath newFlowPath() {
+ IFlowPath flowPath = (IFlowPath)conn.getFramedGraph().addVertex(null, IFlowPath.class);
+ if (flowPath != null) {
+ flowPath.setType("flow");
+ }
+ return flowPath;
+ }
+
+ @Override
+ public IFlowPath getFlowPathByFlowEntry(INetMapTopologyObjects.IFlowEntry flowEntry) {
+ GremlinPipeline<Vertex, IFlowPath> pipe = new GremlinPipeline<Vertex, IFlowPath>();
+ pipe.start(flowEntry.asVertex());
+ pipe.out("flow");
+ FramedVertexIterable<IFlowPath> r = new FramedVertexIterable(conn.getFramedGraph(), (Iterable) pipe, IFlowPath.class);
+ return r.iterator().hasNext() ? r.iterator().next() : null;
+ }
+
+
+
+ protected ISwitchObject searchSwitch(final String dpid, final FramedGraph fg) {
+ return (fg != null && fg.getVertices("dpid", dpid).iterator().hasNext())
+ ? (ISwitchObject) (fg.getVertices("dpid", dpid, ISwitchObject.class).iterator().next()) : null;
+ }
+
+ protected Iterable<ISwitchObject> getActiveSwitches(final FramedGraph fg) {
+ Iterable<ISwitchObject> switches = fg.getVertices("type", "switch", ISwitchObject.class);
+ List<ISwitchObject> activeSwitches = new ArrayList<ISwitchObject>();
+
+ for (ISwitchObject sw : switches) {
+ if (sw.getState().equals(ISwitchStorage.SwitchState.ACTIVE.toString())) {
+ activeSwitches.add(sw);
+ }
+ }
+ return activeSwitches;
+ }
+
+ protected Iterable<ISwitchObject> getAllSwitches(final FramedGraph fg) {
+ Iterable<ISwitchObject> switches = fg.getVertices("type", "switch", ISwitchObject.class);
+ return switches;
+ }
+
+ protected IDeviceObject searchDevice(String macAddr, final FramedGraph fg) {
+ return (fg != null && fg.getVertices("dl_addr", macAddr).iterator().hasNext())
+ ? (IDeviceObject) fg.getVertices("dl_addr", macAddr, IDeviceObject.class).iterator().next() : null;
+
+ }
+
+ protected IFlowPath searchFlowPath(final FlowId flowId, final FramedGraph fg) {
+ return fg.getVertices("flow_id", flowId.toString()).iterator().hasNext()
+ ? (IFlowPath) fg.getVertices("flow_id", flowId.toString(),
+ IFlowPath.class).iterator().next() : null;
+ }
+
+ protected Iterable<IFlowPath> getAllFlowPaths(final FramedGraph fg) {
+ Iterable<IFlowPath> flowPaths = fg.getVertices("type", "flow", IFlowPath.class);
+
+ List<IFlowPath> nonNullFlows = new ArrayList<IFlowPath>();
+
+ for (IFlowPath fp : flowPaths) {
+ if (fp.getFlowId() != null) {
+ nonNullFlows.add(fp);
+ }
+ }
+ return nonNullFlows;
+ }
+
+ protected IFlowEntry newFlowEntry(final FramedGraph fg) {
+ IFlowEntry flowEntry = (IFlowEntry) fg.addVertex(null, IFlowEntry.class);
+ if (flowEntry != null) {
+ flowEntry.setType("flow_entry");
+ }
+ return flowEntry;
+ }
+
+}
diff --git a/src/main/java/net/onrc/onos/graph/GraphDBManager.java b/src/main/java/net/onrc/onos/graph/GraphDBManager.java
new file mode 100644
index 0000000..6b06fd2
--- /dev/null
+++ b/src/main/java/net/onrc/onos/graph/GraphDBManager.java
@@ -0,0 +1,58 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.onrc.onos.graph;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * @author nickkaranatsios
+ */
+public class GraphDBManager {
+ private static ThreadLocal<HashMap<String, DBConnection>> connections = new ThreadLocal<HashMap<String, DBConnection>>();
+
+ static Map<String, DBConnection> getConnectionMap() {
+ if (connections.get() == null) {
+ connections.set(new HashMap<String, DBConnection>());
+ }
+ return connections.get();
+ }
+
+ 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);
+ }
+ return null;
+ }
+
+ public static DBConnection getConnection(final String dbStore, final String dbConfigFile) {
+ DBConnection conn = getConnectionMap().get(dbStore);
+ if (conn == null) {
+ if (dbStore.equals("ramcloud")) {
+ conn = new RamCloudDBConnection(dbConfigFile);
+ } else if (dbStore.equals("titan")) {
+ conn = new TitanDBConnection(dbConfigFile);
+ }
+
+ GraphDBManager.getConnectionMap().put(dbStore, conn);
+ } else {
+ GraphDBManager.getConnectionMap().get(dbStore);
+ }
+ return conn;
+ }
+
+ static List<DBConnection> getConnections() {
+ return new ArrayList<DBConnection>(getConnectionMap().values());
+ }
+}
diff --git a/src/main/java/net/onrc/onos/graph/IDBConnection.java b/src/main/java/net/onrc/onos/graph/IDBConnection.java
index 82ebba2..cd65ec0 100644
--- a/src/main/java/net/onrc/onos/graph/IDBConnection.java
+++ b/src/main/java/net/onrc/onos/graph/IDBConnection.java
@@ -1,13 +1,12 @@
package net.onrc.onos.graph;
-import com.thinkaurelius.titan.core.TitanGraph;
import com.tinkerpop.frames.FramedGraph;
public interface IDBConnection {
- public FramedGraph<TitanGraph> getFramedGraph();
- public void addEventListener(final LocalGraphChangedListener listener);
- public Boolean isValid();
- public void commit();
- public void rollback();
- public void close();
+ public FramedGraph getFramedGraph();
+ public void addEventListener(final LocalGraphChangedListener listener);
+ public Boolean isValid();
+ public void commit();
+ public void rollback();
+ public void close();
}
diff --git a/src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java b/src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java
index 5388233..7014e23 100644
--- a/src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java
+++ b/src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java
@@ -11,13 +11,15 @@
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Vertex;
+import com.tinkerpop.blueprints.impls.ramcloud.*;
+import java.util.Map;
public class LocalTopologyEventListener implements LocalGraphChangedListener {
protected final static Logger log = LoggerFactory.getLogger(LocalTopologyEventListener.class);
- protected static GraphDBConnection conn;
+ protected static DBConnection conn;
- public LocalTopologyEventListener(GraphDBConnection conn) {
+ public LocalTopologyEventListener(DBConnection conn) {
LocalTopologyEventListener.conn = conn;
}
@@ -35,7 +37,6 @@
}
- @Override
public void edgeRemoved(Edge e) {
// TODO Auto-generated method stub
// Fire NetMapEvents (LinkRemoved, FlowEntryRemoved, HostRemoved, PortRemoved)
@@ -44,9 +45,9 @@
String label = edge.getLabel();
if (label.equals("link")) {
Vertex v = edge.getVertex(Direction.IN);
- IPortObject src_port = conn.getFramedGraph().frame(v, IPortObject.class);
+ IPortObject src_port = (IPortObject) conn.getFramedGraph().frame(v, IPortObject.class);
v = edge.getVertex(Direction.OUT);
- IPortObject dest_port = conn.getFramedGraph().frame(v, IPortObject.class);
+ IPortObject dest_port = (IPortObject) conn.getFramedGraph().frame(v, IPortObject.class);
log.debug("TopologyEvents: link broken {}", new Object []{src_port.getSwitch().getDPID(),
src_port.getNumber(),
@@ -70,7 +71,6 @@
}
- @Override
public void vertexRemoved(Vertex vertex) {
// TODO Auto-generated method stub
// Generate NetMapEvents
@@ -79,7 +79,7 @@
if (type.equals("port")) {
// port is removed...lets fire reconcile here directly for now
- IPortObject src_port = conn.getFramedGraph().frame(vertex, IPortObject.class);
+ IPortObject src_port = (IPortObject) conn.getFramedGraph().frame(vertex, IPortObject.class);
log.debug("TopologyEvents: Port removed: {}:{}",src_port.getSwitch().getDPID(),src_port.getNumber());
IFlowManager manager = new FlowManagerImpl();
manager.reconcileFlows(src_port);
@@ -101,4 +101,13 @@
}
+ @Override
+ public void vertexRemoved(Vertex vertex, Map<String, Object> props) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void edgeRemoved(Edge edge, Map<String, Object> props) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
}
diff --git a/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java b/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java
new file mode 100644
index 0000000..66c3154
--- /dev/null
+++ b/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java
@@ -0,0 +1,80 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.onrc.onos.graph;
+
+import com.tinkerpop.blueprints.impls.ramcloud.RamCloudGraph;
+import com.tinkerpop.frames.FramedGraph;
+import java.io.File;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+
+/**
+ *
+ * @author nickkaranatsios
+ */
+public class RamCloudDBConnection extends DBConnection {
+ private RamCloudGraph graph;
+
+ public RamCloudDBConnection(final String dbConfigFile) {
+ System.out.println("dbconfigfile is + "+ dbConfigFile);
+ final String coordinatorURL = open(getConfiguration(new File(dbConfigFile)));
+ graph = new RamCloudGraph(coordinatorURL);
+ }
+
+ @Override
+ public FramedGraph getFramedGraph() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void addEventListener(LocalGraphChangedListener listener) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public Boolean isValid() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void commit() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void rollback() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void close() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ private static final Configuration getConfiguration(final File dirOrFile) {
+ if (dirOrFile == null) {
+ throw new IllegalArgumentException("Need to specify a configuration file or storage directory");
+ }
+
+ if (!dirOrFile.isFile()) {
+ throw new IllegalArgumentException("Location of configuration must be a file");
+ }
+
+ try {
+ return new PropertiesConfiguration(dirOrFile);
+ } catch (ConfigurationException e) {
+ throw new IllegalArgumentException("Could not load configuration at: " + dirOrFile, e);
+ }
+ }
+
+ private String open(final Configuration configuration) {
+ final String coordinatorURL = configuration.getString("ramcloud.coordinator", null);
+ if (coordinatorURL == null) {
+ throw new RuntimeException("Configuration must contain a valid 'coordinatorURL' setting");
+ }
+ return coordinatorURL;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/graph/RamCloudDBOperation.java b/src/main/java/net/onrc/onos/graph/RamCloudDBOperation.java
new file mode 100644
index 0000000..93b0054
--- /dev/null
+++ b/src/main/java/net/onrc/onos/graph/RamCloudDBOperation.java
@@ -0,0 +1,170 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.onrc.onos.graph;
+
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.tinkerpop.blueprints.impls.ramcloud.RamCloudGraph;
+import com.tinkerpop.frames.FramedGraph;
+import java.io.File;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
+import net.onrc.onos.ofcontroller.util.FlowEntryId;
+import net.onrc.onos.ofcontroller.util.FlowId;
+import org.apache.commons.configuration.Configuration;
+
+/**
+ *
+ * @author nickkaranatsios
+ */
+public class RamCloudDBOperation extends DBOperation {
+
+ public RamCloudDBOperation() {
+ //Configuration configuration= getConfiguration(new File(dbConfigFile));
+ //final String coordinatorURL = configuration.getProperty("connect.coordinator");
+ }
+
+ @Override
+ public INetMapTopologyObjects.ISwitchObject searchSwitch(String dpid) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public INetMapTopologyObjects.ISwitchObject searchActiveSwitch(String dpid) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public Iterable<INetMapTopologyObjects.ISwitchObject> getActiveSwitches() {
+ return getActiveSwitches(conn.getFramedGraph());
+ }
+
+ @Override
+ public Iterable<INetMapTopologyObjects.ISwitchObject> getAllSwitches() {
+ return getAllSwitches(conn.getFramedGraph());
+ }
+
+ @Override
+ public Iterable<INetMapTopologyObjects.ISwitchObject> getInactiveSwitches() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public Iterable<INetMapTopologyObjects.IFlowEntry> getAllSwitchNotUpdatedFlowEntries() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void removeSwitch(INetMapTopologyObjects.ISwitchObject sw) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public INetMapTopologyObjects.IPortObject newPort(Short portNumber) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public INetMapTopologyObjects.IPortObject newPort(String dpid, Short portNum) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public IPortObject searchPort(String dpid, Short number) {
+ final FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
+ return searchPort(dpid, number, fg);
+ }
+
+ @Override
+ public void removePort(INetMapTopologyObjects.IPortObject port) {
+ FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
+ if (fg != null) {
+ fg.removeVertex(port.asVertex());
+ }
+ }
+
+
+ @Override
+ public IDeviceObject searchDevice(String macAddr) {
+ FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
+ return searchDevice(macAddr, fg);
+ }
+
+ @Override
+ public Iterable<IDeviceObject> getDevices() {
+ FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
+ return fg != null ? fg.getVertices("type", "device", IDeviceObject.class) : null;
+ }
+
+ @Override
+ public void removeDevice(IDeviceObject dev) {
+ FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
+ if (fg != null) {
+ fg.removeVertex(dev.asVertex());
+ }
+ }
+
+
+ @Override
+ public INetMapTopologyObjects.IFlowPath searchFlowPath(FlowId flowId) {
+ FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
+ return searchFlowPath(flowId, fg);
+ }
+
+ @Override
+ public Iterable<IFlowPath> getAllFlowPaths() {
+ FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
+ return getAllFlowPaths(fg);
+ }
+
+ @Override
+ public void removeFlowPath(INetMapTopologyObjects.IFlowPath flowPath) {
+ FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
+ fg.removeVertex(flowPath.asVertex());
+ }
+
+ @Override
+ public IFlowEntry newFlowEntry() {
+ FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
+ return newFlowEntry(fg);
+ }
+
+ @Override
+ public INetMapTopologyObjects.IFlowEntry searchFlowEntry(FlowEntryId flowEntryId) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public Iterable<INetMapTopologyObjects.IFlowEntry> getAllFlowEntries() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void removeFlowEntry(INetMapTopologyObjects.IFlowEntry flowEntry) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public IDBConnection getDBConnection() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void commit() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void rollback() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void close() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+}
diff --git a/src/main/java/net/onrc/onos/graph/TitanDBConnection.java b/src/main/java/net/onrc/onos/graph/TitanDBConnection.java
new file mode 100644
index 0000000..055a758
--- /dev/null
+++ b/src/main/java/net/onrc/onos/graph/TitanDBConnection.java
@@ -0,0 +1,125 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.onrc.onos.graph;
+
+import com.thinkaurelius.titan.core.TitanFactory;
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.tinkerpop.blueprints.TransactionalGraph;
+import com.tinkerpop.blueprints.Vertex;
+import com.tinkerpop.blueprints.util.wrappers.event.EventTransactionalGraph;
+import com.tinkerpop.frames.FramedGraph;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author nickkaranatsios
+ */
+public class TitanDBConnection extends DBConnection {
+
+ private TitanGraph graph;
+ private static Logger log = LoggerFactory.getLogger(TitanDBConnection.class);
+ private EventTransactionalGraph<TitanGraph> eg;
+
+ public TitanDBConnection(final String dbConfigFile) {
+ graph = TitanFactory.open(dbConfigFile);
+ Set<String> s = graph.getIndexedKeys(Vertex.class);
+ if (!s.contains("dpid")) {
+ graph.createKeyIndex("dpid", Vertex.class);
+ }
+ if (!s.contains("port_id")) {
+ graph.createKeyIndex("port_id", Vertex.class);
+ }
+ if (!s.contains("type")) {
+ graph.createKeyIndex("type", Vertex.class);
+ }
+ if (!s.contains("dl_addr")) {
+ graph.createKeyIndex("dl_addr", Vertex.class);
+ }
+ if (!s.contains("flow_id")) {
+ graph.createKeyIndex("flow_id", Vertex.class);
+ }
+ if (!s.contains("flow_entry_id")) {
+ graph.createKeyIndex("flow_entry_id", Vertex.class);
+ }
+ if (!s.contains("switch_state")) {
+ graph.createKeyIndex("switch_state", Vertex.class);
+ }
+ graph.commit();
+ eg = new EventTransactionalGraph<TitanGraph>(graph);
+ }
+
+ class TransactionHandle {
+
+ protected TransactionalGraph tr;
+
+ public void create() {
+ tr = graph.newTransaction();
+ }
+ }
+
+ @Override
+ public FramedGraph getFramedGraph() {
+ if (isValid()) {
+ FramedGraph<TitanGraph> fg = new FramedGraph<TitanGraph>(graph);
+ return fg;
+ } else {
+ log.error("new FramedGraph failed");
+ return null;
+ }
+ }
+
+ @Override
+ public void addEventListener(LocalGraphChangedListener listener) {
+ EventTransactionalGraph<TitanGraph> eg = this.getEventGraph();
+ eg.addListener(listener);
+ log.debug("Registered listener {}", listener.getClass());
+ }
+
+ @Override
+ public Boolean isValid() {
+ return (graph != null || graph.isOpen());
+ }
+
+ @Override
+ public void commit() {
+ try {
+ graph.commit();
+ } catch (Exception e) {
+ log.error("{}", e.toString());
+ }
+ }
+
+ @Override
+ public void rollback() {
+ try {
+ graph.rollback();
+ } catch (Exception e) {
+ log.error("{}", e.toString());
+ }
+ }
+
+ @Override
+ public void close() {
+ commit();
+ }
+
+ /**
+ * Get EventTransactionalGraph of the titan graph.
+ *
+ * @return EventTransactionalGraph of the titan graph
+ */
+ private EventTransactionalGraph<TitanGraph> getEventGraph() {
+ if (isValid()) {
+ return eg;
+ } else {
+ return null;
+ }
+ }
+
+ private TitanDBConnection() {
+ }
+}
diff --git a/src/main/java/net/onrc/onos/graph/TitanDBOperation.java b/src/main/java/net/onrc/onos/graph/TitanDBOperation.java
new file mode 100644
index 0000000..26289bd
--- /dev/null
+++ b/src/main/java/net/onrc/onos/graph/TitanDBOperation.java
@@ -0,0 +1,169 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.onrc.onos.graph;
+
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.tinkerpop.blueprints.Vertex;
+import com.tinkerpop.frames.FramedGraph;
+import com.tinkerpop.frames.structures.FramedVertexIterable;
+import com.tinkerpop.gremlin.java.GremlinPipeline;
+import java.util.ArrayList;
+import java.util.List;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.*;
+import net.onrc.onos.ofcontroller.core.ISwitchStorage;
+import net.onrc.onos.ofcontroller.util.FlowEntryId;
+import net.onrc.onos.ofcontroller.util.FlowId;
+
+/**
+ *
+ * @author nickkaranatsios
+ */
+public class TitanDBOperation extends DBOperation {
+
+ /**
+ * Search and get a switch object with DPID.
+ *
+ * @param dpid DPID of the switch
+ */
+ @Override
+ public ISwitchObject searchSwitch(String dpid) {
+ final FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+
+ return searchSwitch(dpid, fg);
+ }
+
+ @Override
+ public IPortObject newPort(String dpid, Short portNum) {
+ return newPort(dpid, portNum);
+ }
+
+ @Override
+ public Iterable<ISwitchObject> getActiveSwitches() {
+ final FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+
+ return getActiveSwitches(fg);
+ }
+
+ @Override
+ public IPortObject searchPort(String dpid, Short number) {
+ final FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+ return searchPort(dpid, number, fg);
+ }
+
+
+ @Override
+ public void removePort(IPortObject port) {
+ FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+ if (fg != null) {
+ fg.removeVertex(port.asVertex());
+ }
+ }
+
+
+ @Override
+ public IDeviceObject searchDevice(String macAddr) {
+ // TODO Auto-generated method stub
+ FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+ return searchDevice(macAddr, fg);
+ }
+
+ @Override
+ public Iterable<IDeviceObject> getDevices() {
+ FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+ return fg != null ? fg.getVertices("type", "device", IDeviceObject.class) : null;
+ }
+
+ @Override
+ public void removeDevice(IDeviceObject dev) {
+ FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+ if (fg != null) {
+ fg.removeVertex(dev.asVertex());
+ }
+ }
+
+
+ @Override
+ public IFlowPath searchFlowPath(FlowId flowId) {
+ FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+ return searchFlowPath(flowId, fg);
+ }
+
+
+ @Override
+ public Iterable<IFlowPath> getAllFlowPaths() {
+ FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+ return getAllFlowPaths(fg);
+ }
+
+ @Override
+ public void removeFlowPath(IFlowPath flowPath) {
+ FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+ fg.removeVertex(flowPath.asVertex());
+ }
+
+ @Override
+ public IFlowEntry newFlowEntry() {
+ FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+ return newFlowEntry(fg);
+ }
+
+ @Override
+ public IFlowEntry searchFlowEntry(FlowEntryId flowEntryId) {
+ FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+
+ return fg.getVertices("flow_entry_id", flowEntryId.toString()).iterator().hasNext()
+ ? fg.getVertices("flow_entry_id", flowEntryId.toString(),
+ IFlowEntry.class).iterator().next() : null;
+ }
+
+ @Override
+ public Iterable<IFlowEntry> getAllFlowEntries() {
+ FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+
+ return fg.getVertices("type", "flow_entry", IFlowEntry.class);
+ }
+
+ @Override
+ public void removeFlowEntry(IFlowEntry flowEntry) {
+ FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+ fg.removeVertex(flowEntry.asVertex());
+ }
+
+ @Override
+ public IDBConnection getDBConnection() {
+ return conn;
+ }
+
+ @Override
+ public void commit() {
+ conn.commit();
+ }
+
+ @Override
+ public void rollback() {
+ conn.rollback();
+ }
+
+ @Override
+ public void close() {
+ conn.close();
+ }
+
+ /**
+ * Create a port having specified port number.
+ *
+ * @param portNumber port number
+ */
+ @Deprecated
+ public IPortObject newPort(Short portNumber) {
+ FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+ IPortObject obj = fg.addVertex(null, IPortObject.class);
+ if (obj != null) {
+ obj.setType("port");
+ obj.setNumber(portNumber);
+ }
+ return obj;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/ILinkStorage.java b/src/main/java/net/onrc/onos/ofcontroller/core/ILinkStorage.java
index 8889092..6b285f4 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/ILinkStorage.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/ILinkStorage.java
@@ -10,7 +10,7 @@
/*
* Init with Storage conf
*/
- public void init(String conf);
+ public void init(final String dbStore, final String conf);
/*
* Generic operation method
@@ -60,7 +60,8 @@
* @param dpid DPID of desired switch.
* @return List of reverse links. Empty list if no port was found.
*/
- public List<Link> getReverseLinks(String dpid);
+
+ public List<Link> getReverseLinks(String dpid);
public List<Link> getActiveLinks();
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapStorage.java b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapStorage.java
index b052540..2cf0e18 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapStorage.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapStorage.java
@@ -14,6 +14,6 @@
DELETE, // Delete the object
UPDATE // Update the object if exists or CREATE/INSERT if does not exist
}
- public void init(String conf);
+ public void init(final String dbStore, final String conf);
public void close();
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/ISwitchStorage.java b/src/main/java/net/onrc/onos/ofcontroller/core/ISwitchStorage.java
index 2cfab3f..8dd2f16 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/ISwitchStorage.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/ISwitchStorage.java
@@ -16,7 +16,8 @@
/*
* Initialize
*/
- public void init(String conf);
+ public void init(final String dbStore, final String conf);
+
/*
* Update the switch details
*/
@@ -39,7 +40,7 @@
public boolean deactivateSwitch(String dpid);
/*
* Update the port details
- */
+ */
public boolean updatePort(String dpid, short port, int state, String desc);
/*
* Associate a port on switch
@@ -49,7 +50,6 @@
* Delete a port on a switch by num
*/
public boolean deletePort(String dpid, short port);
-
/**
* Get list of all ports on the switch specified by given DPID.
*
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/internal/DeviceStorageImpl.java b/src/main/java/net/onrc/onos/ofcontroller/core/internal/DeviceStorageImpl.java
index fd9d535..9ba5ecf 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/internal/DeviceStorageImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/internal/DeviceStorageImpl.java
@@ -6,7 +6,9 @@
import net.floodlightcontroller.devicemanager.IDevice;
import net.floodlightcontroller.devicemanager.SwitchPort;
-import net.onrc.onos.graph.GraphDBOperation;
+import net.floodlightcontroller.packet.IPv4;
+import net.onrc.onos.graph.DBOperation;
+import net.onrc.onos.graph.GraphDBManager;
import net.onrc.onos.ofcontroller.core.IDeviceStorage;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IIpv4Address;
@@ -19,67 +21,72 @@
import com.google.common.collect.Lists;
import com.google.common.net.InetAddresses;
import com.thinkaurelius.titan.core.TitanException;
-
/**
* This is the class for storing the information of devices into CassandraDB
+ *
* @author Pankaj
*/
public class DeviceStorageImpl implements IDeviceStorage {
- protected final static Logger log = LoggerFactory.getLogger(DeviceStorageImpl.class);
-
- private GraphDBOperation ope;
- /***
- * Initialize function. Before you use this class, please call this method
- * @param conf configuration file for Cassandra DB
- */
+ private DBOperation ope;
+ protected final static Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
+ /**
+ * *
+ * Initialize function. Before you use this class, please call this method
+ *
+ * @param conf configuration file for Cassandra DB
+ */
@Override
- public void init(String conf) {
+ public void init(final String dbStore, final String conf) {
try {
- ope = new GraphDBOperation(conf);
- } catch (TitanException e) {
- log.error("Couldn't open graph operation", e);
+ ope = GraphDBManager.getDBOperation(dbStore, conf);
+ } catch (Exception e) {
+ log.error(e.getMessage());
}
- }
-
- /***
- * Finalize/close function. After you use this class, please call this method.
- * It will close the DB connection.
- */
+ }
+
+ /**
+ * *
+ * Finalize/close function. After you use this class, please call this
+ * method. It will close the DB connection.
+ */
@Override
public void close() {
ope.close();
}
-
- /***
- * Finalize/close function. After you use this class, please call this method.
- * It will close the DB connection. This is for Java garbage collection.
- */
+
+ /**
+ * *
+ * Finalize/close function. After you use this class, please call this
+ * method. It will close the DB connection. This is for Java garbage
+ * collection.
+ */
@Override
public void finalize() {
close();
}
- /***
- * This function is for adding the device into the DB.
- * @param device The device you want to add into the DB.
- * @return IDeviceObject which was added in the DB.
- */
+ /**
+ * *
+ * This function is for adding the device into the DB.
+ *
+ * @param device The device you want to add into the DB.
+ * @return IDeviceObject which was added in the DB.
+ */
@Override
public IDeviceObject addDevice(IDevice device) {
IDeviceObject obj = null;
- try {
- if ((obj = ope.searchDevice(device.getMACAddressString())) != null) {
- log.debug("Adding device {}: found existing device", device.getMACAddressString());
- } else {
- obj = ope.newDevice();
- log.debug("Adding device {}: creating new device", device.getMACAddressString());
- }
-
- changeDeviceAttachments(device, obj);
-
- changeDeviceIpv4Addresses(device, obj);
-
+ try {
+ if ((obj = ope.searchDevice(device.getMACAddressString())) != null) {
+ log.debug("Adding device {}: found existing device", device.getMACAddressString());
+ } else {
+ obj = ope.newDevice();
+ log.debug("Adding device {}: creating new device", device.getMACAddressString());
+ }
+ changeDeviceAttachments(device, obj);
+
+ changeDeviceIpv4Addresses(device, obj);
+
obj.setMACAddress(device.getMACAddressString());
obj.setType("device");
obj.setState("ACTIVE");
@@ -94,12 +101,13 @@
return obj;
}
-
- /***
- * This function is for updating the Device properties.
- * @param device The device you want to add into the DB.
- * @return IDeviceObject which was added in the DB.
- */
+ /**
+ * *
+ * This function is for updating the Device properties.
+ *
+ * @param device The device you want to add into the DB.
+ * @return IDeviceObject which was added in the DB.
+ */
@Override
public IDeviceObject updateDevice(IDevice device) {
return addDevice(device);
@@ -139,16 +147,18 @@
ope.removeDevice(deviceObject);
}
-
- /***
- * This function is for getting the Device from the DB by Mac address of the device.
- * @param mac The device mac address you want to get from the DB.
- * @return IDeviceObject you want to get.
- */
- @Override
- public IDeviceObject getDeviceByMac(String mac) {
- return ope.searchDevice(mac);
- }
+ /**
+ * *
+ * This function is for getting the Device from the DB by Mac address of the
+ * device.
+ *
+ * @param mac The device mac address you want to get from the DB.
+ * @return IDeviceObject you want to get.
+ */
+ @Override
+ public IDeviceObject getDeviceByMac(String mac) {
+ return ope.searchDevice(mac);
+ }
/***
* This function is for getting the Device from the DB by IP address of the device.
@@ -170,26 +180,28 @@
}
}
- /***
- * This function is for changing the Device attachment point.
- * @param device The device you want change the attachment point
- */
+ /**
+ * *
+ * This function is for changing the Device attachment point.
+ *
+ * @param device The device you want change the attachment point
+ */
@Override
public void changeDeviceAttachments(IDevice device) {
IDeviceObject obj = null;
- try {
- if ((obj = ope.searchDevice(device.getMACAddressString())) != null) {
- log.debug("Changing device ports {}: found existing device", device.getMACAddressString());
- changeDeviceAttachments(device, obj);
- ope.commit();
- } else {
- log.debug("failed to search device...now adding {}", device.getMACAddressString());
- addDevice(device);
- }
+ try {
+ if ((obj = ope.searchDevice(device.getMACAddressString())) != null) {
+ log.debug("Changing device ports {}: found existing device", device.getMACAddressString());
+ changeDeviceAttachments(device, obj);
+ ope.commit();
+ } else {
+ log.debug("failed to search device...now adding {}", device.getMACAddressString());
+ addDevice(device);
+ }
} catch (TitanException e) {
ope.rollback();
log.error(":addDevice mac:{} failed", device.getMACAddressString());
- }
+ }
}
/***
@@ -246,16 +258,15 @@
log.debug("Changing IP address for {} to {}", device.getMACAddressString(),
device.getIPv4Addresses());
IDeviceObject obj;
- try {
- if ((obj = ope.searchDevice(device.getMACAddressString())) != null) {
- changeDeviceIpv4Addresses(device, obj);
-
- ope.commit();
- } else {
- log.error(":changeDeviceIPv4Address mac:{} failed", device.getMACAddressString());
- }
- } catch (TitanException e) {
- ope.rollback();
+ try {
+ if ((obj = ope.searchDevice(device.getMACAddressString())) != null) {
+ changeDeviceIpv4Addresses(device, obj);
+ ope.commit();
+ } else {
+ log.error(":changeDeviceIPv4Address mac:{} failed", device.getMACAddressString());
+ }
+ } catch (TitanException e) {
+ ope.rollback();
log.error(":changeDeviceIPv4Address mac:{} failed due to exception {}", device.getMACAddressString(), e);
}
}
@@ -299,5 +310,4 @@
}
}
}
-
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImpl.java b/src/main/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImpl.java
index 7a3d43e..84a6c9c 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImpl.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.ILinkStorage;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
@@ -17,23 +17,23 @@
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.pipes.PipeFunction;
import com.tinkerpop.pipes.transform.PathPipe;
+import net.onrc.onos.graph.GraphDBManager;
/**
* This is the class for storing the information of links into GraphDB
*/
public class LinkStorageImpl implements ILinkStorage {
-
- protected final static Logger log = LoggerFactory.getLogger(LinkStorageImpl.class);
- protected GraphDBOperation op;
-
+ protected final static Logger log = LoggerFactory.getLogger(LinkStorageImpl.class);
+ protected DBOperation dbop;
+
/**
* Initialize the object. Open LinkStorage using given configuration file.
* @param conf Path (absolute path for now) to configuration file.
*/
@Override
- public void init(String conf) {
- this.op = new GraphDBOperation(conf);
+ public void init(final String dbStore, final String conf) {
+ this.dbop = GraphDBManager.getDBOperation(dbStore, conf);
}
// Method designing policy:
@@ -59,11 +59,11 @@
if (link != null) {
try {
if (addLinkImpl(link)) {
- op.commit();
+ dbop.commit();
success = true;
}
} catch (Exception e) {
- op.rollback();
+ dbop.rollback();
e.printStackTrace();
log.error("LinkStorageImpl:update {} link:{} failed", dmop, link);
}
@@ -73,11 +73,11 @@
if (link != null && linkinfo != null) {
try {
if (setLinkInfoImpl(link, linkinfo)) {
- op.commit();
+ dbop.commit();
success = true;
}
} catch (Exception e) {
- op.rollback();
+ dbop.rollback();
e.printStackTrace();
log.error("LinkStorageImpl:update {} link:{} failed", dmop, link);
}
@@ -87,15 +87,15 @@
if (link != null) {
try {
if (deleteLinkImpl(link)) {
- op.commit();
+ dbop.commit();
success = true;
log.debug("LinkStorageImpl:update {} link:{} succeeded", dmop, link);
} else {
- op.rollback();
+ dbop.rollback();
log.debug("LinkStorageImpl:update {} link:{} failed", dmop, link);
}
} catch (Exception e) {
- op.rollback();
+ dbop.rollback();
e.printStackTrace();
log.error("LinkStorageImpl:update {} link:{} failed", dmop, link);
}
@@ -120,18 +120,18 @@
// Set LinkInfo only if linfo is non-null.
if (linfo != null && (! setLinkInfoImpl(link, linfo))) {
log.debug("Adding linkinfo failed: {}", link);
- op.rollback();
+ dbop.rollback();
}
- op.commit();
+ dbop.commit();
success = true;
} else {
// If we fail here that's because the ports aren't added
// before we try to add the link
log.debug("Adding link failed: {}", link);
- op.rollback();
+ dbop.rollback();
}
} catch (Exception e) {
- op.rollback();
+ dbop.rollback();
e.printStackTrace();
log.error("LinkStorageImpl:addLink link:{} linfo:{} failed", link, linfo);
}
@@ -155,10 +155,10 @@
}
try {
- op.commit();
+ dbop.commit();
success = true;
} catch (Exception e) {
- op.rollback();
+ dbop.rollback();
e.printStackTrace();
log.error("LinkStorageImpl:addLinks link:s{} failed", links);
}
@@ -178,15 +178,15 @@
try {
if (deleteLinkImpl(lt)) {
- op.commit();
+ dbop.commit();
success = true;
log.debug("LinkStorageImpl:deleteLink(): deleted edges {}", lt);
} else {
- op.rollback();
+ dbop.rollback();
log.error("LinkStorageImpl:deleteLink(): failed invalid vertices {}", lt);
}
} catch (Exception e) {
- op.rollback();
+ dbop.rollback();
log.error("LinkStorageImpl:deleteLink(): failed {} {}",
new Object[]{lt, e.toString()});
e.printStackTrace();
@@ -206,14 +206,14 @@
try {
for (Link lt : links) {
if (! deleteLinkImpl(lt)) {
- op.rollback();
+ dbop.rollback();
return false;
}
}
- op.commit();
+ dbop.commit();
success = true;
} catch (Exception e) {
- op.rollback();
+ dbop.rollback();
e.printStackTrace();
log.error("LinkStorageImpl:deleteLinks failed invalid vertices {}", links);
}
@@ -231,7 +231,7 @@
public List<Link> getLinks(Long dpid, short port) {
List<Link> links = new ArrayList<Link>();
- IPortObject srcPort = op.searchPort(HexString.toHexString(dpid), port);
+ IPortObject srcPort = dbop.searchPort(HexString.toHexString(dpid), port);
if (srcPort == null)
return links;
ISwitchObject srcSw = srcPort.getSwitch();
@@ -260,7 +260,7 @@
public List<Link> getReverseLinks(Long dpid, short port) {
List<Link> links = new ArrayList<Link>();
- IPortObject srcPort = op.searchPort(HexString.toHexString(dpid), port);
+ IPortObject srcPort = dbop.searchPort(HexString.toHexString(dpid), port);
if (srcPort == null)
return links;
ISwitchObject srcSw = srcPort.getSwitch();
@@ -292,15 +292,15 @@
try {
for(Link l : linksToDelete) {
if (! deleteLinkImpl(l)) {
- op.rollback();
+ dbop.rollback();
log.error("LinkStorageImpl:deleteLinksOnPort dpid:{} port:{} failed", dpid, port);
return false;
}
}
- op.commit();
+ dbop.commit();
success = true;
} catch (Exception e) {
- op.rollback();
+ dbop.rollback();
e.printStackTrace();
log.error("LinkStorageImpl:deleteLinksOnPort dpid:{} port:{} failed", dpid, port);
}
@@ -317,7 +317,7 @@
public List<Link> getLinks(String dpid) {
List<Link> links = new ArrayList<Link>();
- ISwitchObject srcSw = op.searchSwitch(dpid);
+ ISwitchObject srcSw = dbop.searchSwitch(dpid);
if(srcSw != null) {
for(IPortObject srcPort : srcSw.getPorts()) {
@@ -347,7 +347,7 @@
public List<Link> getReverseLinks(String dpid) {
List<Link> links = new ArrayList<Link>();
- ISwitchObject srcSw = op.searchSwitch(dpid);
+ ISwitchObject srcSw = dbop.searchSwitch(dpid);
if(srcSw != null) {
for(IPortObject srcPort : srcSw.getPorts()) {
@@ -374,7 +374,7 @@
* @return List of active links. Empty list if no port was found.
*/
public List<Link> getActiveLinks() {
- Iterable<ISwitchObject> switches = op.getActiveSwitches();
+ Iterable<ISwitchObject> switches = dbop.getActiveSwitches();
List<Link> links = new ArrayList<Link>();
@@ -437,12 +437,12 @@
// get source port vertex
String dpid = HexString.toHexString(lt.getSrc());
short port = lt.getSrcPort();
- vportSrc = op.searchPort(dpid, port);
+ vportSrc = dbop.searchPort(dpid, port);
// get dest port vertex
dpid = HexString.toHexString(lt.getDst());
port = lt.getDstPort();
- vportDst = op.searchPort(dpid, port);
+ vportDst = dbop.searchPort(dpid, port);
if (vportSrc != null && vportDst != null) {
IPortObject portExist = null;
@@ -459,7 +459,7 @@
success = true;
} else {
log.debug("LinkStorageImpl:addLinkImpl failed link exists {} {} src {} dst {}",
- new Object[]{op, lt, vportSrc, vportDst});
+ new Object[]{dbop, lt, vportSrc, vportDst});
}
}
@@ -473,12 +473,12 @@
// get source port vertex
String dpid = HexString.toHexString(lt.getSrc());
short port = lt.getSrcPort();
- vportSrc = op.searchPort(dpid, port);
+ vportSrc = dbop.searchPort(dpid, port);
// get dst port vertex
dpid = HexString.toHexString(lt.getDst());
port = lt.getDstPort();
- vportDst = op.searchPort(dpid, port);
+ vportDst = dbop.searchPort(dpid, port);
// FIXME: This needs to remove all edges
if (vportSrc != null && vportDst != null) {
@@ -517,6 +517,4 @@
return l;
}
}
-
-
}
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 dcfdc73..8bc4fdd 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
@@ -4,8 +4,9 @@
import java.util.List;
import net.floodlightcontroller.core.IOFSwitch;
-import net.onrc.onos.graph.GraphDBConnection;
-import net.onrc.onos.graph.GraphDBOperation;
+import net.onrc.onos.graph.DBOperation;
+import net.onrc.onos.graph.GraphDBManager;
+import net.onrc.onos.ofcontroller.core.ISwitchStorage;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
@@ -21,19 +22,22 @@
* This is the class for storing the information of switches into GraphDB
*/
public class SwitchStorageImpl implements ISwitchStorage {
- protected GraphDBOperation op;
+
+ protected DBOperation op;
protected final static Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
-
- /***
- * Initialize function. Before you use this class, please call this method
- * @param conf configuration file for Cassandra DB
- */
+
+ /**
+ * *
+ * Initialize function. Before you use this class, please call this method
+ *
+ * @param conf configuration file for Cassandra DB
+ */
@Override
- public void init(String conf) {
- GraphDBConnection conn = GraphDBConnection.getInstance(conf);
- op = new GraphDBOperation(conn);
+ public void init(final String dbStore, final String conf) {
+ op = GraphDBManager.getDBOperation(dbStore, conf);
}
+
/***
* Finalize/close function. After you use this class, please call this method.
* It will close the DB connection.
@@ -155,7 +159,7 @@
// XXX for now delete devices when we change a port to prevent
// having stale devices.
DeviceStorageImpl deviceStorage = new DeviceStorageImpl();
- deviceStorage.init("");
+ deviceStorage.init("","");
for (IPortObject portObject : curr.getPorts()) {
for (IDeviceObject deviceObject : portObject.getDevices()) {
// The deviceStorage has to remove on the object gained by its own
@@ -309,7 +313,7 @@
// XXX for now delete devices when we change a port to prevent
// having stale devices.
DeviceStorageImpl deviceStorage = new DeviceStorageImpl();
- deviceStorage.init("");
+ deviceStorage.init("","");
for (IDeviceObject deviceObject : portObject.getDevices()) {
deviceStorage.removeDevice(deviceObject);
@@ -339,7 +343,7 @@
boolean success = false;
DeviceStorageImpl deviceStorage = new DeviceStorageImpl();
- deviceStorage.init("");
+ deviceStorage.init("","");
try {
ISwitchObject sw = op.searchSwitch(dpid);
@@ -500,4 +504,5 @@
port.getPortId());
}
}
+
}
\ No newline at end of file
diff --git a/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/NetworkGraphPublisher.java b/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/NetworkGraphPublisher.java
index 104032b..5a2fc7f 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/NetworkGraphPublisher.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/NetworkGraphPublisher.java
@@ -28,9 +28,10 @@
import net.floodlightcontroller.devicemanager.IDeviceService;
import net.floodlightcontroller.routing.Link;
import net.floodlightcontroller.threadpool.IThreadPoolService;
+import net.onrc.onos.graph.DBOperation;
+import net.onrc.onos.graph.DBConnection;
+import net.onrc.onos.graph.GraphDBManager;
import net.onrc.onos.datagrid.IDatagridService;
-import net.onrc.onos.graph.GraphDBConnection;
-import net.onrc.onos.graph.GraphDBOperation;
import net.onrc.onos.graph.IDBConnection;
import net.onrc.onos.graph.LocalTopologyEventListener;
import net.onrc.onos.ofcontroller.core.IDeviceStorage;
@@ -65,9 +66,10 @@
protected final static Logger log = LoggerFactory.getLogger(NetworkGraphPublisher.class);
protected IDeviceService deviceService;
protected IControllerRegistryService registryService;
- protected GraphDBOperation op;
+ protected DBOperation op;
protected static final String DBConfigFile = "dbconf";
+ protected static final String GraphDBStore = "graph_db_store";
protected static final String CleanupEnabled = "EnableCleanup";
protected IThreadPoolService threadPool;
protected IFloodlightProviderService floodlightProvider;
@@ -436,7 +438,8 @@
throws FloodlightModuleException {
Map<String, String> configMap = context.getConfigParams(this);
String conf = configMap.get(DBConfigFile);
- op = new GraphDBOperation(conf);
+ String dbStore = configMap.get(GraphDBStore);
+ op = GraphDBManager.getDBOperation(dbStore, conf);
floodlightProvider =
context.getServiceImpl(IFloodlightProviderService.class);
@@ -447,13 +450,13 @@
datagridService = context.getServiceImpl(IDatagridService.class);
devStore = new DeviceStorageImpl();
- devStore.init(conf);
+ devStore.init(dbStore, conf);
swStore = new SwitchStorageImpl();
- swStore.init(conf);
+ swStore.init(dbStore, conf);
linkStore = new LinkStorageImpl();
- linkStore.init(conf);
+ linkStore.init(dbStore, conf);
log.debug("Initializing NetworkGraphPublisher module with {}", conf);
@@ -470,7 +473,7 @@
log.debug("Adding EventListener");
IDBConnection conn = op.getDBConnection();
- conn.addEventListener(new LocalTopologyEventListener((GraphDBConnection) conn));
+ conn.addEventListener(new LocalTopologyEventListener((DBConnection) conn));
// Setup the Cleanup task.
if (cleanupNeeded == null || !cleanupNeeded.equals("False")) {
ScheduledExecutorService ses = threadPool.getScheduledExecutor();
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
index 45e8a6f..db1e588 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
@@ -20,8 +20,9 @@
import net.floodlightcontroller.core.module.IFloodlightService;
import net.floodlightcontroller.restserver.IRestApiService;
import net.floodlightcontroller.util.OFMessageDamper;
+import net.onrc.onos.graph.DBOperation;
+import net.onrc.onos.graph.GraphDBManager;
import net.onrc.onos.datagrid.IDatagridService;
-import net.onrc.onos.graph.GraphDBOperation;
import net.onrc.onos.ofcontroller.core.INetMapStorage;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
@@ -42,8 +43,7 @@
// flag to use FlowPusher instead of FlowSwitchOperation/MessageDamper
private final static boolean enableFlowPusher = false;
- protected GraphDBOperation dbHandlerApi;
- protected GraphDBOperation dbHandlerInner;
+ protected DBOperation op;
protected volatile IFloodlightProviderService floodlightProvider;
protected volatile IDatagridService datagridService;
@@ -81,9 +81,9 @@
* @param conf the Graph Database configuration string.
*/
@Override
- public void init(String conf) {
- dbHandlerApi = new GraphDBOperation(conf);
- dbHandlerInner = new GraphDBOperation(conf);
+ public void init(final String dbStore, final String conf) {
+ op = GraphDBManager.getDBOperation(dbStore, conf);
+ topoRouteService = new TopoRouteService(dbStore, conf);
}
/**
@@ -170,7 +170,7 @@
OFMESSAGE_DAMPER_TIMEOUT);
}
- this.init("");
+ this.init("","");
}
/**
diff --git a/src/main/java/net/onrc/onos/ofcontroller/topology/ShortestPath.java b/src/main/java/net/onrc/onos/ofcontroller/topology/ShortestPath.java
index f187c27..393e16f 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/topology/ShortestPath.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/topology/ShortestPath.java
@@ -9,7 +9,7 @@
import java.util.Queue;
import java.util.Set;
-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.ISwitchStorage.SwitchState;
import net.onrc.onos.ofcontroller.util.DataPath;
@@ -22,6 +22,7 @@
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Vertex;
+import net.onrc.onos.graph.GraphDBManager;
/**
* Class to calculate a shortest DataPath between 2 SwitchPorts
@@ -160,7 +161,7 @@
* @return the data path with the computed shortest path if
* found, otherwise null.
*/
- public static DataPath getDatabaseShortestPath(GraphDBOperation dbHandler,
+ public static DataPath getDatabaseShortestPath(DBOperation dbHandler,
SwitchPort src, SwitchPort dest) {
DataPath result_data_path = new DataPath();
@@ -323,4 +324,4 @@
return null;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java b/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java
index 0d33b27..839ba28 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java
@@ -19,6 +19,11 @@
@Get("json")
public DataPath retrieve() {
+<<<<<<< HEAD
+ ITopoRouteService topoRouteService = new TopoRouteService("titan", "");
+ if (topoRouteService == null) {
+ log.debug("Topology Route Service not found");
+=======
// Get the services that are needed for the computation
ITopologyNetService topologyNetService =
(ITopologyNetService)getContext().getAttributes().
@@ -33,6 +38,7 @@
}
if (flowService == null) {
log.debug("Flow Service not found");
+>>>>>>> master
return null;
}
diff --git a/src/test/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImplTest.java b/src/test/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImplTest.java
index 4aea22a..0081264 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImplTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImplTest.java
@@ -118,7 +118,7 @@
mockToPortInfoMap = new HashMap<IPortObject,PortInfo>();
linkStorage = new LinkStorageImpl();
- linkStorage.init("/dummy/path/to/conf");
+ linkStorage.init("dummyStore", "/dummy/path/to/conf");
initLinks();
}
diff --git a/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTest.java b/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTest.java
index 6f4f850..c308b7f 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTest.java
@@ -34,6 +34,7 @@
protected static org.slf4j.Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
String conf;
+ String dbStore;
private GraphDBConnection mockConn = null;
private GraphDBOperation mockOpe = null;
ISwitchStorage swSt = null;
@@ -42,6 +43,7 @@
public void setUp() throws Exception {
swSt = new SwitchStorageImpl();
+ dbStore = "dummyStore";
conf = "/dummy/path/to/db";
// Make mock cassandra DB
@@ -95,7 +97,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
}
@@ -129,7 +131,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.addSwitch(dpid);
}
@@ -153,7 +155,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
}
@@ -185,7 +187,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
}
@@ -217,8 +219,13 @@
mockOpe.close();
replay(mockOpe);
+<<<<<<< HEAD
+ swSt.init(dbStore, conf);
+ swSt.update(dpid, stateINACTIVE, opUPDATE);
+=======
swSt.init(conf);
swSt.updateSwitch(dpid, stateINACTIVE, opUPDATE);
+>>>>>>> master
}
/**
@@ -250,8 +257,13 @@
mockOpe.close();
replay(mockOpe);
+<<<<<<< HEAD
+ swSt.init(dbStore, conf);
+ swSt.update(dpid, stateINACTIVE, opCREATE);
+=======
swSt.init(conf);
swSt.updateSwitch(dpid, stateINACTIVE, opCREATE);
+>>>>>>> master
}
/**
@@ -283,8 +295,13 @@
mockOpe.close();
replay(mockOpe);
+<<<<<<< HEAD
+ swSt.init(dbStore, conf);
+ swSt.update(dpid, stateINACTIVE, opINSERT);
+=======
swSt.init(conf);
swSt.updateSwitch(dpid, stateINACTIVE, opINSERT);
+>>>>>>> master
}
/**
@@ -319,7 +336,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.updateSwitch(dpid, stateACTIVE, opDELETE);
}
@@ -354,7 +371,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.deleteSwitch(dpid);
@@ -393,7 +410,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.deleteSwitch(dpid);
}
@@ -446,7 +463,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.addPort(dpid, portToAdd);
}
@@ -502,7 +519,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.addPort(dpid, portToAdd);
}
@@ -541,7 +558,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addPort(dpid, portToAdd);
}
@@ -593,7 +610,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.addPort(dpid, portToAdd);
}
@@ -648,7 +665,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.addPort(dpid, portToAdd);
}
@@ -711,7 +728,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.addPort(dpid, portToAdd);
swSt.deletePort(dpid, portNumber);
@@ -778,7 +795,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.addPort(dpid, portToAdd);
swSt.deletePort(dpid, portNumber);
diff --git a/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTestBB.java b/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTestBB.java
index 7edc1c5..c76022c 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTestBB.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImplTestBB.java
@@ -5,6 +5,11 @@
import net.floodlightcontroller.core.internal.TestDatabaseManager;
import net.onrc.onos.graph.GraphDBConnection;
import net.onrc.onos.graph.GraphDBOperation;
+<<<<<<< HEAD
+import net.onrc.onos.ofcontroller.core.ISwitchStorage;
+import net.onrc.onos.ofcontroller.core.ISwitchStorage.SwitchState;
+=======
+>>>>>>> master
import net.onrc.onos.ofcontroller.core.INetMapStorage;
import net.onrc.onos.ofcontroller.core.INetMapStorage.DM_OPERATION;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
@@ -49,6 +54,7 @@
protected static org.slf4j.Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
String conf;
+ String dbStore;
private GraphDBConnection conn = null;
private GraphDBOperation ope = null;
private TitanGraph titanGraph = null;
@@ -59,6 +65,7 @@
swSt = new SwitchStorageImpl();
conf = "/dummy/path/to/db";
+ dbStore ="dummyStore";
// Make mock cassandra DB
// Replace TitanFactory.open() to return mock DB
@@ -71,7 +78,7 @@
conn = GraphDBConnection.getInstance(conf);
ope = new GraphDBOperation(conn);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
}
@After
diff --git a/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableLinkStorageImpl.java b/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableLinkStorageImpl.java
index ecba546..8411b22 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableLinkStorageImpl.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableLinkStorageImpl.java
@@ -2,7 +2,6 @@
import java.util.Set;
-import net.onrc.onos.ofcontroller.core.internal.LinkStorageImpl;
import com.thinkaurelius.titan.core.TitanGraph;
import com.tinkerpop.blueprints.TransactionalGraph.Conclusion;
@@ -27,7 +26,7 @@
}
@Override
- public void init(String conf){
+ public void init(final String dbStore, final String conf){
Set<String> s = graph.getIndexedKeys(Vertex.class);
if (!s.contains("dpid")) {
graph.createKeyIndex("dpid", Vertex.class);
diff --git a/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableSwitchStorageImpl.java b/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableSwitchStorageImpl.java
index e0b34e1..82d1faf 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableSwitchStorageImpl.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableSwitchStorageImpl.java
@@ -18,9 +18,9 @@
}
@Override
- public void init(String conf){
+ public void init(final String dbStore, final String conf){
- super.init(conf);
+ super.init(dbStore, conf);
}
}
diff --git a/src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTest.java b/src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTest.java
index 44573bc..4fbf5e1 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTest.java
@@ -46,6 +46,7 @@
protected final static Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
String conf;
+ String dbStore;
DeviceStorageImpl deviceImpl;
private GraphDBConnection mockConn;
private GraphDBOperation mockOpe;
@@ -54,6 +55,7 @@
public void setUp() throws Exception {
deviceImpl = new DeviceStorageImpl();
conf = "/dummy/path/to/db";
+ dbStore = "dummyStore";
PowerMock.mockStatic(GraphDBConnection.class);
mockConn = createMock(GraphDBConnection.class);
@@ -241,6 +243,7 @@
assertNotNull(addedObject);
verify(mockDeviceObject);
+
}
/**
diff --git a/src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTestBB.java b/src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTestBB.java
index c7c74a5..b207b9b 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTestBB.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/devicemanager/internal/DeviceStorageImplTestBB.java
@@ -54,6 +54,7 @@
protected static org.slf4j.Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
String conf;
+ String dbStore;
private GraphDBConnection conn = null;
private GraphDBOperation ope = null;
private TitanGraph titanGraph = null;
@@ -64,6 +65,7 @@
deviceImpl = new DeviceStorageImpl();
conf = "/dummy/path/to/db";
+ dbStore = "dummyStore";
// Make mock cassandra DB
// Replace TitanFactory.open() to return mock DB
@@ -76,7 +78,7 @@
conn = GraphDBConnection.getInstance(conf);
ope = new GraphDBOperation(conn);
- deviceImpl.init(conf);
+ deviceImpl.init(dbStore, conf);
}
@After
diff --git a/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java b/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java
index 881ff7c..c2db225 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java
@@ -620,7 +620,7 @@
// start the test
replayAll();
- fm.init("/dummy/path");
+ fm.init("dummy_store", "/dummy/path");
// verify the test
verifyAll();
diff --git a/src/test/java/net/onrc/onos/ofcontroller/topology/TopologyManagerTest.java b/src/test/java/net/onrc/onos/ofcontroller/topology/TopologyManagerTest.java
index 09d0a00..0461d72 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/topology/TopologyManagerTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/topology/TopologyManagerTest.java
@@ -17,7 +17,10 @@
import com.thinkaurelius.titan.core.TitanGraph;
import com.thinkaurelius.titan.core.TitanFactory;
+import net.onrc.onos.graph.DBConnection;
+import net.onrc.onos.graph.DBOperation;
import net.onrc.onos.graph.GraphDBConnection;
+import net.onrc.onos.graph.GraphDBManager;
import net.onrc.onos.graph.GraphDBOperation;
import net.onrc.onos.ofcontroller.core.internal.TestDatabaseManager;
import net.onrc.onos.ofcontroller.topology.TopologyManager;
@@ -35,8 +38,9 @@
@PrepareForTest({TitanFactory.class, GraphDBConnection.class, GraphDBOperation.class, TopologyManager.class})
public class TopologyManagerTest {
String conf;
- private GraphDBConnection conn = null;
- private GraphDBOperation oper = null;
+ String dbStore;
+ private DBConnection conn = null;
+ private DBOperation oper = null;
private TitanGraph titanGraph = null;
private TopologyManager topologyManager = null;
@@ -45,6 +49,7 @@
*/
@Before
public void setUp() throws Exception {
+ dbStore = "dummyStore";
conf = "/dummy/path/to/db";
//
@@ -56,9 +61,9 @@
EasyMock.expect(TitanFactory.open((String)EasyMock.anyObject())).andReturn(titanGraph);
PowerMock.replay(TitanFactory.class);
+ oper = GraphDBManager.getDBOperation(dbStore, conf);
// Create the connection to the database
- conn = GraphDBConnection.getInstance(conf);
- oper = new GraphDBOperation(conn);
+ conn = GraphDBManager.getConnection(dbStore, conf);
// Populate the database
TestDatabaseManager.populateTestData(titanGraph);