Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.linkdiscovery.internal; |
| 2 | |
Pankaj Berde | 6debb04 | 2013-01-16 18:04:32 -0800 | [diff] [blame] | 3 | import java.util.ArrayList; |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 4 | import java.util.Collection; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 5 | import java.util.List; |
| 6 | import java.util.Set; |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 7 | |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 8 | import net.floodlightcontroller.core.INetMapTopologyObjects.IPortObject; |
Pankaj Berde | 1e2f731 | 2013-02-15 08:25:31 -0800 | [diff] [blame] | 9 | import net.floodlightcontroller.core.INetMapTopologyObjects.ISwitchObject; |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 10 | import net.floodlightcontroller.core.INetMapTopologyService.ITopoSwitchService; |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 11 | import net.floodlightcontroller.core.internal.TopoSwitchServiceImpl; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 12 | import net.floodlightcontroller.linkdiscovery.ILinkStorage; |
| 13 | import net.floodlightcontroller.linkdiscovery.LinkInfo; |
| 14 | import net.floodlightcontroller.routing.Link; |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 15 | import net.onrc.onos.util.GraphDBConnection; |
| 16 | import net.onrc.onos.util.GraphDBConnection.GenerateEvent; |
| 17 | import net.onrc.onos.util.GraphDBConnection.Transaction; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 18 | |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 19 | import org.openflow.util.HexString; |
| 20 | import org.slf4j.Logger; |
| 21 | import org.slf4j.LoggerFactory; |
| 22 | |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 23 | import com.thinkaurelius.titan.core.TitanException; |
| 24 | import com.thinkaurelius.titan.core.TitanFactory; |
| 25 | import com.thinkaurelius.titan.core.TitanGraph; |
| 26 | import com.tinkerpop.blueprints.Direction; |
| 27 | import com.tinkerpop.blueprints.TransactionalGraph.Conclusion; |
| 28 | import com.tinkerpop.blueprints.Vertex; |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 29 | import com.tinkerpop.blueprints.Edge; |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 30 | import com.tinkerpop.blueprints.util.wrappers.event.EventGraph; |
| 31 | import com.tinkerpop.blueprints.util.wrappers.event.EventTransactionalGraph; |
Jonathan Hart | b7e3d2c | 2013-01-15 18:45:19 -0800 | [diff] [blame] | 32 | import com.tinkerpop.gremlin.java.GremlinPipeline; |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 33 | import com.tinkerpop.pipes.PipeFunction; |
| 34 | import com.tinkerpop.pipes.transform.PathPipe; |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 35 | |
| 36 | public class LinkStorageImpl implements ILinkStorage { |
| 37 | public TitanGraph graph; |
| 38 | protected static Logger log = LoggerFactory.getLogger(LinkStorageImpl.class); |
Pankaj Berde | 5fb2763 | 2013-04-05 08:56:12 -0700 | [diff] [blame^] | 39 | protected String conf; |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 40 | |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 41 | @Override |
| 42 | public void update(Link link, DM_OPERATION op) { |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 43 | update(link, (LinkInfo)null, op); |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public void update(List<Link> links, DM_OPERATION op) { |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 48 | for (Link lt: links) { |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 49 | update(lt, (LinkInfo)null, op); |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 50 | } |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public void update(Link link, LinkInfo linkinfo, DM_OPERATION op) { |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 55 | switch (op) { |
| 56 | case UPDATE: |
| 57 | case CREATE: |
| 58 | case INSERT: |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 59 | addOrUpdateLink(link, linkinfo, op); |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 60 | break; |
| 61 | case DELETE: |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 62 | deleteLink(link); |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 63 | break; |
| 64 | } |
| 65 | } |
| 66 | |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 67 | private Vertex getPortVertex(String dpid, short port) { |
| 68 | Vertex vsw, vport = null; |
| 69 | if ((vsw = graph.getVertices("dpid", dpid).iterator().next()) != null) { |
| 70 | GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>(); |
| 71 | pipe.start(vsw).out("on").has("number", port); |
| 72 | if (pipe.hasNext()) { |
| 73 | vport = pipe.next(); |
| 74 | } |
| 75 | } |
| 76 | return vport; |
| 77 | } |
| 78 | |
| 79 | public void addOrUpdateLink(Link lt, LinkInfo linkinfo, DM_OPERATION op) { |
Pankaj Berde | 5fb2763 | 2013-04-05 08:56:12 -0700 | [diff] [blame^] | 80 | GraphDBConnection conn = GraphDBConnection.getInstance(this.conf); |
| 81 | IPortObject vportSrc = null, vportDst = null; |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 82 | |
Umesh Krishnaswamy | 0ef75ee | 2013-03-25 17:50:27 -0700 | [diff] [blame] | 83 | log.trace("addOrUpdateLink(): op {} {} {}", new Object[]{op, lt, linkinfo}); |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 84 | |
| 85 | try { |
| 86 | // get source port vertex |
| 87 | String dpid = HexString.toHexString(lt.getSrc()); |
| 88 | short port = lt.getSrcPort(); |
Pankaj Berde | 5fb2763 | 2013-04-05 08:56:12 -0700 | [diff] [blame^] | 89 | vportSrc = conn.utils().searchPort(conn, dpid, port); |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 90 | |
| 91 | // get dest port vertex |
| 92 | dpid = HexString.toHexString(lt.getDst()); |
| 93 | port = lt.getDstPort(); |
Pankaj Berde | 5fb2763 | 2013-04-05 08:56:12 -0700 | [diff] [blame^] | 94 | vportDst = conn.utils().searchPort(conn, dpid, port); |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 95 | |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 96 | if (vportSrc != null && vportDst != null) { |
Pankaj Berde | 5fb2763 | 2013-04-05 08:56:12 -0700 | [diff] [blame^] | 97 | |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 98 | |
| 99 | // check if the link exists |
Pankaj Berde | 6debb04 | 2013-01-16 18:04:32 -0800 | [diff] [blame] | 100 | List<Vertex> currLinks = new ArrayList<Vertex>(); |
Pankaj Berde | 5fb2763 | 2013-04-05 08:56:12 -0700 | [diff] [blame^] | 101 | for (Vertex V : vportSrc.asVertex().query().direction(Direction.OUT).labels("link").vertices()) { |
Pankaj Berde | 6debb04 | 2013-01-16 18:04:32 -0800 | [diff] [blame] | 102 | currLinks.add(V); |
| 103 | } |
| 104 | |
| 105 | if (currLinks.contains(vportDst)) { |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 106 | // TODO: update linkinfo |
| 107 | if (op.equals(DM_OPERATION.INSERT) || op.equals(DM_OPERATION.CREATE)) { |
Umesh Krishnaswamy | 9306f95 | 2013-01-24 20:42:59 -0800 | [diff] [blame] | 108 | log.debug("addOrUpdateLink(): failed link exists {} {} src {} dst {}", |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 109 | new Object[]{op, lt, vportSrc, vportDst}); |
| 110 | } |
Pankaj Berde | 0fc4e43 | 2013-01-12 09:47:22 -0800 | [diff] [blame] | 111 | } else { |
Pankaj Berde | 5fb2763 | 2013-04-05 08:56:12 -0700 | [diff] [blame^] | 112 | graph.addEdge(null, vportSrc.asVertex(), vportDst.asVertex(), "link"); |
Pankaj Berde | 0fc4e43 | 2013-01-12 09:47:22 -0800 | [diff] [blame] | 113 | graph.stopTransaction(Conclusion.SUCCESS); |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 114 | log.debug("addOrUpdateLink(): link added {} {} src {} dst {}", new Object[]{op, lt, vportSrc, vportDst}); |
Pankaj Berde | 0fc4e43 | 2013-01-12 09:47:22 -0800 | [diff] [blame] | 115 | } |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 116 | } else { |
Umesh Krishnaswamy | 9306f95 | 2013-01-24 20:42:59 -0800 | [diff] [blame] | 117 | log.error("addOrUpdateLink(): failed invalid vertices {} {} src {} dst {}", new Object[]{op, lt, vportSrc, vportDst}); |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 118 | graph.stopTransaction(Conclusion.FAILURE); |
| 119 | } |
| 120 | } catch (TitanException e) { |
| 121 | /* |
| 122 | * retry till we succeed? |
| 123 | */ |
Umesh Krishnaswamy | c56a8cc | 2013-01-24 21:47:51 -0800 | [diff] [blame] | 124 | log.error("addOrUpdateLink(): titan exception {} {} {}", new Object[]{op, lt, e.toString()}); |
| 125 | e.printStackTrace(); |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 126 | } |
| 127 | } |
| 128 | |
| 129 | @Override |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 130 | public void deleteLinks(List<Link> links) { |
| 131 | |
| 132 | for (Link lt : links) { |
| 133 | deleteLink(lt); |
| 134 | } |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 135 | } |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 136 | |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 137 | |
| 138 | @Override |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 139 | public void deleteLink(Link lt) { |
Pankaj Berde | 5fb2763 | 2013-04-05 08:56:12 -0700 | [diff] [blame^] | 140 | GraphDBConnection conn = GraphDBConnection.getInstance(this.conf); |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 141 | IPortObject vportSrc = null, vportDst = null; |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 142 | int count = 0; |
| 143 | |
| 144 | log.debug("deleteLink(): {}", lt); |
| 145 | |
| 146 | try { |
| 147 | // get source port vertex |
| 148 | String dpid = HexString.toHexString(lt.getSrc()); |
| 149 | short port = lt.getSrcPort(); |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 150 | vportSrc = conn.utils().searchPort(conn, dpid, port); |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 151 | |
| 152 | // get dst port vertex |
| 153 | dpid = HexString.toHexString(lt.getDst()); |
| 154 | port = lt.getDstPort(); |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 155 | vportDst = conn.utils().searchPort(conn, dpid, port); |
| 156 | // FIXME: This needs to remove all edges |
| 157 | // FIXME: Events will only be generated on singleton graph object (GraphDBConnection) |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 158 | |
| 159 | if (vportSrc != null && vportDst != null) { |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 160 | |
| 161 | /* for (Edge e : vportSrc.asVertex().getEdges(Direction.OUT)) { |
Umesh Krishnaswamy | 11060ed | 2013-01-23 19:24:36 -0800 | [diff] [blame] | 162 | log.debug("deleteLink(): {} in {} out {}", |
| 163 | new Object[]{e.getLabel(), e.getVertex(Direction.IN), e.getVertex(Direction.OUT)}); |
| 164 | if (e.getLabel().equals("link") && e.getVertex(Direction.IN).equals(vportDst)) { |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 165 | graph.removeEdge(e); |
| 166 | count++; |
| 167 | } |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 168 | }*/ |
| 169 | vportSrc.removeLink(vportDst); |
Pankaj Berde | 5fb2763 | 2013-04-05 08:56:12 -0700 | [diff] [blame^] | 170 | conn.endTx(Transaction.COMMIT); |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 171 | log.debug("deleteLink(): deleted edges src {} dst {}", new Object[]{ |
| 172 | lt, vportSrc, vportDst}); |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 173 | |
| 174 | } else { |
Umesh Krishnaswamy | 9306f95 | 2013-01-24 20:42:59 -0800 | [diff] [blame] | 175 | log.error("deleteLink(): failed invalid vertices {} src {} dst {}", new Object[]{lt, vportSrc, vportDst}); |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 176 | conn.endTx(Transaction.ROLLBACK); |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | } catch (TitanException e) { |
| 180 | /* |
| 181 | * retry till we succeed? |
| 182 | */ |
Umesh Krishnaswamy | c56a8cc | 2013-01-24 21:47:51 -0800 | [diff] [blame] | 183 | log.error("deleteLink(): titan exception {} {}", new Object[]{lt, e.toString()}); |
| 184 | e.printStackTrace(); |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 185 | } |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 186 | } |
| 187 | |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 188 | // TODO: Fix me |
| 189 | @Override |
| 190 | public List<Link> getLinks(Long dpid, short port) { |
| 191 | Vertex vportSrc, vportDst; |
| 192 | List<Link> links = null; |
| 193 | Link lt; |
| 194 | |
| 195 | vportSrc = getPortVertex(HexString.toHexString(dpid), port); |
| 196 | if (vportSrc != null) { |
| 197 | for (Edge e : vportSrc.getEdges(Direction.OUT)) { |
| 198 | if (e.getLabel().equals("link")) { |
| 199 | break; |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | return null; |
| 204 | } |
| 205 | |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 206 | @Override |
| 207 | public void init(String conf) { |
Pankaj Berde | 1f10be0 | 2013-02-01 14:06:02 -0800 | [diff] [blame] | 208 | //TODO extract the DB location from properties |
Pankaj Berde | 67f88fb | 2013-01-15 17:16:01 -0800 | [diff] [blame] | 209 | |
Pankaj Berde | 5fb2763 | 2013-04-05 08:56:12 -0700 | [diff] [blame^] | 210 | this.conf = conf; |
| 211 | graph = TitanFactory.open(this.conf); |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 212 | |
Pankaj Berde | 67f88fb | 2013-01-15 17:16:01 -0800 | [diff] [blame] | 213 | // FIXME: These keys are not needed for Links but we better create it before using it as per titan |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 214 | Set<String> s = graph.getIndexedKeys(Vertex.class); |
| 215 | if (!s.contains("dpid")) { |
| 216 | graph.createKeyIndex("dpid", Vertex.class); |
| 217 | graph.stopTransaction(Conclusion.SUCCESS); |
| 218 | } |
| 219 | if (!s.contains("type")) { |
| 220 | graph.createKeyIndex("type", Vertex.class); |
| 221 | graph.stopTransaction(Conclusion.SUCCESS); |
| 222 | } |
| 223 | } |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 224 | |
| 225 | @Override |
| 226 | public void deleteLinksOnPort(Long dpid, short port) { |
| 227 | // TODO Auto-generated method stub |
| 228 | |
| 229 | } |
| 230 | |
Pankaj Berde | ff42180 | 2013-01-29 20:28:52 -0800 | [diff] [blame] | 231 | @Override |
| 232 | public List<Link> getLinks(String dpid) { |
| 233 | // TODO Auto-generated method stub |
| 234 | return null; |
| 235 | } |
| 236 | |
| 237 | public List<Link> getActiveLinks() { |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 238 | |
| 239 | ITopoSwitchService swService = new TopoSwitchServiceImpl(); |
Pankaj Berde | ff42180 | 2013-01-29 20:28:52 -0800 | [diff] [blame] | 240 | |
Pankaj Berde | 1cde50b | 2013-02-19 20:16:06 -0800 | [diff] [blame] | 241 | Iterable<ISwitchObject> switches = swService.getActiveSwitches(); |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 242 | |
| 243 | List<Link> links = new ArrayList<Link>(); |
| 244 | for (ISwitchObject sw : switches) { |
| 245 | GremlinPipeline<Vertex, Link> pipe = new GremlinPipeline<Vertex, Link>(); |
| 246 | ExtractLink extractor = new ExtractLink(); |
| 247 | |
| 248 | pipe.start(sw.asVertex()); |
| 249 | pipe.enablePath(true); |
Pankaj Berde | 1f10be0 | 2013-02-01 14:06:02 -0800 | [diff] [blame] | 250 | pipe.out("on").out("link").in("on").path().step(extractor); |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 251 | |
Pankaj Berde | 1f10be0 | 2013-02-01 14:06:02 -0800 | [diff] [blame] | 252 | while (pipe.hasNext() ) { |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 253 | Link l = pipe.next(); |
| 254 | links.add(l); |
| 255 | } |
| 256 | |
| 257 | } |
| 258 | return links; |
Pankaj Berde | ff42180 | 2013-01-29 20:28:52 -0800 | [diff] [blame] | 259 | } |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 260 | |
| 261 | static class ExtractLink implements PipeFunction<PathPipe<Vertex>, Link> { |
| 262 | |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 263 | @Override |
| 264 | public Link compute(PathPipe<Vertex> pipe ) { |
Pankaj Berde | d18c762 | 2013-02-04 10:28:35 -0800 | [diff] [blame] | 265 | // TODO Auto-generated method stub |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 266 | long s_dpid = 0; |
| 267 | long d_dpid = 0; |
| 268 | short s_port = 0; |
| 269 | short d_port = 0; |
| 270 | List<Vertex> V = new ArrayList<Vertex>(); |
| 271 | V = pipe.next(); |
| 272 | Vertex src_sw = V.get(0); |
| 273 | Vertex dest_sw = V.get(3); |
| 274 | Vertex src_port = V.get(1); |
| 275 | Vertex dest_port = V.get(2); |
| 276 | s_dpid = HexString.toLong((String) src_sw.getProperty("dpid")); |
| 277 | d_dpid = HexString.toLong((String) dest_sw.getProperty("dpid")); |
| 278 | s_port = (Short) src_port.getProperty("number"); |
| 279 | d_port = (Short) dest_port.getProperty("number"); |
| 280 | |
| 281 | Link l = new Link(s_dpid,s_port,d_dpid,d_port); |
| 282 | |
| 283 | return l; |
| 284 | } |
| 285 | } |
Pankaj Berde | d18c762 | 2013-02-04 10:28:35 -0800 | [diff] [blame] | 286 | |
| 287 | public void finalize() { |
| 288 | close(); |
| 289 | } |
| 290 | |
| 291 | @Override |
| 292 | public void close() { |
| 293 | // TODO Auto-generated method stub |
| 294 | graph.shutdown(); |
| 295 | } |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 296 | |
Pankaj Berde | ff42180 | 2013-01-29 20:28:52 -0800 | [diff] [blame] | 297 | |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 298 | } |