Merge from upstream/master
diff --git a/conf/onos.properties b/conf/onos.properties
index b748b40..ec04622 100644
--- a/conf/onos.properties
+++ b/conf/onos.properties
@@ -13,5 +13,7 @@
net.floodlightcontroller.core.FloodlightProvider.workerthreads = 16
net.floodlightcontroller.forwarding.Forwarding.idletimeout = 5
net.floodlightcontroller.forwarding.Forwarding.hardtimeout = 0
-net.onrc.onos.ofcontroller.floodlightlistener.NetworkGraphPublisher.dbconf = /tmp/cassandra.titan
+#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/conf/ramcloud.conf b/conf/ramcloud.conf
new file mode 100644
index 0000000..84b4ff2
--- /dev/null
+++ b/conf/ramcloud.conf
@@ -0,0 +1 @@
+ramcloud.coordinator=fast+udp:host=10.128.100.36,port=12246
diff --git a/lib/blueprints-ramcloud-graph-2.4.0.jar b/lib/blueprints-ramcloud-graph-2.4.0.jar
new file mode 100644
index 0000000..f796c94
--- /dev/null
+++ b/lib/blueprints-ramcloud-graph-2.4.0.jar
Binary files differ
diff --git a/lib/blueprints-ramcloud-graph-2.5.0.jar b/lib/blueprints-ramcloud-graph-2.5.0.jar
new file mode 100644
index 0000000..7d0080c
--- /dev/null
+++ b/lib/blueprints-ramcloud-graph-2.5.0.jar
Binary files differ
diff --git a/pom.xml b/pom.xml
index ebed868..af6c709 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
<artifactId>onos</artifactId>
<version>0.1.0</version>
<packaging>jar</packaging>
- <name>ONOS</name>
+ <name>ONOS-RAMLCloud</name>
<url>http://onlab.us/</url>
<repositories>
<repository>
@@ -254,7 +254,12 @@
<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>
@@ -422,5 +427,10 @@
<version>0.1.0</version>
</dependency>
-->
+ <dependency>
+ <groupId>com.tinkerpop.blueprints.impls.ramcloud</groupId>
+ <artifactId>blueprints-ramcloud-graph</artifactId>
+ <version>2.5.0</version>
+ </dependency>
</dependencies>
</project>
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..c0666b7
--- /dev/null
+++ b/src/main/java/net/onrc/onos/graph/DBOperation.java
@@ -0,0 +1,413 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.onrc.onos.graph;
+
+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.IBaseObject;
+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.IIpv4Address;
+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.FlowEntryId;
+import net.onrc.onos.ofcontroller.util.FlowId;
+
+/**
+ *
+ * @author nickkaranatsios
+ */
+public abstract class DBOperation implements IDBOperation {
+
+ protected DBConnection conn;
+
+ /**
+ * Search and get an active switch object with DPID.
+ * @param dpid DPID of the switch
+ */
+ @Override
+ public ISwitchObject searchActiveSwitch(String dpid) {
+ ISwitchObject sw = searchSwitch(dpid);
+ if ((sw != null)
+ && sw.getState().equals(ISwitchStorage.SwitchState.ACTIVE.toString())) {
+ return sw;
+ }
+ return null;
+ }
+
+ /**
+ * Create a new switch and return the created switch object.
+ * @param dpid DPID of the switch
+ */
+ @Override
+ public ISwitchObject newSwitch(final String dpid) {
+ //System.out.println("newSwitch");
+ ISwitchObject obj = (ISwitchObject) conn.getFramedGraph().addVertex(null, ISwitchObject.class);
+ if (obj != null) {
+ obj.setType("switch");
+ obj.setDPID(dpid);
+ }
+ return obj;
+ }
+
+ /**
+ * Get all switch objects.
+ */
+ @Override
+ public Iterable<ISwitchObject> getAllSwitches() {
+ //System.out.println("getAllSwitches");
+ Iterable<ISwitchObject> switches = conn.getFramedGraph().getVertices("type", "switch", ISwitchObject.class);
+ return switches;
+ }
+
+ /**
+ * Get all inactive switch objects.
+ */
+ @Override
+ public Iterable<ISwitchObject> getInactiveSwitches() {
+ //System.out.println("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;
+ }
+
+ /**
+ * Get all flow entries objects where their switches are not updated.
+ */
+ @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);
+
+ }
+
+ /**
+ * Remove specified switch.
+ * @param sw switch object to remove
+ */
+ @Override
+ public void removeSwitch(ISwitchObject sw) {
+ //System.out.println("removeSwitch");
+ conn.getFramedGraph().removeVertex(sw.asVertex());
+ }
+
+ @Override
+ public IPortObject newPort(String dpid, Short portNum) {
+ //System.out.println("newPort");
+ 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;
+ }
+
+ /**
+ * Create a port having specified port number.
+ *
+ * @param portNumber port number
+ */
+ @Deprecated
+ public IPortObject newPort(Short portNumber) {
+ IPortObject obj = (IPortObject) conn.getFramedGraph().addVertex(null, IPortObject.class);
+ if (obj != null) {
+ obj.setType("port");
+ obj.setNumber(portNumber);
+ }
+ return obj;
+ }
+
+ /**
+ * Search and get a port object of specified switch and port number.
+ * @param dpid DPID of a switch
+ * @param number port number of the switch's port
+ */
+ @Override
+ public IPortObject searchPort(String dpid, Short number) {
+ //System.out.println("searchPort");
+ String id = dpid + number.toString();
+ return (conn.getFramedGraph() != null && conn.getFramedGraph().getVertices("port_id", id).iterator().hasNext())
+ ? (IPortObject) conn.getFramedGraph().getVertices("port_id", id, IPortObject.class).iterator().next() : null;
+
+ }
+
+ /**
+ * Remove the specified switch port.
+ * @param port switch port object to remove
+ */
+ @Override
+ public void removePort(IPortObject port) {
+ //System.out.println("removeProt");
+ if (conn.getFramedGraph() != null) {
+ conn.getFramedGraph().removeVertex(port.asVertex());
+ }
+ }
+
+ /**
+ * Create and return a device object.
+ */
+ @Override
+ public IDeviceObject newDevice() {
+ //System.out.println("newDevice");
+ IDeviceObject obj = (IDeviceObject) conn.getFramedGraph().addVertex(null, IDeviceObject.class);
+ if (obj != null) {
+ obj.setType("device");
+ }
+ return obj;
+ }
+
+ /**
+ * Get all devices.
+ */
+ @Override
+ public Iterable<IDeviceObject> getDevices() {
+ //System.out.println("getDeiveces");
+ return conn.getFramedGraph() != null ? conn.getFramedGraph().getVertices("type", "device", IDeviceObject.class) : null;
+ }
+
+ /**
+ * Remove the specified device.
+ * @param dev a device object to remove
+ */
+ @Override
+ public void removeDevice(IDeviceObject dev) {
+ //System.out.println("removeDevice");
+ if (conn.getFramedGraph() != null) {
+ conn.getFramedGraph().removeVertex(dev.asVertex());
+ }
+ }
+
+ /**
+ * Create and return a flow path object.
+ */
+ @Override
+ public IFlowPath newFlowPath() {
+ //System.out.println("newFlowPath");
+ IFlowPath flowPath = (IFlowPath)conn.getFramedGraph().addVertex(null, IFlowPath.class);
+ //System.out.println("flowPath : " + flowPath);
+ if (flowPath != null) {
+ flowPath.setType("flow");
+ }
+ return flowPath;
+ }
+
+ /**
+ * Get a flow path object with a flow entry.
+ * @param flowEntry flow entry object
+ */
+ @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;
+ }
+
+
+ /**
+ * Search and get a switch object with DPID.
+ *
+ * @param dpid DPID of the switch
+ */
+ @Override
+ public ISwitchObject searchSwitch(final String dpid) {
+ //System.out.println("searchSwitch");
+ return (conn.getFramedGraph() != null && conn.getFramedGraph().getVertices("dpid", dpid).iterator().hasNext())
+ ? (ISwitchObject) (conn.getFramedGraph().getVertices("dpid", dpid, ISwitchObject.class).iterator().next()) : null;
+ }
+
+ /**
+ * Get all active switch objects.
+ */
+ @Override
+ public Iterable<ISwitchObject> getActiveSwitches() {
+ Iterable<ISwitchObject> switches = conn.getFramedGraph().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;
+ }
+
+ /**
+ * Search and get a device object having specified MAC address.
+ * @param macAddr MAC address to search and get
+ */
+ @Override
+ public IDeviceObject searchDevice(String macAddr) {
+ return (conn.getFramedGraph() != null && conn.getFramedGraph().getVertices("dl_addr", macAddr).iterator().hasNext())
+ ? (IDeviceObject) conn.getFramedGraph().getVertices("dl_addr", macAddr, IDeviceObject.class).iterator().next() : null;
+
+ }
+
+ /**
+ * Search and get a flow path object with specified flow ID.
+ * @param flowId flow ID to search
+ */
+ @Override
+ public IFlowPath searchFlowPath(final FlowId flowId) {
+ //System.out.println("searchFlowPath");
+ return conn.getFramedGraph().getVertices("flow_id", flowId.toString()).iterator().hasNext()
+ ? (IFlowPath) conn.getFramedGraph().getVertices("flow_id", flowId.toString(),
+ IFlowPath.class).iterator().next() : null;
+ }
+
+ /**
+ * Get all flow path objects.
+ */
+ @Override
+ public Iterable<IFlowPath> getAllFlowPaths() {
+ //System.out.println("getAllFlowPaths");
+ Iterable<IFlowPath> flowPaths = conn.getFramedGraph().getVertices("type", "flow", IFlowPath.class);
+
+ List<IFlowPath> nonNullFlows = new ArrayList<IFlowPath>();
+
+ for (IFlowPath fp : flowPaths) {
+ if (fp.getFlowId() != null) {
+ nonNullFlows.add(fp);
+ }
+ }
+ return nonNullFlows;
+ }
+
+ /**
+ * Remove the specified flow path.
+ * @param flowPath flow path object to remove
+ */
+ @Override
+ public void removeFlowPath(IFlowPath flowPath) {
+ //System.out.println("removeFlowPath");
+ conn.getFramedGraph().removeVertex(flowPath.asVertex());
+ }
+
+ /**
+ * Search and get a flow entry object with flow entry ID.
+ * @param flowEntryId flow entry ID to search
+ */
+ @Override
+ public IFlowEntry searchFlowEntry(FlowEntryId flowEntryId) {
+ //System.out.println("searchFlowEntry");
+ return conn.getFramedGraph().getVertices("flow_entry_id", flowEntryId.toString()).iterator().hasNext()
+ ? (IFlowEntry)conn.getFramedGraph().getVertices("flow_entry_id", flowEntryId.toString(),
+ IFlowEntry.class).iterator().next() : null;
+ }
+
+ /**
+ * Get all flow entry objects.
+ */
+ @Override
+ public Iterable<IFlowEntry> getAllFlowEntries() {
+ return conn.getFramedGraph().getVertices("type", "flow_entry", IFlowEntry.class);
+ }
+
+ /**
+ * Remove the specified flow entry.
+ * @param flowEntry flow entry object to remove
+ */
+ @Override
+ public void removeFlowEntry(IFlowEntry flowEntry) {
+ //System.out.println("removeFlowEntry");
+ conn.getFramedGraph().removeVertex(flowEntry.asVertex());
+ }
+
+ /**
+ * Create and return a flow entry object.
+ */
+ @Override
+ public IFlowEntry newFlowEntry() {
+ //System.out.println("newFlowEntry");
+ IFlowEntry flowEntry = (IFlowEntry) conn.getFramedGraph().addVertex(null, IFlowEntry.class);
+ if (flowEntry != null) {
+ flowEntry.setType("flow_entry");
+ }
+ return flowEntry;
+ }
+
+
+ public IIpv4Address newIpv4Address() {
+ return newVertex("ipv4Address", IIpv4Address.class);
+ }
+
+ private <T extends IBaseObject> T newVertex(String type, Class<T> vertexType) {
+ T newVertex = (T) conn.getFramedGraph().addVertex(null, vertexType);
+ if (newVertex != null) {
+ newVertex.setType(type);
+ }
+ return newVertex;
+ }
+
+ public IIpv4Address searchIpv4Address(int intIpv4Address) {
+ return searchForVertex("ipv4_address", intIpv4Address, IIpv4Address.class);
+ }
+
+
+ public IIpv4Address ensureIpv4Address(int intIpv4Address) {
+ IIpv4Address ipv4Vertex = searchIpv4Address(intIpv4Address);
+ if (ipv4Vertex == null) {
+ ipv4Vertex = newIpv4Address();
+ ipv4Vertex.setIpv4Address(intIpv4Address);
+ }
+ return ipv4Vertex;
+ }
+
+
+ private <T> T searchForVertex(String propertyName, Object propertyValue, Class<T> vertexType) {
+ if (conn.getFramedGraph() != null) {
+ Iterator<T> it = conn.getFramedGraph().getVertices(propertyName, propertyValue, vertexType).iterator();
+ if (it.hasNext()) {
+ return it.next();
+ }
+ }
+ return null;
+ }
+
+ public void removeIpv4Address(IIpv4Address ipv4Address) {
+ //System.out.println("removeIpv4Address");
+ conn.getFramedGraph().removeVertex(ipv4Address.asVertex());
+ }
+
+ /**
+ * Get the instance of GraphDBConnection assigned to this class.
+ */
+ @Override
+ public IDBConnection getDBConnection() {
+ return conn;
+ }
+
+ @Override
+ public void commit() {
+ conn.commit();
+ }
+
+ @Override
+ public void rollback() {
+ conn.rollback();
+ }
+
+ @Override
+ public void close() {
+ conn.close();
+ }
+}
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..ec7eb7f
--- /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>>();
+ private static DBOperation operation = null;
+
+ 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) {
+ 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;
+ }
+
+ 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 40f5044..2778b55 100644
--- a/src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java
+++ b/src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java
@@ -9,13 +9,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;
}
@@ -33,7 +35,6 @@
}
- @Override
public void edgeRemoved(Edge e) {
// TODO Auto-generated method stub
// Fire NetMapEvents (LinkRemoved, FlowEntryRemoved, HostRemoved, PortRemoved)
@@ -42,9 +43,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(),
@@ -71,7 +72,6 @@
}
- @Override
public void vertexRemoved(Vertex vertex) {
// TODO Auto-generated method stub
// Generate NetMapEvents
@@ -80,7 +80,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());
// NOTE: Old code/logic.
@@ -105,4 +105,11 @@
}
+ public void vertexRemoved(Vertex vertex, Map<String, Object> props) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ 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..4728e61
--- /dev/null
+++ b/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java
@@ -0,0 +1,126 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package net.onrc.onos.graph;
+
+import com.tinkerpop.blueprints.Vertex;
+import com.tinkerpop.blueprints.impls.ramcloud.RamCloudGraph;
+import com.tinkerpop.frames.FramedGraph;
+import java.io.File;
+import java.util.Set;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author nickkaranatsios
+ */
+public class RamCloudDBConnection extends DBConnection {
+ private RamCloudGraph graph;
+ private static Logger log = LoggerFactory.getLogger(RamCloudDBConnection.class);
+
+ //private static final ThreadLocal<RamCloudGraph> RamCloudThreadLocal = new ThreadLocal<RamCloudGraph>();
+
+ public RamCloudDBConnection(final String dbConfigFile) {
+ //final String coordinatorURL = open(getConfiguration(new File(dbConfigFile)));
+ //System.out.println("coordinatorURL "+ coordinatorURL);
+ //graph = new RamCloudGraph(coordinatorURL);
+ //graph = RamCloudThreadLocal.get();
+ //System.out.println("ThreadId = " + Thread.currentThread().getId() + " graph = " + graph);
+ graph = new RamCloudGraph("fast+udp:host=10.128.4.104,port=12246");
+ 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);
+ }
+ }
+
+ @Override
+ public FramedGraph getFramedGraph() {
+ if (isValid()) {
+ FramedGraph<RamCloudGraph> fg = new FramedGraph<RamCloudGraph>(graph);
+ return fg;
+ } else {
+ log.error("new FramedGraph failed");
+ return null;
+ }
+ }
+
+ @Override
+ public void addEventListener(LocalGraphChangedListener listener) {
+ //TO-DO
+ }
+
+ @Override
+ public Boolean isValid() {
+ return (graph != null);
+ }
+
+ @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();
+ }
+
+ 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..1487be7
--- /dev/null
+++ b/src/main/java/net/onrc/onos/graph/RamCloudDBOperation.java
@@ -0,0 +1,27 @@
+/*
+ * 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 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.util.FlowEntryId;
+import net.onrc.onos.ofcontroller.util.FlowId;
+import org.apache.commons.configuration.Configuration;
+
+/**
+ *
+ * @author nickkaranatsios
+ */
+public class RamCloudDBOperation extends DBOperation {
+
+ public RamCloudDBOperation() {
+ }
+}
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..f46e417
--- /dev/null
+++ b/src/main/java/net/onrc/onos/graph/TitanDBConnection.java
@@ -0,0 +1,122 @@
+/*
+ * 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;
+ }
+ }
+}
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..1b211d6
--- /dev/null
+++ b/src/main/java/net/onrc/onos/graph/TitanDBOperation.java
@@ -0,0 +1,26 @@
+/*
+ * 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.ISwitchStorage;
+import net.onrc.onos.ofcontroller.util.FlowEntryId;
+import net.onrc.onos.ofcontroller.util.FlowId;
+
+/**
+ *
+ * @author nickkaranatsios
+ */
+public class TitanDBOperation extends DBOperation {
+
+}
\ No newline at end of file
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
index 33280a6..3ff6058 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
@@ -280,7 +280,7 @@
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
topologyChangeDetectorTask = new SingletonTask(executor, new TopologyChangeDetector());
- topologyNetService = new TopologyManager("");
+ topologyNetService = new TopologyManager(context);
pathsWaitingOnArp = new HashMap<InetAddress, Path>();
prefixesWaitingOnArp = Multimaps.synchronizedSetMultimap(
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 4bbc054..3eaf79d 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,52 +21,59 @@
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("ramcloud", "/tmp/ramcloudconf");
+ //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;
@@ -104,12 +113,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);
@@ -149,16 +159,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.
@@ -180,26 +192,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());
- }
+ }
}
/***
@@ -256,16 +270,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);
}
}
@@ -314,5 +327,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 635e24e..36e1c5e 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;
@@ -14,22 +14,28 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+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);
+ this.dbop = GraphDBManager.getDBOperation("ramcloud", "/tmp/ramcloudconf");
+
}
// Method designing policy:
@@ -55,11 +61,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);
}
@@ -69,11 +75,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);
}
@@ -83,15 +89,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);
}
@@ -116,18 +122,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);
}
@@ -151,10 +157,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);
}
@@ -174,15 +180,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();
@@ -202,14 +208,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);
}
@@ -226,8 +232,7 @@
@Override
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();
@@ -256,7 +261,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();
@@ -288,15 +293,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);
}
@@ -312,8 +317,7 @@
@Override
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()) {
@@ -343,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()) {
@@ -370,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>();
@@ -433,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;
@@ -455,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});
}
}
@@ -469,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) {
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 5f51b58..6599366 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,23 @@
* 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("ramcloud", "/tmp/ramcloudconf");
+ //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 +160,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 +314,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 +344,7 @@
boolean success = false;
DeviceStorageImpl deviceStorage = new DeviceStorageImpl();
- deviceStorage.init("");
+ deviceStorage.init("","");
try {
ISwitchObject sw = op.searchSwitch(dpid);
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 71fecd0..cf73c9c 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;
@@ -14,12 +14,13 @@
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.gremlin.java.GremlinPipeline;
+import net.onrc.onos.graph.GraphDBManager;
import com.tinkerpop.pipes.PipeFunction;
import com.tinkerpop.pipes.transform.PathPipe;
public class TopoLinkServiceImpl implements ITopoLinkService {
- protected GraphDBOperation op;
+ protected DBOperation dbop;
protected final static Logger log = LoggerFactory.getLogger(TopoLinkServiceImpl.class);
public void finalize() {
@@ -28,14 +29,16 @@
@Override
public void close() {
- op.close();
+ dbop.close();
}
@Override
public List<Link> getActiveLinks() {
- op = new GraphDBOperation("");
- op.commit(); //Commit to ensure we see latest data
- Iterable<ISwitchObject> switches = op.getActiveSwitches();
+ // TODO Auto-generated method stub
+ dbop = GraphDBManager.getDBOperation("ramcloud", "/tmp/ramcloudconf");
+ //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>();
@@ -51,14 +54,14 @@
}
}
- op.commit();
+ dbop.commit();
return links;
}
@Override
public List<Link> getLinksOnSwitch(String dpid) {
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();
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 3a324b1..3f7090b 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
@@ -1,6 +1,7 @@
package net.onrc.onos.ofcontroller.core.internal;
-import net.onrc.onos.graph.GraphDBOperation;
+import net.onrc.onos.graph.DBOperation;
+import net.onrc.onos.graph.GraphDBManager;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoSwitchService;
@@ -10,15 +11,16 @@
public class TopoSwitchServiceImpl implements ITopoSwitchService {
- private GraphDBOperation op;
+ private DBOperation op;
protected final static Logger log = LoggerFactory.getLogger(TopoSwitchServiceImpl.class);
- public TopoSwitchServiceImpl(String conf) {
- op = new GraphDBOperation(conf);
+ public TopoSwitchServiceImpl(final String dbStore, String conf) {
+ op = GraphDBManager.getDBOperation("ramcloud", "/tmp/ramcloudconf");
+ //op = GraphDBManager.getDBOperation(dbStore, conf);;
}
public TopoSwitchServiceImpl() {
- this("");
+ this("","");
}
public void finalize() {
@@ -33,27 +35,27 @@
@Override
public Iterable<ISwitchObject> getActiveSwitches() {
// TODO Auto-generated method stub
- op.close(); //Commit to ensure we see latest data
+ //op.close(); //Commit to ensure we see latest data
return op.getActiveSwitches();
}
@Override
public Iterable<ISwitchObject> getAllSwitches() {
// TODO Auto-generated method stub
- op.close(); //Commit to ensure we see latest data
+ //op.close(); //Commit to ensure we see latest data
return op.getAllSwitches();
}
@Override
public Iterable<ISwitchObject> getInactiveSwitches() {
// TODO Auto-generated method stub
- op.close(); //Commit to ensure we see latest data
+ //op.close(); //Commit to ensure we see latest data
return op.getInactiveSwitches();
}
@Override
public Iterable<IPortObject> getPortsOnSwitch(String dpid) {
- op.close(); //Commit to ensure we see latest data
+ //op.close(); //Commit to ensure we see latest data
ISwitchObject switchObject = op.searchSwitch(dpid);
if (switchObject != null) {
return switchObject.getPorts();
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 ac9409f..0d95e49 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
@@ -2,7 +2,8 @@
import java.util.Iterator;
-import net.onrc.onos.graph.GraphDBOperation;
+import net.onrc.onos.graph.DBOperation;
+import net.onrc.onos.graph.GraphDBManager;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
import org.restlet.resource.Get;
@@ -12,7 +13,7 @@
@Get("json")
public Iterator<IDeviceObject> retrieve() {
- GraphDBOperation op = new GraphDBOperation("");
+ DBOperation op = GraphDBManager.getDBOperation("ramcloud", "/tmp/ramcloudconf");
return op.getDevices().iterator();
}
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 4b31667..f458603 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;
@@ -64,9 +65,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;
@@ -85,6 +87,7 @@
public void run() {
try {
log.debug("Running cleanup thread");
+ op = GraphDBManager.getDBOperation("ramcloud", "/tmp/ramcloudconf");
switchCleanup();
}
catch (Exception e) {
@@ -147,7 +150,7 @@
}
protected void switchCleanup() {
- op.close();
+ //op.close();
Iterable<ISwitchObject> switches = op.getActiveSwitches();
log.debug("Checking for inactive switches");
@@ -442,7 +445,13 @@
throws FloodlightModuleException {
Map<String, String> configMap = context.getConfigParams(this);
String conf = configMap.get(DBConfigFile);
- op = new GraphDBOperation(conf);
+ String dbStore = configMap.get(GraphDBStore);
+ System.out.println("conf" + conf + "dbStore" + dbStore);
+ op = GraphDBManager.getDBOperation("ramcloud", "/tmp/ramcloudconf");
+ //op = GraphDBManager.getDBOperation(dbStore, conf);
+ if (op == null) {
+ System.out.println("publisher op is null");
+ }
floodlightProvider =
context.getServiceImpl(IFloodlightProviderService.class);
@@ -453,13 +462,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);
@@ -475,8 +484,9 @@
linkDiscovery.addListener(this);
log.debug("Adding EventListener");
+ System.out.println("start Up op " + op);
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/FlowDatabaseOperation.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
index da407ab..95185b9 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
@@ -7,8 +7,7 @@
import java.util.List;
import net.floodlightcontroller.util.MACAddress;
-
-import net.onrc.onos.graph.GraphDBOperation;
+import net.onrc.onos.graph.DBOperation;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
@@ -32,11 +31,12 @@
* @param flowPath the Flow Path to install.
* @return true on success, otherwise false.
*/
- static boolean addFlow(GraphDBOperation dbHandler, FlowPath flowPath) {
+ static boolean addFlow(DBOperation dbHandler, FlowPath flowPath) {
IFlowPath flowObj = null;
boolean found = false;
try {
- if ((flowObj = dbHandler.searchFlowPath(flowPath.flowId())) != null) {
+ flowObj = dbHandler.searchFlowPath(flowPath.flowId());
+ if (flowObj != null) {
found = true;
} else {
flowObj = dbHandler.newFlowPath();
@@ -188,7 +188,7 @@
* @param flowEntry the Flow Entry to install.
* @return the added Flow Entry object on success, otherwise null.
*/
- static IFlowEntry addFlowEntry(GraphDBOperation dbHandler,
+ static IFlowEntry addFlowEntry(DBOperation dbHandler,
IFlowPath flowObj,
FlowEntry flowEntry) {
// Flow edges
@@ -336,7 +336,7 @@
* @param flowEntry the Flow Entry to delete.
* @return true on success, otherwise false.
*/
- static boolean deleteFlowEntry(GraphDBOperation dbHandler,
+ static boolean deleteFlowEntry(DBOperation dbHandler,
IFlowPath flowObj,
FlowEntry flowEntry) {
IFlowEntry flowEntryObj = null;
@@ -372,7 +372,7 @@
* @param dbHandler the Graph Database handler to use.
* @return true on success, otherwise false.
*/
- static boolean deleteAllFlows(GraphDBOperation dbHandler) {
+ static boolean deleteAllFlows(DBOperation dbHandler) {
List<FlowId> allFlowIds = new LinkedList<FlowId>();
// Get all Flow IDs
@@ -402,7 +402,7 @@
* @param flowId the Flow ID of the flow to delete.
* @return true on success, otherwise false.
*/
- static boolean deleteFlow(GraphDBOperation dbHandler, FlowId flowId) {
+ static boolean deleteFlow(DBOperation dbHandler, FlowId flowId) {
IFlowPath flowObj = null;
try {
flowObj = dbHandler.searchFlowPath(flowId);
@@ -439,7 +439,7 @@
* @param flowId the Flow ID of the flow to get.
* @return the Flow Path if found, otherwise null.
*/
- static FlowPath getFlow(GraphDBOperation dbHandler, FlowId flowId) {
+ static FlowPath getFlow(DBOperation dbHandler, FlowId flowId) {
IFlowPath flowObj = null;
try {
flowObj = dbHandler.searchFlowPath(flowId);
@@ -469,7 +469,7 @@
* @param dbHandler the Graph Database handler to use.
* @return the Flow Paths if found, otherwise null.
*/
- static ArrayList<FlowPath> getAllFlows(GraphDBOperation dbHandler) {
+ static ArrayList<FlowPath> getAllFlows(DBOperation dbHandler) {
Iterable<IFlowPath> flowPathsObj = null;
ArrayList<FlowPath> flowPaths = new ArrayList<FlowPath>();
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 84b175f..0f9ed91 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
@@ -18,8 +18,10 @@
import net.floodlightcontroller.core.module.IFloodlightModule;
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.floodlightlistener.INetworkGraphService;
import net.onrc.onos.ofcontroller.flowmanager.web.FlowWebRoutable;
@@ -46,8 +48,10 @@
* Flow Manager class for handling the network flows.
*/
public class FlowManager implements IFloodlightModule, IFlowService, INetMapStorage {
- protected GraphDBOperation dbHandlerApi;
- protected GraphDBOperation dbHandlerInner;
+ // flag to use FlowPusher instead of FlowSwitchOperation/MessageDamper
+ private final static boolean enableFlowPusher = false;
+ protected DBOperation dbHandlerApi;
+ protected DBOperation dbHandlerInner;
protected volatile IFloodlightProviderService floodlightProvider;
protected volatile IDatagridService datagridService;
@@ -79,9 +83,13 @@
* @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) {
+ dbHandlerApi = GraphDBManager.getDBOperation("ramcloud", "/tmp/ramcloudconf");
+ dbHandlerInner = GraphDBManager.getDBOperation("ramcloud", "/tmp/ramcloudconf");
+
+ //dbHandlerApi = GraphDBManager.getDBOperation(dbStore, conf);
+ //dbHandlerInner = GraphDBManager.getDBOperation(dbStore, conf);
+
}
/**
@@ -164,7 +172,7 @@
pusher = context.getServiceImpl(IFlowPusherService.class);
forwardingService = context.getServiceImpl(IForwardingService.class);
- this.init("");
+ this.init("","");
}
/**
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
index 6ef44be..04d3bbc 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
@@ -24,7 +24,8 @@
import org.slf4j.LoggerFactory;
import net.floodlightcontroller.core.IOFSwitch;
-import net.onrc.onos.graph.GraphDBOperation;
+import net.onrc.onos.graph.DBOperation;
+import net.onrc.onos.graph.GraphDBManager;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.flowmanager.FlowDatabaseOperation;
@@ -44,14 +45,13 @@
private static Logger log = LoggerFactory.getLogger(FlowSynchronizer.class);
- private GraphDBOperation dbHandler;
+ private DBOperation dbHandler;
protected IFlowPusherService pusher;
private Map<IOFSwitch, FutureTask<SyncResult>> switchThreads;
public FlowSynchronizer() {
- dbHandler = new GraphDBOperation("");
- switchThreads = new HashMap<IOFSwitch, FutureTask<SyncResult>>();
- }
+ dbHandler = GraphDBManager.getDBOperation("ramcloud", "/tmp/ramcloudconf");
+ switchThreads = new HashMap<IOFSwitch, FutureTask<SyncResult>>(); }
@Override
public Future<SyncResult> synchronize(IOFSwitch sw) {
diff --git a/src/main/java/net/onrc/onos/ofcontroller/forwarding/Forwarding.java b/src/main/java/net/onrc/onos/ofcontroller/forwarding/Forwarding.java
index 430d05d..b062e2b 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/forwarding/Forwarding.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/forwarding/Forwarding.java
@@ -158,9 +158,9 @@
waitingPackets = HashMultimap.create();
deviceStorage = new DeviceStorageImpl();
- deviceStorage.init("");
+ deviceStorage.init("","");
topologyService = new TopologyManager();
- topologyService.init("");
+ topologyService.init("","");
}
@Override
diff --git a/src/main/java/net/onrc/onos/ofcontroller/proxyarp/BgpProxyArpManager.java b/src/main/java/net/onrc/onos/ofcontroller/proxyarp/BgpProxyArpManager.java
index 801e414..3dba4f8 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/proxyarp/BgpProxyArpManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/proxyarp/BgpProxyArpManager.java
@@ -143,7 +143,7 @@
floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
deviceStorage = new DeviceStorageImpl();
- deviceStorage.init("");
+ deviceStorage.init("","");
Timer arpTimer = new Timer("arp-processing");
arpTimer.scheduleAtFixedRate(new TimerTask() {
diff --git a/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java b/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java
index eadbbdd..5e0b752 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java
@@ -184,7 +184,7 @@
datagrid.registerArpEventHandler(this);
deviceStorage = new DeviceStorageImpl();
- deviceStorage.init("");
+ deviceStorage.init("","");
Timer arpTimer = new Timer("arp-processing");
arpTimer.scheduleAtFixedRate(new TimerTask() {
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..a4a2be3 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;
@@ -160,7 +160,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 +323,4 @@
return null;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/topology/Topology.java b/src/main/java/net/onrc/onos/ofcontroller/topology/Topology.java
index fc75591..761189c 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/topology/Topology.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/topology/Topology.java
@@ -13,6 +13,7 @@
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Vertex;
+import net.onrc.onos.graph.DBOperation;
/**
* A class for storing Node and Link information for fast computation
@@ -382,7 +383,7 @@
*
* @param dbHandler the Graph Database handler to use.
*/
- public void readFromDatabase(GraphDBOperation dbHandler) {
+ public void readFromDatabase(DBOperation dbHandler) {
//
// Fetch the relevant info from the Switch and Port vertices
// from the Titan Graph.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/topology/TopologyManager.java b/src/main/java/net/onrc/onos/ofcontroller/topology/TopologyManager.java
index 02e0ffb..6b2ab99 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/topology/TopologyManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/topology/TopologyManager.java
@@ -12,6 +12,8 @@
import net.floodlightcontroller.core.module.IFloodlightService;
import net.onrc.onos.datagrid.IDatagridService;
+import net.onrc.onos.graph.DBOperation;
+import net.onrc.onos.graph.GraphDBManager;
import net.onrc.onos.graph.GraphDBOperation;
import net.onrc.onos.ofcontroller.floodlightlistener.INetworkGraphService;
import net.onrc.onos.ofcontroller.util.DataPath;
@@ -34,7 +36,10 @@
private final static Logger log = LoggerFactory.getLogger(TopologyManager.class);
protected IFloodlightProviderService floodlightProvider;
- protected GraphDBOperation dbHandler;
+ protected static final String DBConfigFile = "dbconf";
+ protected static final String GraphDBStore = "graph_db_store";
+
+ protected DBOperation dbHandler;
/**
@@ -49,8 +54,11 @@
* @param config the database configuration file to use for
* the initialization.
*/
- public TopologyManager(String config) {
- this.init(config);
+ public TopologyManager(FloodlightModuleContext context) {
+ Map<String, String> configMap = context.getConfigParams(this);
+ String conf = configMap.get(DBConfigFile);
+ String dbStore = configMap.get(GraphDBStore);
+ this.init(dbStore,conf);
}
/**
@@ -59,19 +67,20 @@
* @param dbHandler the database operation handler to use for the
* initialization.
*/
- public TopologyManager(GraphDBOperation dbHandler) {
+ public TopologyManager(DBOperation dbHandler) {
this.dbHandler = dbHandler;
}
/**
* Init the module.
- *
+ * @param
* @param config the database configuration file to use for
* the initialization.
*/
- public void init(String config) {
+ public void init(final String dbStore, String config) {
try {
- dbHandler = new GraphDBOperation(config);
+ dbHandler = GraphDBManager.getDBOperation("ramcloud", "/tmp/ramcloudconf");
+ //dbHandler = GraphDBManager.getDBOperation(dbStore, config);
} catch (Exception e) {
log.error(e.getMessage());
}
@@ -145,9 +154,10 @@
public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
-
- String conf = "";
- this.init(conf);
+ Map<String, String> configMap = context.getConfigParams(this);
+ String conf = configMap.get(DBConfigFile);
+ String dbStore = configMap.get(GraphDBStore);
+ this.init(dbStore, conf);
}
/**
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 8034d44..69c3c8a 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
@@ -119,7 +119,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..fdc13db 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,7 +219,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.updateSwitch(dpid, stateINACTIVE, opUPDATE);
}
@@ -250,7 +252,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.updateSwitch(dpid, stateINACTIVE, opCREATE);
}
@@ -283,7 +285,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.updateSwitch(dpid, stateINACTIVE, opINSERT);
}
@@ -319,7 +321,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.updateSwitch(dpid, stateACTIVE, opDELETE);
}
@@ -354,7 +356,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.deleteSwitch(dpid);
@@ -393,7 +395,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.deleteSwitch(dpid);
}
@@ -446,7 +448,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.addPort(dpid, portToAdd);
}
@@ -502,7 +504,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.addPort(dpid, portToAdd);
}
@@ -541,7 +543,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addPort(dpid, portToAdd);
}
@@ -593,7 +595,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.addPort(dpid, portToAdd);
}
@@ -648,7 +650,7 @@
mockOpe.close();
replay(mockOpe);
- swSt.init(conf);
+ swSt.init(dbStore, conf);
swSt.addSwitch(dpid);
swSt.addPort(dpid, portToAdd);
}
@@ -711,7 +713,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 +780,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..fe51f95 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
@@ -49,6 +49,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 +60,7 @@
swSt = new SwitchStorageImpl();
conf = "/dummy/path/to/db";
+ dbStore ="dummyStore";
// Make mock cassandra DB
// Replace TitanFactory.open() to return mock DB
@@ -71,7 +73,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..d017546 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);
@@ -69,7 +71,7 @@
// Replace the conf to dummy conf
// String conf = "/tmp/cassandra.titan";
- deviceImpl.init(conf);
+ deviceImpl.init(dbStore, conf);
}
@@ -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 9964ec3..c80b52a 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
@@ -56,6 +56,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;
@@ -66,6 +67,7 @@
deviceImpl = new DeviceStorageImpl();
conf = "/dummy/path/to/db";
+ dbStore = "dummyStore";
// Make mock cassandra DB
// Replace TitanFactory.open() to return mock DB
@@ -78,7 +80,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 b43ce1c..73577c1 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java
@@ -485,7 +485,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 e054e05..8d4ccc0 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/topology/TopologyManagerTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/topology/TopologyManagerTest.java
@@ -16,7 +16,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;
@@ -34,8 +37,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;
@@ -44,6 +48,7 @@
*/
@Before
public void setUp() throws Exception {
+ dbStore = "dummyStore";
conf = "/dummy/path/to/db";
//
@@ -55,9 +60,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);
diff --git a/start-onos.sh b/start-onos.sh
index 29a108c..1f67368 100755
--- a/start-onos.sh
+++ b/start-onos.sh
@@ -160,7 +160,7 @@
case "$1" in
start)
stop
- check_db
+# check_db
start
;;
startifdown)
diff --git a/start-ramcloud.sh b/start-ramcloud.sh
new file mode 100755
index 0000000..161dc62
--- /dev/null
+++ b/start-ramcloud.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# Set paths
+ONOS_HOME=`dirname $0`
+RAMCLOUD_DIR=${HOME}/ramcloud
+LOGDIR=${ONOS_HOME}/ONOS/onos-logs
+RAMCLOUD_LOG=${LOGDIR}/ramcloud.`hostname`.log
+RAMCLOUD_COORDINATOR="fast+udp:host=10.128.4.104,port=12246"
+RAMCLOUD_SERVER="fast+udp:host=10.128.100.35,port=12242"
+
+function lotate {
+ logfile=$1
+ nr_max=${2:-10}
+ if [ -f $logfile ]; then
+ for i in `seq $(expr $nr_max - 1) -1 1`; do
+ if [ -f ${logfile}.${i} ]; then
+ mv -f ${logfile}.${i} ${logfile}.`expr $i + 1`
+ fi
+ done
+ mv $logfile $logfile.1
+ fi
+}
+
+function start {
+ if [ ! -d ${LOGDIR} ]; then
+ mkdir -p ${LOGDIR}
+ fi
+ echo "rotate log: $log"
+ if [ -f $RAMCLOUD_LOG ]; then
+ lotate $RAMCLOUD_LOG
+ fi
+
+ # Run ramcloud
+ echo "Starting ramcloud"
+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${HOME}/ramcloud/bindings/java/edu/stanford/ramcloud:${HOME}/ramcloud/obj.blueprint-java
+ $RAMCLOUD_DIR/obj/server -M -r 0 -L $RAMCLOUD_SERVER -C $RAMCLOUD_COORDINATOR > $RAMCLOUD_LOG 2>&1 &
+}
+
+function stop {
+ # Kill the existing processes
+ capid=`ps -edalf |grep ramcloud |grep obj/server | awk '{print $4}'`
+ pids="$capid"
+ for p in ${pids}; do
+ if [ x$p != "x" ]; then
+ kill -KILL $p
+ echo "Killed existing prosess (pid: $p)"
+ fi
+ done
+}
+
+function deldb {
+# # Delete the berkeley db database
+ if [ -d "/tmp/ramcloud.conf" ]; then
+ echo "deleting berkeley db dir"
+ sudo rm -rf /tmp/ramcloud.conf
+ fi
+}
+
+case "$1" in
+ start)
+ deldb
+ cp $ONOS_HOME/conf/ramcloud.conf /tmp
+ stop
+ start
+ ;;
+ stop)
+ stop
+ ;;
+# deldb)
+# deldb
+# ;;
+ status)
+ n=`ps -edalf |grep ramcloud |grep obj/server | wc -l`
+ echo "$n ramcloud server running"
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|status}"
+ exit 1
+esac