blob: 657c521c52c05d6679e3713f24e057b5e4f0c0e3 [file] [log] [blame]
yoshi0451f282013-11-22 15:48:55 -08001/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package net.onrc.onos.graph;
6
yoshi0451f282013-11-22 15:48:55 -08007import com.tinkerpop.blueprints.impls.ramcloud.RamCloudGraph;
8import com.tinkerpop.frames.FramedGraph;
yoshi0451f282013-11-22 15:48:55 -08009import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects;
10import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
11import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
12import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
13import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
yoshie665e822013-11-26 19:51:16 -080014import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
yoshi0451f282013-11-22 15:48:55 -080015import net.onrc.onos.ofcontroller.util.FlowEntryId;
16import net.onrc.onos.ofcontroller.util.FlowId;
17import org.apache.commons.configuration.Configuration;
18
19/**
20 *
21 * @author nickkaranatsios
22 */
23public class RamCloudDBOperation extends DBOperation {
24
25 public RamCloudDBOperation() {
yoshi0451f282013-11-22 15:48:55 -080026 }
27
28 @Override
yoshie665e822013-11-26 19:51:16 -080029 public IFlowPath searchFlowPath(FlowId flowId) {
yoshi0451f282013-11-22 15:48:55 -080030 FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
31 return searchFlowPath(flowId, fg);
32 }
33
34 @Override
35 public Iterable<IFlowPath> getAllFlowPaths() {
36 FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
37 return getAllFlowPaths(fg);
38 }
39
40 @Override
yoshie665e822013-11-26 19:51:16 -080041 public void removeFlowPath(IFlowPath flowPath) {
yoshi0451f282013-11-22 15:48:55 -080042 FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
43 fg.removeVertex(flowPath.asVertex());
44 }
45
46 @Override
yoshie665e822013-11-26 19:51:16 -080047 public IFlowEntry searchFlowEntry(FlowEntryId flowEntryId) {
48 FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
49
50 return fg.getVertices("flow_entry_id", flowEntryId.toString()).iterator().hasNext()
51 ? fg.getVertices("flow_entry_id", flowEntryId.toString(),
52 IFlowEntry.class).iterator().next() : null;
yoshi0451f282013-11-22 15:48:55 -080053 }
54
55 @Override
yoshie665e822013-11-26 19:51:16 -080056 public Iterable<IFlowEntry> getAllFlowEntries() {
57 FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
58
59 return fg.getVertices("type", "flow_entry", IFlowEntry.class);
yoshi0451f282013-11-22 15:48:55 -080060 }
61
62 @Override
yoshie665e822013-11-26 19:51:16 -080063 public void removeFlowEntry(IFlowEntry flowEntry) {
64 FramedGraph<RamCloudGraph> fg = conn.getFramedGraph();
65 fg.removeVertex(flowEntry.asVertex());
yoshi0451f282013-11-22 15:48:55 -080066 }
67
68 @Override
yoshi0451f282013-11-22 15:48:55 -080069 public void commit() {
yoshie665e822013-11-26 19:51:16 -080070 conn.commit();
yoshi0451f282013-11-22 15:48:55 -080071 }
72
73 @Override
74 public void rollback() {
yoshie665e822013-11-26 19:51:16 -080075 conn.rollback();
yoshi0451f282013-11-22 15:48:55 -080076 }
77
78 @Override
79 public void close() {
yoshie665e822013-11-26 19:51:16 -080080 conn.close();
yoshi0451f282013-11-22 15:48:55 -080081 }
yoshi0451f282013-11-22 15:48:55 -080082}