blob: 730f7278231d2e3ba038a78ec328974c3be4f386 [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;
Toshio Koide3f233542014-01-07 14:19:09 -080030import net.onrc.onos.ofcontroller.flowmanager.FlowDatabaseOperation;
yoshib3c83c12013-12-03 00:58:13 -080031import net.onrc.onos.ofcontroller.util.FlowEntryId;
yoshi0451f282013-11-22 15:48:55 -080032import net.onrc.onos.ofcontroller.util.FlowId;
33
yoshi0451f282013-11-22 15:48:55 -080034public abstract class DBOperation implements IDBOperation {
35
yoshic455c012013-11-27 10:35:50 -080036 protected DBConnection conn;
Toshio Koide1de920a2014-01-07 15:43:18 -080037 private final static Logger log = LoggerFactory.getLogger(DBOperation.class);
Toshio Koide3f233542014-01-07 14:19:09 -080038
yoshi0451f282013-11-22 15:48:55 -080039
yoshi2dd767c2013-11-27 23:39:06 -080040 /**
41 * Search and get an active switch object with DPID.
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -080042 * @param dpid DPID of the switch
yoshi2dd767c2013-11-27 23:39:06 -080043 */
yoshic455c012013-11-27 10:35:50 -080044 @Override
45 public ISwitchObject searchActiveSwitch(String dpid) {
46 ISwitchObject sw = searchSwitch(dpid);
47 if ((sw != null)
48 && sw.getState().equals(ISwitchStorage.SwitchState.ACTIVE.toString())) {
49 return sw;
50 }
51 return null;
52 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -080053
yoshi2dd767c2013-11-27 23:39:06 -080054 /**
55 * Create a new switch and return the created switch object.
56 * @param dpid DPID of the switch
57 */
yoshic455c012013-11-27 10:35:50 -080058 @Override
59 public ISwitchObject newSwitch(final String dpid) {
yoshi89eacab2013-12-09 17:29:08 -080060 //System.out.println("newSwitch");
yoshic455c012013-11-27 10:35:50 -080061 ISwitchObject obj = (ISwitchObject) conn.getFramedGraph().addVertex(null, ISwitchObject.class);
62 if (obj != null) {
63 obj.setType("switch");
64 obj.setDPID(dpid);
65 }
66 return obj;
67 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -080068
yoshi2dd767c2013-11-27 23:39:06 -080069 /**
70 * Get all switch objects.
71 */
yoshic455c012013-11-27 10:35:50 -080072 @Override
73 public Iterable<ISwitchObject> getAllSwitches() {
yoshi89eacab2013-12-09 17:29:08 -080074 //System.out.println("getAllSwitches");
yoshic455c012013-11-27 10:35:50 -080075 Iterable<ISwitchObject> switches = conn.getFramedGraph().getVertices("type", "switch", ISwitchObject.class);
76 return switches;
77 }
yoshi0451f282013-11-22 15:48:55 -080078
yoshi2dd767c2013-11-27 23:39:06 -080079 /**
80 * Get all inactive switch objects.
81 */
yoshic455c012013-11-27 10:35:50 -080082 @Override
83 public Iterable<ISwitchObject> getInactiveSwitches() {
yoshi89eacab2013-12-09 17:29:08 -080084 //System.out.println("getInactiveSwitches");
yoshic455c012013-11-27 10:35:50 -080085 Iterable<ISwitchObject> switches = conn.getFramedGraph().getVertices("type", "switch", ISwitchObject.class);
86 List<ISwitchObject> inactiveSwitches = new ArrayList<ISwitchObject>();
yoshi0451f282013-11-22 15:48:55 -080087
yoshic455c012013-11-27 10:35:50 -080088 for (ISwitchObject sw : switches) {
89 if (sw.getState().equals(ISwitchStorage.SwitchState.INACTIVE.toString())) {
90 inactiveSwitches.add(sw);
91 }
92 }
93 return inactiveSwitches;
94 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -080095
yoshi2dd767c2013-11-27 23:39:06 -080096 /**
97 * Get all flow entries objects where their switches are not updated.
98 */
yoshic455c012013-11-27 10:35:50 -080099 @Override
100 public Iterable<INetMapTopologyObjects.IFlowEntry> getAllSwitchNotUpdatedFlowEntries() {
101 //TODO: Should use an enum for flow_switch_state
102 return conn.getFramedGraph().getVertices("switch_state", "FE_SWITCH_NOT_UPDATED", INetMapTopologyObjects.IFlowEntry.class);
yoshi0451f282013-11-22 15:48:55 -0800103
yoshic455c012013-11-27 10:35:50 -0800104 }
yoshi0451f282013-11-22 15:48:55 -0800105
yoshi2dd767c2013-11-27 23:39:06 -0800106 /**
107 * Remove specified switch.
108 * @param sw switch object to remove
109 */
yoshic455c012013-11-27 10:35:50 -0800110 @Override
111 public void removeSwitch(ISwitchObject sw) {
yoshi89eacab2013-12-09 17:29:08 -0800112 //System.out.println("removeSwitch");
yoshic455c012013-11-27 10:35:50 -0800113 conn.getFramedGraph().removeVertex(sw.asVertex());
114 }
yoshi0451f282013-11-22 15:48:55 -0800115
yoshic455c012013-11-27 10:35:50 -0800116 @Override
117 public IPortObject newPort(String dpid, Short portNum) {
yoshi89eacab2013-12-09 17:29:08 -0800118 //System.out.println("newPort");
yoshic455c012013-11-27 10:35:50 -0800119 IPortObject obj = (IPortObject) conn.getFramedGraph().addVertex(null, IPortObject.class);
120 if (obj != null) {
121 obj.setType("port");
122 String id = dpid + portNum.toString();
123 obj.setPortId(id);
124 obj.setNumber(portNum);
125 }
126 return obj;
127 }
yoshi0451f282013-11-22 15:48:55 -0800128
yoshic455c012013-11-27 10:35:50 -0800129 /**
130 * Create a port having specified port number.
131 *
132 * @param portNumber port number
133 */
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800134 @Override
yoshic455c012013-11-27 10:35:50 -0800135 @Deprecated
136 public IPortObject newPort(Short portNumber) {
137 IPortObject obj = (IPortObject) conn.getFramedGraph().addVertex(null, IPortObject.class);
138 if (obj != null) {
139 obj.setType("port");
140 obj.setNumber(portNumber);
141 }
142 return obj;
143 }
yoshi0451f282013-11-22 15:48:55 -0800144
yoshi2dd767c2013-11-27 23:39:06 -0800145 /**
146 * Search and get a port object of specified switch and port number.
147 * @param dpid DPID of a switch
148 * @param number port number of the switch's port
149 */
yoshic455c012013-11-27 10:35:50 -0800150 @Override
151 public IPortObject searchPort(String dpid, Short number) {
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800152 FramedGraph fg = conn.getFramedGraph();
153 if ( fg == null ) return null;
yoshic455c012013-11-27 10:35:50 -0800154 String id = dpid + number.toString();
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800155 Iterator<IPortObject> it = fg.getVertices("port_id", id, IPortObject.class).iterator();
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800156 return (it.hasNext()) ? it.next() : null;
yoshi0451f282013-11-22 15:48:55 -0800157
yoshic455c012013-11-27 10:35:50 -0800158 }
yoshi0451f282013-11-22 15:48:55 -0800159
yoshi2dd767c2013-11-27 23:39:06 -0800160 /**
161 * Remove the specified switch port.
162 * @param port switch port object to remove
163 */
yoshic455c012013-11-27 10:35:50 -0800164 @Override
165 public void removePort(IPortObject port) {
yoshi89eacab2013-12-09 17:29:08 -0800166 //System.out.println("removeProt");
yoshic455c012013-11-27 10:35:50 -0800167 if (conn.getFramedGraph() != null) {
168 conn.getFramedGraph().removeVertex(port.asVertex());
169 }
170 }
171
yoshi2dd767c2013-11-27 23:39:06 -0800172 /**
173 * Create and return a device object.
174 */
yoshic455c012013-11-27 10:35:50 -0800175 @Override
176 public IDeviceObject newDevice() {
yoshi89eacab2013-12-09 17:29:08 -0800177 //System.out.println("newDevice");
yoshic455c012013-11-27 10:35:50 -0800178 IDeviceObject obj = (IDeviceObject) conn.getFramedGraph().addVertex(null, IDeviceObject.class);
179 if (obj != null) {
180 obj.setType("device");
181 }
182 return obj;
183 }
184
yoshi2dd767c2013-11-27 23:39:06 -0800185 /**
186 * Get all devices.
187 */
yoshic455c012013-11-27 10:35:50 -0800188 @Override
189 public Iterable<IDeviceObject> getDevices() {
yoshi89eacab2013-12-09 17:29:08 -0800190 //System.out.println("getDeiveces");
yoshic455c012013-11-27 10:35:50 -0800191 return conn.getFramedGraph() != null ? conn.getFramedGraph().getVertices("type", "device", IDeviceObject.class) : null;
192 }
yoshi0451f282013-11-22 15:48:55 -0800193
yoshi2dd767c2013-11-27 23:39:06 -0800194 /**
195 * Remove the specified device.
196 * @param dev a device object to remove
197 */
yoshic455c012013-11-27 10:35:50 -0800198 @Override
199 public void removeDevice(IDeviceObject dev) {
yoshi89eacab2013-12-09 17:29:08 -0800200 //System.out.println("removeDevice");
yoshic455c012013-11-27 10:35:50 -0800201 if (conn.getFramedGraph() != null) {
202 conn.getFramedGraph().removeVertex(dev.asVertex());
203 }
204 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800205
yoshic455c012013-11-27 10:35:50 -0800206 /**
207 * Create and return a flow path object.
208 */
yoshic455c012013-11-27 10:35:50 -0800209 @Override
210 public IFlowPath newFlowPath() {
yoshi89eacab2013-12-09 17:29:08 -0800211 //System.out.println("newFlowPath");
yoshic455c012013-11-27 10:35:50 -0800212 IFlowPath flowPath = (IFlowPath)conn.getFramedGraph().addVertex(null, IFlowPath.class);
yoshi89eacab2013-12-09 17:29:08 -0800213 //System.out.println("flowPath : " + flowPath);
yoshic455c012013-11-27 10:35:50 -0800214 if (flowPath != null) {
215 flowPath.setType("flow");
216 }
217 return flowPath;
218 }
yoshi0451f282013-11-22 15:48:55 -0800219
yoshi2dd767c2013-11-27 23:39:06 -0800220 /**
221 * Get a flow path object with a flow entry.
222 * @param flowEntry flow entry object
223 */
yoshic455c012013-11-27 10:35:50 -0800224 @Override
225 public IFlowPath getFlowPathByFlowEntry(INetMapTopologyObjects.IFlowEntry flowEntry) {
226 GremlinPipeline<Vertex, IFlowPath> pipe = new GremlinPipeline<Vertex, IFlowPath>();
227 pipe.start(flowEntry.asVertex());
228 pipe.out("flow");
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800229 FramedVertexIterable<IFlowPath> r = new FramedVertexIterable(conn.getFramedGraph(), pipe, IFlowPath.class);
yoshic455c012013-11-27 10:35:50 -0800230 return r.iterator().hasNext() ? r.iterator().next() : null;
231 }
yoshi0451f282013-11-22 15:48:55 -0800232
yoshi0451f282013-11-22 15:48:55 -0800233
yoshic455c012013-11-27 10:35:50 -0800234 /**
235 * Search and get a switch object with DPID.
236 *
237 * @param dpid DPID of the switch
238 */
239 @Override
240 public ISwitchObject searchSwitch(final String dpid) {
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800241 FramedGraph fg = conn.getFramedGraph();
242 if ( fg == null ) return null;
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800243 Iterator<ISwitchObject> it = fg.getVertices("dpid", dpid, ISwitchObject.class).iterator();
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800244 return (it.hasNext()) ? it.next() : null;
yoshic455c012013-11-27 10:35:50 -0800245 }
yoshi0451f282013-11-22 15:48:55 -0800246
yoshi2dd767c2013-11-27 23:39:06 -0800247 /**
248 * Get all active switch objects.
249 */
yoshic455c012013-11-27 10:35:50 -0800250 @Override
251 public Iterable<ISwitchObject> getActiveSwitches() {
252 Iterable<ISwitchObject> switches = conn.getFramedGraph().getVertices("type", "switch", ISwitchObject.class);
253 List<ISwitchObject> activeSwitches = new ArrayList<ISwitchObject>();
yoshi0451f282013-11-22 15:48:55 -0800254
yoshic455c012013-11-27 10:35:50 -0800255 for (ISwitchObject sw : switches) {
256 if (sw.getState().equals(ISwitchStorage.SwitchState.ACTIVE.toString())) {
257 activeSwitches.add(sw);
258 }
259 }
260 return activeSwitches;
261 }
yoshi0451f282013-11-22 15:48:55 -0800262
yoshi2dd767c2013-11-27 23:39:06 -0800263 /**
264 * Search and get a device object having specified MAC address.
265 * @param macAddr MAC address to search and get
266 */
yoshic455c012013-11-27 10:35:50 -0800267 @Override
268 public IDeviceObject searchDevice(String macAddr) {
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800269 FramedGraph fg = conn.getFramedGraph();
270 if ( fg == null ) return null;
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800271 Iterator<IDeviceObject> it = fg.getVertices("dl_addr", macAddr, IDeviceObject.class).iterator();
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800272 return (it.hasNext()) ? it.next() : null;
yoshic455c012013-11-27 10:35:50 -0800273 }
274
yoshi2dd767c2013-11-27 23:39:06 -0800275 /**
276 * Search and get a flow path object with specified flow ID.
277 * @param flowId flow ID to search
278 */
yoshib3c83c12013-12-03 00:58:13 -0800279 @Override
280 public IFlowPath searchFlowPath(final FlowId flowId) {
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800281 FramedGraph fg = conn.getFramedGraph();
282 if ( fg == null ) return null;
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800283 Iterator<IFlowPath> it = fg.getVertices("flow_id", flowId.toString(), IFlowPath.class).iterator();
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800284 return (it.hasNext()) ? it.next() : null;
yoshic455c012013-11-27 10:35:50 -0800285 }
286
yoshi2dd767c2013-11-27 23:39:06 -0800287 /**
288 * Get all flow path objects.
289 */
yoshib3c83c12013-12-03 00:58:13 -0800290 @Override
291 public Iterable<IFlowPath> getAllFlowPaths() {
yoshi89eacab2013-12-09 17:29:08 -0800292 //System.out.println("getAllFlowPaths");
yoshib3c83c12013-12-03 00:58:13 -0800293 Iterable<IFlowPath> flowPaths = conn.getFramedGraph().getVertices("type", "flow", IFlowPath.class);
yoshic455c012013-11-27 10:35:50 -0800294
295 List<IFlowPath> nonNullFlows = new ArrayList<IFlowPath>();
296
297 for (IFlowPath fp : flowPaths) {
298 if (fp.getFlowId() != null) {
299 nonNullFlows.add(fp);
300 }
301 }
302 return nonNullFlows;
303 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800304
yoshi2dd767c2013-11-27 23:39:06 -0800305 /**
yoshib3c83c12013-12-03 00:58:13 -0800306 * Remove the specified flow path.
307 * @param flowPath flow path object to remove
308 */
309 @Override
310 public void removeFlowPath(IFlowPath flowPath) {
yoshi89eacab2013-12-09 17:29:08 -0800311 //System.out.println("removeFlowPath");
yoshib3c83c12013-12-03 00:58:13 -0800312 conn.getFramedGraph().removeVertex(flowPath.asVertex());
313 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800314
yoshib3c83c12013-12-03 00:58:13 -0800315 /**
316 * Search and get a flow entry object with flow entry ID.
317 * @param flowEntryId flow entry ID to search
318 */
319 @Override
320 public IFlowEntry searchFlowEntry(FlowEntryId flowEntryId) {
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800321 FramedGraph fg = conn.getFramedGraph();
322 if ( fg == null ) return null;
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800323 Iterator<IFlowEntry> it = fg.getVertices("flow_entry_id", flowEntryId.toString(), IFlowEntry.class).iterator();
Yuta HIGUCHIfa9bcb12013-12-14 00:14:58 -0800324 return (it.hasNext()) ? it.next() : null;
yoshib3c83c12013-12-03 00:58:13 -0800325 }
326
327 /**
328 * Get all flow entry objects.
329 */
330 @Override
331 public Iterable<IFlowEntry> getAllFlowEntries() {
332 return conn.getFramedGraph().getVertices("type", "flow_entry", IFlowEntry.class);
333 }
334
335 /**
336 * Remove the specified flow entry.
337 * @param flowEntry flow entry object to remove
338 */
339 @Override
340 public void removeFlowEntry(IFlowEntry flowEntry) {
yoshi89eacab2013-12-09 17:29:08 -0800341 //System.out.println("removeFlowEntry");
yoshib3c83c12013-12-03 00:58:13 -0800342 conn.getFramedGraph().removeVertex(flowEntry.asVertex());
343 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800344
yoshib3c83c12013-12-03 00:58:13 -0800345 /**
yoshi2dd767c2013-11-27 23:39:06 -0800346 * Create and return a flow entry object.
347 */
yoshic455c012013-11-27 10:35:50 -0800348 @Override
349 public IFlowEntry newFlowEntry() {
yoshi89eacab2013-12-09 17:29:08 -0800350 //System.out.println("newFlowEntry");
yoshic455c012013-11-27 10:35:50 -0800351 IFlowEntry flowEntry = (IFlowEntry) conn.getFramedGraph().addVertex(null, IFlowEntry.class);
352 if (flowEntry != null) {
353 flowEntry.setType("flow_entry");
354 }
355 return flowEntry;
356 }
357
358
yoshitomob292c622013-11-23 14:35:58 -0800359 public IIpv4Address newIpv4Address() {
360 return newVertex("ipv4Address", IIpv4Address.class);
361 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800362
yoshitomob292c622013-11-23 14:35:58 -0800363 private <T extends IBaseObject> T newVertex(String type, Class<T> vertexType) {
yoshi9247b812013-11-27 11:26:14 -0800364 T newVertex = (T) conn.getFramedGraph().addVertex(null, vertexType);
yoshitomob292c622013-11-23 14:35:58 -0800365 if (newVertex != null) {
366 newVertex.setType(type);
367 }
368 return newVertex;
369 }
yoshic455c012013-11-27 10:35:50 -0800370
yoshitomob292c622013-11-23 14:35:58 -0800371 public IIpv4Address searchIpv4Address(int intIpv4Address) {
372 return searchForVertex("ipv4_address", intIpv4Address, IIpv4Address.class);
373 }
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800374
375
yoshitomob292c622013-11-23 14:35:58 -0800376 public IIpv4Address ensureIpv4Address(int intIpv4Address) {
377 IIpv4Address ipv4Vertex = searchIpv4Address(intIpv4Address);
378 if (ipv4Vertex == null) {
379 ipv4Vertex = newIpv4Address();
380 ipv4Vertex.setIpv4Address(intIpv4Address);
381 }
382 return ipv4Vertex;
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800383 }
yoshitomob292c622013-11-23 14:35:58 -0800384
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800385
yoshitomob292c622013-11-23 14:35:58 -0800386 private <T> T searchForVertex(String propertyName, Object propertyValue, Class<T> vertexType) {
387 if (conn.getFramedGraph() != null) {
388 Iterator<T> it = conn.getFramedGraph().getVertices(propertyName, propertyValue, vertexType).iterator();
389 if (it.hasNext()) {
390 return it.next();
391 }
392 }
393 return null;
394 }
395
396 public void removeIpv4Address(IIpv4Address ipv4Address) {
yoshi89eacab2013-12-09 17:29:08 -0800397 //System.out.println("removeIpv4Address");
yoshitomob292c622013-11-23 14:35:58 -0800398 conn.getFramedGraph().removeVertex(ipv4Address.asVertex());
399 }
yoshi0451f282013-11-22 15:48:55 -0800400
yoshib3c83c12013-12-03 00:58:13 -0800401 /**
402 * Get the instance of GraphDBConnection assigned to this class.
403 */
yoshi7594aef2013-11-27 09:27:07 -0800404 @Override
405 public IDBConnection getDBConnection() {
406 return conn;
Yuta HIGUCHI9e580b62014-01-02 12:02:22 -0800407 }
408
yoshib3c83c12013-12-03 00:58:13 -0800409 @Override
410 public void commit() {
411 conn.commit();
412 }
413
414 @Override
415 public void rollback() {
416 conn.rollback();
417 }
418
419 @Override
420 public void close() {
421 conn.close();
422 }
Toshio Koide3f233542014-01-07 14:19:09 -0800423
424 @Override
Toshio Koide3fcebc12014-01-09 22:40:11 -0800425 public void setVertexProperties(Vertex vertex, Map<String, Object> map) {
Toshio Koide3f233542014-01-07 14:19:09 -0800426 log.debug("setProperties start: size {}", map.size());
Toshio Koide3fcebc12014-01-09 22:40:11 -0800427 RamCloudVertex v = (RamCloudVertex) vertex;
Toshio Koide3f233542014-01-07 14:19:09 -0800428 v.setProperties(map);
429 log.debug("setProperties end: size {}, id {}", map.size(), v.getId());
430 }
Toshio Koide3fcebc12014-01-09 22:40:11 -0800431
432 public String toString() {
433 StringBuilder sb = new StringBuilder();
434 for(ISwitchObject sw: getAllSwitches()) {
435 sb.append("sw: " + sw.getDPID() + "\n");
436 for(IPortObject port: sw.getPorts()) {
437 sb.append(" port: " + port.getPortId() + "\n");
438 }
439 }
440 return sb.toString();
441 }
yoshi0451f282013-11-22 15:48:55 -0800442}