blob: 3a6f13d6f0d7bc4a4a7a6704822c77586bb0b55e [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
7import com.thinkaurelius.titan.core.TitanGraph;
8import com.tinkerpop.blueprints.Vertex;
9import com.tinkerpop.frames.FramedGraph;
10import com.tinkerpop.frames.structures.FramedVertexIterable;
11import com.tinkerpop.gremlin.java.GremlinPipeline;
12import java.util.ArrayList;
yoshitomob292c622013-11-23 14:35:58 -080013import java.util.Iterator;
yoshi0451f282013-11-22 15:48:55 -080014import java.util.List;
15import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.*;
16import net.onrc.onos.ofcontroller.core.ISwitchStorage;
17import net.onrc.onos.ofcontroller.util.FlowEntryId;
18import net.onrc.onos.ofcontroller.util.FlowId;
19
20/**
21 *
22 * @author nickkaranatsios
23 */
24public class TitanDBOperation extends DBOperation {
yoshitomob292c622013-11-23 14:35:58 -080025
yoshi0451f282013-11-22 15:48:55 -080026 @Override
27 public IFlowPath searchFlowPath(FlowId flowId) {
28 FramedGraph<TitanGraph> fg = conn.getFramedGraph();
29 return searchFlowPath(flowId, fg);
30 }
31
yoshi0451f282013-11-22 15:48:55 -080032 @Override
33 public Iterable<IFlowPath> getAllFlowPaths() {
34 FramedGraph<TitanGraph> fg = conn.getFramedGraph();
35 return getAllFlowPaths(fg);
36 }
37
38 @Override
39 public void removeFlowPath(IFlowPath flowPath) {
40 FramedGraph<TitanGraph> fg = conn.getFramedGraph();
41 fg.removeVertex(flowPath.asVertex());
42 }
43
44 @Override
yoshi0451f282013-11-22 15:48:55 -080045 public IFlowEntry searchFlowEntry(FlowEntryId flowEntryId) {
46 FramedGraph<TitanGraph> fg = conn.getFramedGraph();
47
48 return fg.getVertices("flow_entry_id", flowEntryId.toString()).iterator().hasNext()
49 ? fg.getVertices("flow_entry_id", flowEntryId.toString(),
50 IFlowEntry.class).iterator().next() : null;
51 }
52
53 @Override
54 public Iterable<IFlowEntry> getAllFlowEntries() {
55 FramedGraph<TitanGraph> fg = conn.getFramedGraph();
56
57 return fg.getVertices("type", "flow_entry", IFlowEntry.class);
58 }
59
60 @Override
61 public void removeFlowEntry(IFlowEntry flowEntry) {
62 FramedGraph<TitanGraph> fg = conn.getFramedGraph();
63 fg.removeVertex(flowEntry.asVertex());
64 }
65
66 @Override
yoshi0451f282013-11-22 15:48:55 -080067 public void commit() {
68 conn.commit();
69 }
70
71 @Override
72 public void rollback() {
73 conn.rollback();
74 }
75
76 @Override
77 public void close() {
78 conn.close();
79 }
yoshi0451f282013-11-22 15:48:55 -080080}