blob: 6e278d9d6f7ea0c3f4e3d4b8aa91763fc9227e61 [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.Vertex;
Toshio Koide3f233542014-01-07 14:19:09 -08008import com.tinkerpop.blueprints.impls.ramcloud.*;
yoshi0451f282013-11-22 15:48:55 -08009import com.tinkerpop.frames.FramedGraph;
10import com.tinkerpop.frames.structures.FramedVertexIterable;
11import com.tinkerpop.gremlin.java.GremlinPipeline;
Toshio Koide3f233542014-01-07 14:19:09 -080012
yoshi0451f282013-11-22 15:48:55 -080013import java.util.ArrayList;
14import java.util.Iterator;
15import java.util.List;
Toshio Koide3f233542014-01-07 14:19:09 -080016import java.util.Map;
17
18import org.slf4j.Logger;
19import org.slf4j.LoggerFactory;
20
yoshi0451f282013-11-22 15:48:55 -080021import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects;
yoshitomob292c622013-11-23 14:35:58 -080022import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IBaseObject;
yoshi0451f282013-11-22 15:48:55 -080023import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
24import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
25import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
yoshitomob292c622013-11-23 14:35:58 -080026import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IIpv4Address;
yoshi0451f282013-11-22 15:48:55 -080027import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
28import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
29import net.onrc.onos.ofcontroller.core.ISwitchStorage;
yoshib3c83c12013-12-03 00:58:13 -080030import net.onrc.onos.ofcontroller.util.FlowEntryId;
yoshi0451f282013-11-22 15:48:55 -080031import net.onrc.onos.ofcontroller.util.FlowId;
32
yoshi0451f282013-11-22 15:48:55 -080033public abstract class DBOperation implements IDBOperation {
34
yoshic455c012013-11-27 10:35:50 -080035 protected DBConnection conn;
Toshio Koide1de920a2014-01-07 15:43:18 -080036 private final static Logger log = LoggerFactory.getLogger(DBOperation.class);
Toshio Koide3f233542014-01-07 14:19:09 -080037
yoshi0451f282013-11-22 15:48:55 -080038
yoshi2dd767c2013-11-27 23:39:06 -080039 /**
40 * Search and get an active switch object with DPID.
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -080041 * @param dpid DPID of the switch
yoshi2dd767c2013-11-27 23:39:06 -080042 */
yoshic455c012013-11-27 10:35:50 -080043 @Override
44 public ISwitchObject searchActiveSwitch(String dpid) {
45 ISwitchObject sw = searchSwitch(dpid);
46 if ((sw != null)
47 && sw.getState().equals(ISwitchStorage.SwitchState.ACTIVE.toString())) {
48 return sw;
49 }
50 return null;
51 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -080052
yoshi2dd767c2013-11-27 23:39:06 -080053 /**
54 * Create a new switch and return the created switch object.
55 * @param dpid DPID of the switch
56 */
yoshic455c012013-11-27 10:35:50 -080057 @Override
58 public ISwitchObject newSwitch(final String dpid) {
yoshi89eacab2013-12-09 17:29:08 -080059 //System.out.println("newSwitch");
yoshic455c012013-11-27 10:35:50 -080060 ISwitchObject obj = (ISwitchObject) conn.getFramedGraph().addVertex(null, ISwitchObject.class);
61 if (obj != null) {
62 obj.setType("switch");
63 obj.setDPID(dpid);
64 }
65 return obj;
66 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -080067
yoshi2dd767c2013-11-27 23:39:06 -080068 /**
Yuta HIGUCHI2cef9ba2014-01-09 19:33:22 -080069 * Get all port objects.
70 */
71 @Override
72 public Iterable<IPortObject> getAllPorts() {
73 Iterable<IPortObject> ports = conn.getFramedGraph().getVertices("type", "port", IPortObject.class);
74 return ports;
75 }
76
77 /**
yoshi2dd767c2013-11-27 23:39:06 -080078 * Get all switch objects.
79 */
yoshic455c012013-11-27 10:35:50 -080080 @Override
81 public Iterable<ISwitchObject> getAllSwitches() {
yoshi89eacab2013-12-09 17:29:08 -080082 //System.out.println("getAllSwitches");
yoshic455c012013-11-27 10:35:50 -080083 Iterable<ISwitchObject> switches = conn.getFramedGraph().getVertices("type", "switch", ISwitchObject.class);
84 return switches;
85 }
yoshi0451f282013-11-22 15:48:55 -080086
yoshi2dd767c2013-11-27 23:39:06 -080087 /**
88 * Get all inactive switch objects.
89 */
yoshic455c012013-11-27 10:35:50 -080090 @Override
91 public Iterable<ISwitchObject> getInactiveSwitches() {
yoshi89eacab2013-12-09 17:29:08 -080092 //System.out.println("getInactiveSwitches");
yoshic455c012013-11-27 10:35:50 -080093 Iterable<ISwitchObject> switches = conn.getFramedGraph().getVertices("type", "switch", ISwitchObject.class);
94 List<ISwitchObject> inactiveSwitches = new ArrayList<ISwitchObject>();
yoshi0451f282013-11-22 15:48:55 -080095
yoshic455c012013-11-27 10:35:50 -080096 for (ISwitchObject sw : switches) {
97 if (sw.getState().equals(ISwitchStorage.SwitchState.INACTIVE.toString())) {
98 inactiveSwitches.add(sw);
99 }
100 }
101 return inactiveSwitches;
102 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800103
yoshi2dd767c2013-11-27 23:39:06 -0800104 /**
105 * Get all flow entries objects where their switches are not updated.
106 */
yoshic455c012013-11-27 10:35:50 -0800107 @Override
108 public Iterable<INetMapTopologyObjects.IFlowEntry> getAllSwitchNotUpdatedFlowEntries() {
109 //TODO: Should use an enum for flow_switch_state
110 return conn.getFramedGraph().getVertices("switch_state", "FE_SWITCH_NOT_UPDATED", INetMapTopologyObjects.IFlowEntry.class);
yoshi0451f282013-11-22 15:48:55 -0800111
yoshic455c012013-11-27 10:35:50 -0800112 }
yoshi0451f282013-11-22 15:48:55 -0800113
yoshi2dd767c2013-11-27 23:39:06 -0800114 /**
115 * Remove specified switch.
116 * @param sw switch object to remove
117 */
yoshic455c012013-11-27 10:35:50 -0800118 @Override
119 public void removeSwitch(ISwitchObject sw) {
yoshi89eacab2013-12-09 17:29:08 -0800120 //System.out.println("removeSwitch");
yoshic455c012013-11-27 10:35:50 -0800121 conn.getFramedGraph().removeVertex(sw.asVertex());
122 }
yoshi0451f282013-11-22 15:48:55 -0800123
yoshic455c012013-11-27 10:35:50 -0800124 @Override
125 public IPortObject newPort(String dpid, Short portNum) {
yoshi89eacab2013-12-09 17:29:08 -0800126 //System.out.println("newPort");
yoshic455c012013-11-27 10:35:50 -0800127 IPortObject obj = (IPortObject) conn.getFramedGraph().addVertex(null, IPortObject.class);
128 if (obj != null) {
129 obj.setType("port");
Yuta HIGUCHI2cef9ba2014-01-09 19:33:22 -0800130 String id = dpid + PORT_ID_DELIM + portNum.toString();
yoshic455c012013-11-27 10:35:50 -0800131 obj.setPortId(id);
132 obj.setNumber(portNum);
133 }
134 return obj;
135 }
yoshi0451f282013-11-22 15:48:55 -0800136
yoshic455c012013-11-27 10:35:50 -0800137 /**
138 * Create a port having specified port number.
139 *
140 * @param portNumber port number
141 */
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800142 @Override
yoshic455c012013-11-27 10:35:50 -0800143 @Deprecated
144 public IPortObject newPort(Short portNumber) {
145 IPortObject obj = (IPortObject) conn.getFramedGraph().addVertex(null, IPortObject.class);
146 if (obj != null) {
147 obj.setType("port");
148 obj.setNumber(portNumber);
149 }
150 return obj;
151 }
yoshi0451f282013-11-22 15:48:55 -0800152
yoshi2dd767c2013-11-27 23:39:06 -0800153 /**
154 * Search and get a port object of specified switch and port number.
155 * @param dpid DPID of a switch
156 * @param number port number of the switch's port
157 */
yoshic455c012013-11-27 10:35:50 -0800158 @Override
159 public IPortObject searchPort(String dpid, Short number) {
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800160 FramedGraph fg = conn.getFramedGraph();
161 if ( fg == null ) return null;
Yuta HIGUCHI2cef9ba2014-01-09 19:33:22 -0800162 String id = dpid + PORT_ID_DELIM + number.toString();
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800163 Iterator<IPortObject> it = fg.getVertices("port_id", id, IPortObject.class).iterator();
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800164 return (it.hasNext()) ? it.next() : null;
yoshi0451f282013-11-22 15:48:55 -0800165
yoshic455c012013-11-27 10:35:50 -0800166 }
yoshi0451f282013-11-22 15:48:55 -0800167
yoshi2dd767c2013-11-27 23:39:06 -0800168 /**
169 * Remove the specified switch port.
170 * @param port switch port object to remove
171 */
yoshic455c012013-11-27 10:35:50 -0800172 @Override
173 public void removePort(IPortObject port) {
yoshi89eacab2013-12-09 17:29:08 -0800174 //System.out.println("removeProt");
yoshic455c012013-11-27 10:35:50 -0800175 if (conn.getFramedGraph() != null) {
176 conn.getFramedGraph().removeVertex(port.asVertex());
177 }
178 }
179
yoshi2dd767c2013-11-27 23:39:06 -0800180 /**
181 * Create and return a device object.
182 */
yoshic455c012013-11-27 10:35:50 -0800183 @Override
184 public IDeviceObject newDevice() {
yoshi89eacab2013-12-09 17:29:08 -0800185 //System.out.println("newDevice");
yoshic455c012013-11-27 10:35:50 -0800186 IDeviceObject obj = (IDeviceObject) conn.getFramedGraph().addVertex(null, IDeviceObject.class);
187 if (obj != null) {
188 obj.setType("device");
189 }
190 return obj;
191 }
192
yoshi2dd767c2013-11-27 23:39:06 -0800193 /**
194 * Get all devices.
195 */
yoshic455c012013-11-27 10:35:50 -0800196 @Override
197 public Iterable<IDeviceObject> getDevices() {
yoshi89eacab2013-12-09 17:29:08 -0800198 //System.out.println("getDeiveces");
yoshic455c012013-11-27 10:35:50 -0800199 return conn.getFramedGraph() != null ? conn.getFramedGraph().getVertices("type", "device", IDeviceObject.class) : null;
200 }
yoshi0451f282013-11-22 15:48:55 -0800201
yoshi2dd767c2013-11-27 23:39:06 -0800202 /**
203 * Remove the specified device.
204 * @param dev a device object to remove
205 */
yoshic455c012013-11-27 10:35:50 -0800206 @Override
207 public void removeDevice(IDeviceObject dev) {
yoshi89eacab2013-12-09 17:29:08 -0800208 //System.out.println("removeDevice");
yoshic455c012013-11-27 10:35:50 -0800209 if (conn.getFramedGraph() != null) {
210 conn.getFramedGraph().removeVertex(dev.asVertex());
211 }
212 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800213
yoshic455c012013-11-27 10:35:50 -0800214 /**
215 * Create and return a flow path object.
216 */
yoshic455c012013-11-27 10:35:50 -0800217 @Override
218 public IFlowPath newFlowPath() {
yoshi89eacab2013-12-09 17:29:08 -0800219 //System.out.println("newFlowPath");
yoshic455c012013-11-27 10:35:50 -0800220 IFlowPath flowPath = (IFlowPath)conn.getFramedGraph().addVertex(null, IFlowPath.class);
yoshi89eacab2013-12-09 17:29:08 -0800221 //System.out.println("flowPath : " + flowPath);
yoshic455c012013-11-27 10:35:50 -0800222 if (flowPath != null) {
223 flowPath.setType("flow");
224 }
225 return flowPath;
226 }
yoshi0451f282013-11-22 15:48:55 -0800227
yoshi2dd767c2013-11-27 23:39:06 -0800228 /**
229 * Get a flow path object with a flow entry.
230 * @param flowEntry flow entry object
231 */
yoshic455c012013-11-27 10:35:50 -0800232 @Override
233 public IFlowPath getFlowPathByFlowEntry(INetMapTopologyObjects.IFlowEntry flowEntry) {
234 GremlinPipeline<Vertex, IFlowPath> pipe = new GremlinPipeline<Vertex, IFlowPath>();
235 pipe.start(flowEntry.asVertex());
236 pipe.out("flow");
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800237 FramedVertexIterable<IFlowPath> r = new FramedVertexIterable(conn.getFramedGraph(), pipe, IFlowPath.class);
yoshic455c012013-11-27 10:35:50 -0800238 return r.iterator().hasNext() ? r.iterator().next() : null;
239 }
yoshi0451f282013-11-22 15:48:55 -0800240
yoshi0451f282013-11-22 15:48:55 -0800241
yoshic455c012013-11-27 10:35:50 -0800242 /**
243 * Search and get a switch object with DPID.
244 *
245 * @param dpid DPID of the switch
246 */
247 @Override
248 public ISwitchObject searchSwitch(final String dpid) {
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800249 FramedGraph fg = conn.getFramedGraph();
250 if ( fg == null ) return null;
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800251 Iterator<ISwitchObject> it = fg.getVertices("dpid", dpid, ISwitchObject.class).iterator();
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800252 return (it.hasNext()) ? it.next() : null;
yoshic455c012013-11-27 10:35:50 -0800253 }
yoshi0451f282013-11-22 15:48:55 -0800254
yoshi2dd767c2013-11-27 23:39:06 -0800255 /**
256 * Get all active switch objects.
257 */
yoshic455c012013-11-27 10:35:50 -0800258 @Override
259 public Iterable<ISwitchObject> getActiveSwitches() {
260 Iterable<ISwitchObject> switches = conn.getFramedGraph().getVertices("type", "switch", ISwitchObject.class);
261 List<ISwitchObject> activeSwitches = new ArrayList<ISwitchObject>();
yoshi0451f282013-11-22 15:48:55 -0800262
yoshic455c012013-11-27 10:35:50 -0800263 for (ISwitchObject sw : switches) {
264 if (sw.getState().equals(ISwitchStorage.SwitchState.ACTIVE.toString())) {
265 activeSwitches.add(sw);
266 }
267 }
268 return activeSwitches;
269 }
yoshi0451f282013-11-22 15:48:55 -0800270
yoshi2dd767c2013-11-27 23:39:06 -0800271 /**
272 * Search and get a device object having specified MAC address.
273 * @param macAddr MAC address to search and get
274 */
yoshic455c012013-11-27 10:35:50 -0800275 @Override
276 public IDeviceObject searchDevice(String macAddr) {
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800277 FramedGraph fg = conn.getFramedGraph();
278 if ( fg == null ) return null;
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800279 Iterator<IDeviceObject> it = fg.getVertices("dl_addr", macAddr, IDeviceObject.class).iterator();
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800280 return (it.hasNext()) ? it.next() : null;
yoshic455c012013-11-27 10:35:50 -0800281 }
282
yoshi2dd767c2013-11-27 23:39:06 -0800283 /**
284 * Search and get a flow path object with specified flow ID.
285 * @param flowId flow ID to search
286 */
yoshib3c83c12013-12-03 00:58:13 -0800287 @Override
288 public IFlowPath searchFlowPath(final FlowId flowId) {
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800289 FramedGraph fg = conn.getFramedGraph();
290 if ( fg == null ) return null;
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800291 Iterator<IFlowPath> it = fg.getVertices("flow_id", flowId.toString(), IFlowPath.class).iterator();
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800292 return (it.hasNext()) ? it.next() : null;
yoshic455c012013-11-27 10:35:50 -0800293 }
294
yoshi2dd767c2013-11-27 23:39:06 -0800295 /**
296 * Get all flow path objects.
297 */
yoshib3c83c12013-12-03 00:58:13 -0800298 @Override
299 public Iterable<IFlowPath> getAllFlowPaths() {
yoshi89eacab2013-12-09 17:29:08 -0800300 //System.out.println("getAllFlowPaths");
yoshib3c83c12013-12-03 00:58:13 -0800301 Iterable<IFlowPath> flowPaths = conn.getFramedGraph().getVertices("type", "flow", IFlowPath.class);
yoshic455c012013-11-27 10:35:50 -0800302
303 List<IFlowPath> nonNullFlows = new ArrayList<IFlowPath>();
304
305 for (IFlowPath fp : flowPaths) {
306 if (fp.getFlowId() != null) {
307 nonNullFlows.add(fp);
308 }
309 }
310 return nonNullFlows;
311 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800312
yoshi2dd767c2013-11-27 23:39:06 -0800313 /**
yoshib3c83c12013-12-03 00:58:13 -0800314 * Remove the specified flow path.
315 * @param flowPath flow path object to remove
316 */
317 @Override
318 public void removeFlowPath(IFlowPath flowPath) {
yoshi89eacab2013-12-09 17:29:08 -0800319 //System.out.println("removeFlowPath");
yoshib3c83c12013-12-03 00:58:13 -0800320 conn.getFramedGraph().removeVertex(flowPath.asVertex());
321 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800322
yoshib3c83c12013-12-03 00:58:13 -0800323 /**
324 * Search and get a flow entry object with flow entry ID.
325 * @param flowEntryId flow entry ID to search
326 */
327 @Override
328 public IFlowEntry searchFlowEntry(FlowEntryId flowEntryId) {
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800329 FramedGraph fg = conn.getFramedGraph();
330 if ( fg == null ) return null;
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800331 Iterator<IFlowEntry> it = fg.getVertices("flow_entry_id", flowEntryId.toString(), IFlowEntry.class).iterator();
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800332 return (it.hasNext()) ? it.next() : null;
yoshib3c83c12013-12-03 00:58:13 -0800333 }
334
335 /**
336 * Get all flow entry objects.
337 */
338 @Override
339 public Iterable<IFlowEntry> getAllFlowEntries() {
340 return conn.getFramedGraph().getVertices("type", "flow_entry", IFlowEntry.class);
341 }
342
343 /**
344 * Remove the specified flow entry.
345 * @param flowEntry flow entry object to remove
346 */
347 @Override
348 public void removeFlowEntry(IFlowEntry flowEntry) {
yoshi89eacab2013-12-09 17:29:08 -0800349 //System.out.println("removeFlowEntry");
yoshib3c83c12013-12-03 00:58:13 -0800350 conn.getFramedGraph().removeVertex(flowEntry.asVertex());
351 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800352
yoshib3c83c12013-12-03 00:58:13 -0800353 /**
yoshi2dd767c2013-11-27 23:39:06 -0800354 * Create and return a flow entry object.
355 */
yoshic455c012013-11-27 10:35:50 -0800356 @Override
357 public IFlowEntry newFlowEntry() {
yoshi89eacab2013-12-09 17:29:08 -0800358 //System.out.println("newFlowEntry");
yoshic455c012013-11-27 10:35:50 -0800359 IFlowEntry flowEntry = (IFlowEntry) conn.getFramedGraph().addVertex(null, IFlowEntry.class);
360 if (flowEntry != null) {
361 flowEntry.setType("flow_entry");
362 }
363 return flowEntry;
364 }
365
366
yoshitomob292c622013-11-23 14:35:58 -0800367 public IIpv4Address newIpv4Address() {
368 return newVertex("ipv4Address", IIpv4Address.class);
369 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800370
yoshitomob292c622013-11-23 14:35:58 -0800371 private <T extends IBaseObject> T newVertex(String type, Class<T> vertexType) {
yoshi9247b812013-11-27 11:26:14 -0800372 T newVertex = (T) conn.getFramedGraph().addVertex(null, vertexType);
yoshitomob292c622013-11-23 14:35:58 -0800373 if (newVertex != null) {
374 newVertex.setType(type);
375 }
376 return newVertex;
377 }
yoshic455c012013-11-27 10:35:50 -0800378
yoshitomob292c622013-11-23 14:35:58 -0800379 public IIpv4Address searchIpv4Address(int intIpv4Address) {
380 return searchForVertex("ipv4_address", intIpv4Address, IIpv4Address.class);
381 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800382
383
yoshitomob292c622013-11-23 14:35:58 -0800384 public IIpv4Address ensureIpv4Address(int intIpv4Address) {
385 IIpv4Address ipv4Vertex = searchIpv4Address(intIpv4Address);
386 if (ipv4Vertex == null) {
387 ipv4Vertex = newIpv4Address();
388 ipv4Vertex.setIpv4Address(intIpv4Address);
389 }
390 return ipv4Vertex;
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800391 }
yoshitomob292c622013-11-23 14:35:58 -0800392
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800393
yoshitomob292c622013-11-23 14:35:58 -0800394 private <T> T searchForVertex(String propertyName, Object propertyValue, Class<T> vertexType) {
395 if (conn.getFramedGraph() != null) {
396 Iterator<T> it = conn.getFramedGraph().getVertices(propertyName, propertyValue, vertexType).iterator();
397 if (it.hasNext()) {
398 return it.next();
399 }
400 }
401 return null;
402 }
403
404 public void removeIpv4Address(IIpv4Address ipv4Address) {
yoshi89eacab2013-12-09 17:29:08 -0800405 //System.out.println("removeIpv4Address");
yoshitomob292c622013-11-23 14:35:58 -0800406 conn.getFramedGraph().removeVertex(ipv4Address.asVertex());
407 }
yoshi0451f282013-11-22 15:48:55 -0800408
yoshib3c83c12013-12-03 00:58:13 -0800409 /**
410 * Get the instance of GraphDBConnection assigned to this class.
411 */
yoshi7594aef2013-11-27 09:27:07 -0800412 @Override
413 public IDBConnection getDBConnection() {
414 return conn;
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800415 }
416
yoshib3c83c12013-12-03 00:58:13 -0800417 @Override
418 public void commit() {
419 conn.commit();
420 }
421
422 @Override
423 public void rollback() {
424 conn.rollback();
425 }
426
427 @Override
428 public void close() {
429 conn.close();
430 }
Toshio Koide3f233542014-01-07 14:19:09 -0800431
432 @Override
Toshio Koide3fcebc12014-01-09 22:40:11 -0800433 public void setVertexProperties(Vertex vertex, Map<String, Object> map) {
Toshio Koide3f233542014-01-07 14:19:09 -0800434 log.debug("setProperties start: size {}", map.size());
Toshio Koide3fcebc12014-01-09 22:40:11 -0800435 RamCloudVertex v = (RamCloudVertex) vertex;
Toshio Koide3f233542014-01-07 14:19:09 -0800436 v.setProperties(map);
437 log.debug("setProperties end: size {}, id {}", map.size(), v.getId());
438 }
Toshio Koide3fcebc12014-01-09 22:40:11 -0800439
440 public String toString() {
441 StringBuilder sb = new StringBuilder();
442 for(ISwitchObject sw: getAllSwitches()) {
443 sb.append("sw: " + sw.getDPID() + "\n");
444 for(IPortObject port: sw.getPorts()) {
445 sb.append(" port: " + port.getPortId() + "\n");
446 }
447 }
448 return sb.toString();
449 }
yoshi0451f282013-11-22 15:48:55 -0800450}