Removed directory src/main/java/net/onrc/onos/graph/
because it is not needed anymore.
Updated few files that still referred to that directory:
* NetworkGraphPublisher.java
This file will be removed in the future
* FlowSynchronizer.java
- Commented-out few places which referred to
src/main/java/net/onrc/onos/graph/
Currently, the FlowSynchronizer is disabled, and will be refactored
in the future
* FlowSynchronizerTest.java
Unit test for the FlowSynchronizer. The test needs to be updated
after FlowSynchronizer itself is refactored.
Change-Id: I3f8df81e64ad6000e44217a26408e3aaa0321670
diff --git a/src/main/java/net/onrc/onos/graph/DBConnection.java b/src/main/java/net/onrc/onos/graph/DBConnection.java
deleted file mode 100644
index dee458a..0000000
--- a/src/main/java/net/onrc/onos/graph/DBConnection.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 747e514..0000000
--- a/src/main/java/net/onrc/onos/graph/DBOperation.java
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * 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.*;
-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 java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-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.util.FlowEntryId;
-import net.onrc.onos.ofcontroller.util.FlowId;
-
-public abstract class DBOperation implements IDBOperation {
-
- protected DBConnection conn;
- private final static Logger log = LoggerFactory.getLogger(DBOperation.class);
-
-
- /**
- * 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) {
- ISwitchObject obj = (ISwitchObject) conn.getFramedGraph().addVertex(null, ISwitchObject.class);
- if (obj != null) {
- obj.setType("switch");
- obj.setDPID(dpid);
- }
- return obj;
- }
-
- /**
- * Get all port objects.
- */
- @Override
- public Iterable<IPortObject> getAllPorts() {
- Iterable<IPortObject> ports = conn.getFramedGraph().getVertices("type", "port", IPortObject.class);
- return ports;
- }
-
- /**
- * Get all switch objects.
- */
- @Override
- public Iterable<ISwitchObject> getAllSwitches() {
- Iterable<ISwitchObject> switches = conn.getFramedGraph().getVertices("type", "switch", ISwitchObject.class);
- return switches;
- }
-
- /**
- * Get all inactive switch objects.
- */
- @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;
- }
-
- /**
- * 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) {
- 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 + PORT_ID_DELIM + portNum.toString();
- obj.setPortId(id);
- obj.setNumber(portNum);
- }
- return obj;
- }
-
- /**
- * Create a port having specified port number.
- *
- * @param portNumber port number
- */
- @Override
- @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) {
- FramedGraph fg = conn.getFramedGraph();
- if ( fg == null ) return null;
- String id = dpid + PORT_ID_DELIM + number.toString();
- Iterator<IPortObject> it = fg.getVertices("port_id", id, IPortObject.class).iterator();
- return (it.hasNext()) ? it.next() : null;
-
- }
-
- /**
- * Remove the specified switch port.
- * @param port switch port object to remove
- */
- @Override
- public void removePort(IPortObject port) {
- if (conn.getFramedGraph() != null) {
- conn.getFramedGraph().removeVertex(port.asVertex());
- }
- }
-
- /**
- * Create and return a device object.
- */
- @Override
- public IDeviceObject 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() {
- 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) {
- if (conn.getFramedGraph() != null) {
- conn.getFramedGraph().removeVertex(dev.asVertex());
- }
- }
-
- /**
- * Create and return a flow path object.
- */
- @Override
- public IFlowPath newFlowPath() {
- IFlowPath flowPath = (IFlowPath)conn.getFramedGraph().addVertex(null, IFlowPath.class);
- 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(), 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) {
- FramedGraph fg = conn.getFramedGraph();
- if ( fg == null ) return null;
- Iterator<ISwitchObject> it = fg.getVertices("dpid", dpid, ISwitchObject.class).iterator();
- return (it.hasNext()) ? it.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) {
- FramedGraph fg = conn.getFramedGraph();
- if ( fg == null ) return null;
- Iterator<IDeviceObject> it = fg.getVertices("dl_addr", macAddr, IDeviceObject.class).iterator();
- return (it.hasNext()) ? it.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) {
- FramedGraph fg = conn.getFramedGraph();
- if ( fg == null ) return null;
- Iterator<IFlowPath> it = fg.getVertices("flow_id", flowId.toString(), IFlowPath.class).iterator();
- return (it.hasNext()) ? it.next() : null;
- }
-
- /**
- * Get all flow path objects.
- */
- @Override
- public Iterable<IFlowPath> 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) {
- 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) {
- FramedGraph fg = conn.getFramedGraph();
- if ( fg == null ) return null;
- Iterator<IFlowEntry> it = fg.getVertices("flow_entry_id", flowEntryId.toString(), IFlowEntry.class).iterator();
- return (it.hasNext()) ? it.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) {
- conn.getFramedGraph().removeVertex(flowEntry.asVertex());
- }
-
- /**
- * Create and return a flow entry object.
- */
- @Override
- public IFlowEntry 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) {
- 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();
- }
-
- @Override
- public void setVertexProperties(Vertex vertex, Map<String, Object> map) {
- log.debug("setProperties start: size {}", map.size());
- RamCloudVertex v = (RamCloudVertex) vertex;
- v.setProperties(map);
- log.debug("setProperties end: size {}, id {}", map.size(), v.getId());
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- for(ISwitchObject sw: getAllSwitches()) {
- sb.append("sw: " + sw.getDPID() + "\n");
- for(IPortObject port: sw.getPorts()) {
- sb.append(" port: " + port.getPortId() + "\n");
- }
- }
- return sb.toString();
- }
-}
diff --git a/src/main/java/net/onrc/onos/graph/GraphDBConnection.java b/src/main/java/net/onrc/onos/graph/GraphDBConnection.java
deleted file mode 100644
index b504c4b..0000000
--- a/src/main/java/net/onrc/onos/graph/GraphDBConnection.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package net.onrc.onos.graph;
-
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-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 com.tinkerpop.frames.FramedGraphFactory;
-import com.tinkerpop.frames.modules.gremlingroovy.GremlinGroovyModule;
-
-public class GraphDBConnection implements IDBConnection {
- public enum Transaction {
- COMMIT, ROLLBACK
- }
-
- public enum GenerateEvent {
- TRUE, FALSE
- }
-
- class TransactionHandle {
- protected TransactionalGraph tr;
-
- public void create() {
- tr = graph.newTransaction();
- }
- }
-
- protected final static Logger log = LoggerFactory
- .getLogger(GraphDBConnection.class);
- private static GraphDBConnection singleton = new GraphDBConnection();
- private static TitanGraph graph;
- private static FramedGraphFactory factory;
- private static FramedGraph<TitanGraph> fg;
- private static EventTransactionalGraph<TitanGraph> eg;
- private static String configFile;
-
- /*
- * A private Constructor prevents any other class from instantiating.
- */
- private GraphDBConnection() {
- }
-
- /* Static 'instance' method */
- /**
- * Get the instance of GraphDBConnection class.
- * @param conf the path to the database configuration file.
- * @return GraphDBConnection instance.
- */
- public static synchronized GraphDBConnection getInstance(final String conf) {
- if (GraphDBConnection.configFile == null
- || GraphDBConnection.configFile.isEmpty()) {
- GraphDBConnection.configFile = conf;
- log.debug("GraphDBConnection::Setting Config File {}",
- GraphDBConnection.configFile);
- }
- if (!GraphDBConnection.configFile.isEmpty()
- && (graph == null || graph.isOpen() == Boolean.FALSE)) {
- graph = TitanFactory.open(GraphDBConnection.configFile);
- // FIXME: Creation on Indexes should be done only once
- 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);
- }
- if (!s.contains("ipv4_address")) {
- graph.createKeyIndex("ipv4_address", Vertex.class);
- }
- graph.commit();
- // Make sure you reuse the factory when creating new framed graphs
- factory = new FramedGraphFactory(new GremlinGroovyModule());
- fg = factory.create(graph);
- eg = new EventTransactionalGraph<TitanGraph>(graph);
- }
- return singleton;
- }
-
- /**
- * Get a FramedGraph instance of the graph.
- */
- @Override
- public FramedGraph<TitanGraph> getFramedGraph() {
- if (isValid()) {
- return fg;
- } else {
- log.error("New FramedGraph failed");
- return null;
- }
- }
-
- /**
- * Get EventTransactionalGraph of the titan graph.
- * @return EventTransactionalGraph of the titan graph
- */
- protected EventTransactionalGraph<TitanGraph> getEventGraph() {
- if (isValid()) {
- return eg;
- } else {
- return null;
- }
- }
-
- /**
- * Add LocalGraphChangedLister for the graph.
- */
- @Override
- public void addEventListener(final LocalGraphChangedListener listener) {
- EventTransactionalGraph<TitanGraph> eg = this.getEventGraph();
- eg.addListener(listener);
- log.debug("Registered listener {}", listener.getClass());
- }
-
- /**
- * Return whether this connection is valid.
- */
- @Override
- public Boolean isValid() {
- return (graph != null && graph.isOpen());
- }
-
- /**
- * Commit changes for the graph operations.
- * @throws Exception
- */
- @Override
- public void commit() {
-// // Should not catch exception here!
-// try {
- graph.commit();
-// }
-// catch (Exception e) {
-// log.error("{}", e.toString());
-// }
- }
-
- /**
- * Rollback changes for the graph operations.
- */
- @Override
- public void rollback() {
- // Should not catch exception here!
-// try {
- graph.rollback();
-// }
-// catch (Exception e) {
-// log.error("{}", e.toString());
-// }
- }
-
- /**
- * Close this database connection.
- */
- @Override
- public void close() {
- try {
- commit();
- } catch (Exception e) {
- log.error("close() failed with exception", e);
- }
- }
-}
diff --git a/src/main/java/net/onrc/onos/graph/GraphDBManager.java b/src/main/java/net/onrc/onos/graph/GraphDBManager.java
deleted file mode 100644
index 3eec68f..0000000
--- a/src/main/java/net/onrc/onos/graph/GraphDBManager.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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;
-
-public class GraphDBManager {
- private static ThreadLocal<HashMap<String, DBConnection>> connections = new ThreadLocal<HashMap<String, DBConnection>>();
- private static DBOperation operation = null;
- private final static String DB_CONFIG_FILE = "conf/ramcloud.conf";
-
- static Map<String, DBConnection> getConnectionMap() {
- if (connections.get() == null) {
- connections.set(new HashMap<String, DBConnection>());
- }
- return connections.get();
- }
-
- public static DBOperation getDBOperation() {
- return getDBOperation("ramcloud");
- }
-
- public static DBOperation getDBOperation(final String dbStore) {
- if (dbStore.equals("ramcloud")) {
- operation = new RamCloudDBOperation();
- } else if (dbStore.equals("titan")) {
- operation = new TitanDBOperation();
- }
- if (operation != null) {
- operation.conn = GraphDBManager.getConnection(dbStore, DB_CONFIG_FILE);
- }
- 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
deleted file mode 100644
index cd65ec0..0000000
--- a/src/main/java/net/onrc/onos/graph/IDBConnection.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package net.onrc.onos.graph;
-
-import com.tinkerpop.frames.FramedGraph;
-
-public interface IDBConnection {
- 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/IDBOperation.java b/src/main/java/net/onrc/onos/graph/IDBOperation.java
deleted file mode 100644
index d2e8109..0000000
--- a/src/main/java/net/onrc/onos/graph/IDBOperation.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package net.onrc.onos.graph;
-
-import java.util.Map;
-
-import com.tinkerpop.blueprints.Vertex;
-
-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;
-
-public interface IDBOperation {
- public static final String PORT_ID_DELIM = "@";
-
- public ISwitchObject newSwitch(String dpid);
- public ISwitchObject searchSwitch(String dpid);
- public ISwitchObject searchActiveSwitch(String dpid);
- public Iterable<ISwitchObject> getActiveSwitches();
- public Iterable<ISwitchObject> getAllSwitches();
- public Iterable<ISwitchObject> getInactiveSwitches();
- public Iterable<IFlowEntry> getAllSwitchNotUpdatedFlowEntries();
- public void removeSwitch(ISwitchObject sw);
-
- @Deprecated
- public IPortObject newPort(Short portNumber);
- public IPortObject newPort(String dpid, Short portNum);
- public IPortObject searchPort(String dpid, Short number);
- public void removePort(IPortObject port);
-
- public IDeviceObject newDevice();
- public IDeviceObject searchDevice(String macAddr);
- public Iterable<IDeviceObject> getDevices();
- public void removeDevice(IDeviceObject dev);
-
- public IFlowPath newFlowPath();
- public IFlowPath searchFlowPath(FlowId flowId);
- public IFlowPath getFlowPathByFlowEntry(IFlowEntry flowEntry);
- public Iterable<IFlowPath> getAllFlowPaths();
- public void removeFlowPath(IFlowPath flowPath);
-
- public IFlowEntry newFlowEntry();
- public IFlowEntry searchFlowEntry(FlowEntryId flowEntryId);
- public Iterable<IFlowEntry> getAllFlowEntries();
- public void removeFlowEntry(IFlowEntry flowEntry);
-
- public void setVertexProperties(Vertex vertex, Map<String, Object> map);
-
- public IDBConnection getDBConnection();
- public void commit();
- public void rollback();
- public void close();
-
- public Iterable<IPortObject> getAllPorts();
-}
diff --git a/src/main/java/net/onrc/onos/graph/LocalGraphChangedListener.java b/src/main/java/net/onrc/onos/graph/LocalGraphChangedListener.java
deleted file mode 100644
index 5f3bbf1..0000000
--- a/src/main/java/net/onrc/onos/graph/LocalGraphChangedListener.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package net.onrc.onos.graph;
-
-import com.tinkerpop.blueprints.util.wrappers.event.listener.GraphChangedListener;
-
-public interface LocalGraphChangedListener extends GraphChangedListener {
-
-}
diff --git a/src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java b/src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java
deleted file mode 100644
index 72227d5..0000000
--- a/src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package net.onrc.onos.graph;
-
-import java.util.Map;
-
-import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.thinkaurelius.titan.core.TitanEdge;
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Edge;
-import com.tinkerpop.blueprints.Vertex;
-
-public class LocalTopologyEventListener implements LocalGraphChangedListener {
-
- protected final static Logger log = LoggerFactory.getLogger(LocalTopologyEventListener.class);
- protected static DBConnection conn;
-
- public LocalTopologyEventListener(DBConnection conn) {
- LocalTopologyEventListener.conn = conn;
- }
-
- @Override
- public void edgeAdded(Edge arg0) {
- // TODO Auto-generated method stub
- // Convert this Event into NetMapEvent (LinkAdded, FlowEntryEnabled, HostAttached, PortEnabled)
- }
-
-
- @Override
- public void edgePropertyRemoved(Edge arg0, String arg1, Object arg2) {
- // TODO Auto-generated method stub
- // Currently not needed
-
- }
-
- @Override
- public void edgeRemoved(Edge e, Map<String, Object> arg1) {
- // TODO Auto-generated method stub
- // Fire NetMapEvents (LinkRemoved, FlowEntryRemoved, HostRemoved, PortRemoved)
- TitanEdge edge = (TitanEdge) e;
- log.debug("TopologyEvents: Received edge removed event: {}",edge);
- String label = edge.getLabel();
- if (label.equals("link")) {
- Vertex v = edge.getVertex(Direction.IN);
- IPortObject src_port = (IPortObject) conn.getFramedGraph().frame(v, IPortObject.class);
- v = edge.getVertex(Direction.OUT);
- IPortObject dest_port = (IPortObject) conn.getFramedGraph().frame(v, IPortObject.class);
-
- log.debug("TopologyEvents: link broken {}", new Object []{src_port.getSwitch().getDPID(),
- src_port.getNumber(),
- dest_port.getSwitch().getDPID(),
- dest_port.getNumber()});
- // TODO: Find the flows and add to reconcile queue
- //
- // NOTE: Old code/logic.
- //
- // IFlowService flowManager = ...
- // flowManager.reconcileFlows(src_port);
- }
- }
-
- @Override
- public void vertexAdded(Vertex arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void vertexPropertyRemoved(Vertex arg0, String arg1, Object arg2) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void vertexRemoved(Vertex vertex, Map<String, Object> arg1) {
- // TODO Auto-generated method stub
- // Generate NetMapEvents
- String type = (String) vertex.getProperty("type");
- log.debug("TopologyEvents: Received vertex removed event: {}",vertex);
- if (type.equals("port")) {
- // port is removed...lets fire reconcile here directly for now
-
- 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.
- //
- // IFlowService flowManager = ...
- // flowManager.reconcileFlows(src_port);
- }
- }
-
-
- @Override
- public void edgePropertyChanged(Edge arg0, String arg1, Object arg2,
- Object arg3) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void vertexPropertyChanged(Vertex arg0, String arg1, Object arg2,
- Object arg3) {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java b/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java
deleted file mode 100644
index f23db92..0000000
--- a/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java
+++ /dev/null
@@ -1,118 +0,0 @@
-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;
-
-public class RamCloudDBConnection extends DBConnection {
- private RamCloudGraph graph;
- private FramedGraph<RamCloudGraph> fg;
- private static Logger log = LoggerFactory.getLogger(RamCloudDBConnection.class);
-
- public RamCloudDBConnection(final String dbConfigFile) {
- final String coordinatorURL = open(getConfiguration(new File(dbConfigFile)));
- graph = new RamCloudGraph(coordinatorURL);
- 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);
- }
- if (!s.contains("ipv4_address")) {
- graph.createKeyIndex("ipv4_address", Vertex.class);
- }
- fg = new FramedGraph<RamCloudGraph>(graph);
- }
-
- @Override
- public FramedGraph getFramedGraph() {
- if (isValid()) {
- 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 coordinatorIp = configuration.getString("ramcloud.coordinatorIp", null);
- final String coordinatorPort = configuration.getString("ramcloud.coordinatorPort", null);
- final String coordinatorURL = coordinatorIp + "," + coordinatorPort;
- 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
deleted file mode 100644
index 5cc1e53..0000000
--- a/src/main/java/net/onrc/onos/graph/RamCloudDBOperation.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package net.onrc.onos.graph;
-
-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
deleted file mode 100644
index 94ad43c..0000000
--- a/src/main/java/net/onrc/onos/graph/TitanDBConnection.java
+++ /dev/null
@@ -1,114 +0,0 @@
-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;
-
-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
deleted file mode 100644
index a6ccfdf..0000000
--- a/src/main/java/net/onrc/onos/graph/TitanDBOperation.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package net.onrc.onos.graph;
-
-import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.*;
-
-public class TitanDBOperation extends DBOperation {
-
-}
diff --git a/src/main/java/net/onrc/onos/graph/web/TopoDevicesResource.java b/src/main/java/net/onrc/onos/graph/web/TopoDevicesResource.java
deleted file mode 100644
index 2289a0b..0000000
--- a/src/main/java/net/onrc/onos/graph/web/TopoDevicesResource.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package net.onrc.onos.graph.web;
-
-import java.util.Iterator;
-
-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;
-import org.restlet.resource.ServerResource;
-
-public class TopoDevicesResource extends ServerResource {
-
- @Get("json")
- public Iterator<IDeviceObject> retrieve() {
- DBOperation op = GraphDBManager.getDBOperation();
-
- 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 c73a8e4..4c78d23 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/NetworkGraphPublisher.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/NetworkGraphPublisher.java
@@ -21,12 +21,7 @@
import net.floodlightcontroller.routing.Link;
import net.floodlightcontroller.threadpool.IThreadPoolService;
import net.floodlightcontroller.util.MACAddress;
-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.IDBConnection;
-import net.onrc.onos.graph.LocalTopologyEventListener;
import net.onrc.onos.ofcontroller.core.INetMapStorage.DM_OPERATION;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.core.IOFSwitchPortListener;
@@ -55,7 +50,7 @@
protected final static Logger log = LoggerFactory.getLogger(NetworkGraphPublisher.class);
//protected IDeviceService deviceService;
protected IControllerRegistryService registryService;
- protected DBOperation op;
+ // protected DBOperation op;
protected static final String DBConfigFile = "dbconf";
protected static final String GraphDBStore = "graph_db_store";
@@ -79,13 +74,13 @@
Thread.currentThread().setName("SwitchCleanup@" + old);
try {
log.debug("Running cleanup thread");
- op = GraphDBManager.getDBOperation();
+ // op = GraphDBManager.getDBOperation();
switchCleanup();
}
catch (Exception e) {
log.error("Error in cleanup thread", e);
} finally {
- op.close();
+ // op.close();
cleanupTask.reschedule(CLEANUP_TASK_INTERVAL,
TimeUnit.SECONDS);
Thread.currentThread().setName(old);
@@ -146,7 +141,8 @@
protected void switchCleanup() {
//op.close();
- Iterable<ISwitchObject> switches = op.getActiveSwitches();
+ // Iterable<ISwitchObject> switches = op.getActiveSwitches();
+ Iterable<ISwitchObject> switches = null;
log.debug("Checking for inactive switches");
// For each switch check if a controller exists in controller registry
@@ -169,7 +165,7 @@
e.printStackTrace();
}
}
- op.close();
+ // op.close();
}
@Override
@@ -458,7 +454,7 @@
Map<String, String> configMap = context.getConfigParams(this);
String conf = configMap.get(DBConfigFile);
String dbStore = configMap.get(GraphDBStore);
- op = GraphDBManager.getDBOperation();
+ // op = GraphDBManager.getDBOperation();
floodlightProvider =
context.getServiceImpl(IFloodlightProviderService.class);
@@ -474,6 +470,7 @@
@Override
public void startUp(FloodlightModuleContext context) {
+ /*
Map<String, String> configMap = context.getConfigParams(this);
String cleanupNeeded = configMap.get(CleanupEnabled);
@@ -495,6 +492,7 @@
// NOTE: No need to register with the Datagrid Service,
// because we don't need to receive any notifications from it.
//
+ */
}
}
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 16a654f..83edc49 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
@@ -24,8 +24,6 @@
import org.slf4j.LoggerFactory;
import net.floodlightcontroller.core.IOFSwitch;
-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.flowprogrammer.IFlowPusherService.MsgPriority;
@@ -45,12 +43,14 @@
private static Logger log = LoggerFactory.getLogger(FlowSynchronizer.class);
- private DBOperation dbHandler;
+ // TODO: fix after FlowSynchronizer is refactored
+ // private DBOperation dbHandler;
protected IFlowPusherService pusher;
private Map<IOFSwitch, FutureTask<SyncResult>> switchThreads;
public FlowSynchronizer() {
- dbHandler = GraphDBManager.getDBOperation();
+ // TODO: fix after FlowSynchronizer is refactored
+ // dbHandler = GraphDBManager.getDBOperation();
switchThreads = new HashMap<IOFSwitch, FutureTask<SyncResult>>();
}
@@ -91,7 +91,8 @@
public Synchronizer(IOFSwitch sw) {
this.sw = sw;
Dpid dpid = new Dpid(sw.getId());
- this.swObj = dbHandler.searchSwitch(dpid.toString());
+ // TODO: fix after FlowSynchronizer is refactored
+ // this.swObj = dbHandler.searchSwitch(dpid.toString());
}
double graphIDTime, switchTime, compareTime, graphEntryTime, extractTime, pushTime, totalTime;
@@ -283,7 +284,8 @@
// Get the Flow Entry state from the Network Graph
if (iFlowEntry == null) {
try {
- iFlowEntry = dbHandler.searchFlowEntry(flowEntryId);
+ // TODO: fix after FlowSynchronizer is refactored
+ // iFlowEntry = dbHandler.searchFlowEntry(flowEntryId);
} catch (Exception e) {
log.error("Error finding flow entry {} in Network Graph",
flowEntryId);
diff --git a/src/test/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizerTest.java b/src/test/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizerTest.java
index a1398ee..03c9f4f 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizerTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizerTest.java
@@ -9,7 +9,6 @@
import java.util.concurrent.Future;
import net.floodlightcontroller.core.IOFSwitch;
-import net.onrc.onos.graph.DBOperation;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.flowprogrammer.IFlowPusherService.MsgPriority;
@@ -38,7 +37,7 @@
// Test should be fixed to fit RAMCloud basis
@Ignore
@RunWith(PowerMockRunner.class)
-@PrepareForTest({FlowSynchronizer.class, DBOperation.class})
+@PrepareForTest({FlowSynchronizer.class})
public class FlowSynchronizerTest {
private FlowPusher pusher;
private FlowSynchronizer sync;
@@ -252,7 +251,7 @@
}
/**
- * Create mock GraphDBOperation and FlowDatabaseOperation to mock DB.
+ * Create mock FlowDatabaseOperation to mock DB.
* @param idList List of FlowEntry IDs stored in DB.
*/
private void initMockGraph(long[] idList) {