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 | 86a0d41 | 2013-04-05 15:06:26 -0700 | [diff] [blame] | 97 | |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 98 | // check if the link exists |
Pankaj Berde | 77b5851 | 2013-04-05 12:06:37 -0700 | [diff] [blame] | 99 | List<IPortObject> currLinks = new ArrayList<IPortObject>(); |
| 100 | Iterable<IPortObject> currPorts = vportSrc.getLinkedPorts(); |
| 101 | |
| 102 | for (IPortObject V : currPorts) { |
Pankaj Berde | 6debb04 | 2013-01-16 18:04:32 -0800 | [diff] [blame] | 103 | currLinks.add(V); |
| 104 | } |
| 105 | |
| 106 | if (currLinks.contains(vportDst)) { |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 107 | // TODO: update linkinfo |
| 108 | if (op.equals(DM_OPERATION.INSERT) || op.equals(DM_OPERATION.CREATE)) { |
Umesh Krishnaswamy | 9306f95 | 2013-01-24 20:42:59 -0800 | [diff] [blame] | 109 | log.debug("addOrUpdateLink(): failed link exists {} {} src {} dst {}", |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 110 | new Object[]{op, lt, vportSrc, vportDst}); |
| 111 | } |
Pankaj Berde | 0fc4e43 | 2013-01-12 09:47:22 -0800 | [diff] [blame] | 112 | } else { |
Pankaj Berde | 86a0d41 | 2013-04-05 15:06:26 -0700 | [diff] [blame] | 113 | conn.getFramedGraph().addEdge(null, vportSrc.asVertex(), vportDst.asVertex(), "link"); |
| 114 | conn.endTx(Transaction.COMMIT); |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 115 | 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] | 116 | } |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 117 | } else { |
Umesh Krishnaswamy | 9306f95 | 2013-01-24 20:42:59 -0800 | [diff] [blame] | 118 | log.error("addOrUpdateLink(): failed invalid vertices {} {} src {} dst {}", new Object[]{op, lt, vportSrc, vportDst}); |
Pankaj Berde | 86a0d41 | 2013-04-05 15:06:26 -0700 | [diff] [blame] | 119 | conn.endTx(Transaction.ROLLBACK); |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 120 | } |
| 121 | } catch (TitanException e) { |
| 122 | /* |
| 123 | * retry till we succeed? |
| 124 | */ |
Umesh Krishnaswamy | c56a8cc | 2013-01-24 21:47:51 -0800 | [diff] [blame] | 125 | log.error("addOrUpdateLink(): titan exception {} {} {}", new Object[]{op, lt, e.toString()}); |
| 126 | e.printStackTrace(); |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 127 | } |
| 128 | } |
| 129 | |
| 130 | @Override |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 131 | public void deleteLinks(List<Link> links) { |
| 132 | |
| 133 | for (Link lt : links) { |
| 134 | deleteLink(lt); |
| 135 | } |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 136 | } |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 137 | |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 138 | |
| 139 | @Override |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 140 | public void deleteLink(Link lt) { |
Pankaj Berde | 5fb2763 | 2013-04-05 08:56:12 -0700 | [diff] [blame] | 141 | GraphDBConnection conn = GraphDBConnection.getInstance(this.conf); |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 142 | IPortObject vportSrc = null, vportDst = null; |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 143 | int count = 0; |
| 144 | |
| 145 | log.debug("deleteLink(): {}", lt); |
| 146 | |
| 147 | try { |
| 148 | // get source port vertex |
| 149 | String dpid = HexString.toHexString(lt.getSrc()); |
| 150 | short port = lt.getSrcPort(); |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 151 | vportSrc = conn.utils().searchPort(conn, dpid, port); |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 152 | |
| 153 | // get dst port vertex |
| 154 | dpid = HexString.toHexString(lt.getDst()); |
| 155 | port = lt.getDstPort(); |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 156 | vportDst = conn.utils().searchPort(conn, dpid, port); |
| 157 | // FIXME: This needs to remove all edges |
| 158 | // FIXME: Events will only be generated on singleton graph object (GraphDBConnection) |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 159 | |
| 160 | if (vportSrc != null && vportDst != null) { |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 161 | |
| 162 | /* for (Edge e : vportSrc.asVertex().getEdges(Direction.OUT)) { |
Umesh Krishnaswamy | 11060ed | 2013-01-23 19:24:36 -0800 | [diff] [blame] | 163 | log.debug("deleteLink(): {} in {} out {}", |
| 164 | new Object[]{e.getLabel(), e.getVertex(Direction.IN), e.getVertex(Direction.OUT)}); |
| 165 | if (e.getLabel().equals("link") && e.getVertex(Direction.IN).equals(vportDst)) { |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 166 | graph.removeEdge(e); |
| 167 | count++; |
| 168 | } |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 169 | }*/ |
| 170 | vportSrc.removeLink(vportDst); |
Pankaj Berde | 5fb2763 | 2013-04-05 08:56:12 -0700 | [diff] [blame] | 171 | conn.endTx(Transaction.COMMIT); |
Pankaj Berde | 2239f0d | 2013-04-04 09:42:43 -0700 | [diff] [blame] | 172 | log.debug("deleteLink(): deleted edges src {} dst {}", new Object[]{ |
| 173 | lt, vportSrc, vportDst}); |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 174 | |
| 175 | } else { |
Umesh Krishnaswamy | 9306f95 | 2013-01-24 20:42:59 -0800 | [diff] [blame] | 176 | 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] | 177 | conn.endTx(Transaction.ROLLBACK); |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | } catch (TitanException e) { |
| 181 | /* |
| 182 | * retry till we succeed? |
| 183 | */ |
Umesh Krishnaswamy | c56a8cc | 2013-01-24 21:47:51 -0800 | [diff] [blame] | 184 | log.error("deleteLink(): titan exception {} {}", new Object[]{lt, e.toString()}); |
| 185 | e.printStackTrace(); |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 186 | } |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 187 | } |
| 188 | |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 189 | // TODO: Fix me |
| 190 | @Override |
| 191 | public List<Link> getLinks(Long dpid, short port) { |
| 192 | Vertex vportSrc, vportDst; |
| 193 | List<Link> links = null; |
| 194 | Link lt; |
| 195 | |
| 196 | vportSrc = getPortVertex(HexString.toHexString(dpid), port); |
| 197 | if (vportSrc != null) { |
| 198 | for (Edge e : vportSrc.getEdges(Direction.OUT)) { |
| 199 | if (e.getLabel().equals("link")) { |
| 200 | break; |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | return null; |
| 205 | } |
| 206 | |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 207 | @Override |
| 208 | public void init(String conf) { |
Pankaj Berde | 1f10be0 | 2013-02-01 14:06:02 -0800 | [diff] [blame] | 209 | //TODO extract the DB location from properties |
Pankaj Berde | 67f88fb | 2013-01-15 17:16:01 -0800 | [diff] [blame] | 210 | |
Pankaj Berde | 5fb2763 | 2013-04-05 08:56:12 -0700 | [diff] [blame] | 211 | this.conf = conf; |
| 212 | graph = TitanFactory.open(this.conf); |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 213 | |
Pankaj Berde | 67f88fb | 2013-01-15 17:16:01 -0800 | [diff] [blame] | 214 | // 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] | 215 | Set<String> s = graph.getIndexedKeys(Vertex.class); |
| 216 | if (!s.contains("dpid")) { |
| 217 | graph.createKeyIndex("dpid", Vertex.class); |
| 218 | graph.stopTransaction(Conclusion.SUCCESS); |
| 219 | } |
| 220 | if (!s.contains("type")) { |
| 221 | graph.createKeyIndex("type", Vertex.class); |
| 222 | graph.stopTransaction(Conclusion.SUCCESS); |
| 223 | } |
| 224 | } |
Umesh Krishnaswamy | f962d64 | 2013-01-23 19:04:23 -0800 | [diff] [blame] | 225 | |
| 226 | @Override |
| 227 | public void deleteLinksOnPort(Long dpid, short port) { |
| 228 | // TODO Auto-generated method stub |
| 229 | |
| 230 | } |
| 231 | |
Pankaj Berde | ff42180 | 2013-01-29 20:28:52 -0800 | [diff] [blame] | 232 | @Override |
| 233 | public List<Link> getLinks(String dpid) { |
| 234 | // TODO Auto-generated method stub |
| 235 | return null; |
| 236 | } |
| 237 | |
| 238 | public List<Link> getActiveLinks() { |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 239 | |
| 240 | ITopoSwitchService swService = new TopoSwitchServiceImpl(); |
Pankaj Berde | ff42180 | 2013-01-29 20:28:52 -0800 | [diff] [blame] | 241 | |
Pankaj Berde | 1cde50b | 2013-02-19 20:16:06 -0800 | [diff] [blame] | 242 | Iterable<ISwitchObject> switches = swService.getActiveSwitches(); |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 243 | |
| 244 | List<Link> links = new ArrayList<Link>(); |
| 245 | for (ISwitchObject sw : switches) { |
| 246 | GremlinPipeline<Vertex, Link> pipe = new GremlinPipeline<Vertex, Link>(); |
| 247 | ExtractLink extractor = new ExtractLink(); |
| 248 | |
| 249 | pipe.start(sw.asVertex()); |
| 250 | pipe.enablePath(true); |
Pankaj Berde | 1f10be0 | 2013-02-01 14:06:02 -0800 | [diff] [blame] | 251 | pipe.out("on").out("link").in("on").path().step(extractor); |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 252 | |
Pankaj Berde | 1f10be0 | 2013-02-01 14:06:02 -0800 | [diff] [blame] | 253 | while (pipe.hasNext() ) { |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 254 | Link l = pipe.next(); |
| 255 | links.add(l); |
| 256 | } |
| 257 | |
| 258 | } |
| 259 | return links; |
Pankaj Berde | ff42180 | 2013-01-29 20:28:52 -0800 | [diff] [blame] | 260 | } |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 261 | |
| 262 | static class ExtractLink implements PipeFunction<PathPipe<Vertex>, Link> { |
| 263 | |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 264 | @Override |
| 265 | public Link compute(PathPipe<Vertex> pipe ) { |
Pankaj Berde | d18c762 | 2013-02-04 10:28:35 -0800 | [diff] [blame] | 266 | // TODO Auto-generated method stub |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 267 | long s_dpid = 0; |
| 268 | long d_dpid = 0; |
| 269 | short s_port = 0; |
| 270 | short d_port = 0; |
| 271 | List<Vertex> V = new ArrayList<Vertex>(); |
| 272 | V = pipe.next(); |
| 273 | Vertex src_sw = V.get(0); |
| 274 | Vertex dest_sw = V.get(3); |
| 275 | Vertex src_port = V.get(1); |
| 276 | Vertex dest_port = V.get(2); |
| 277 | s_dpid = HexString.toLong((String) src_sw.getProperty("dpid")); |
| 278 | d_dpid = HexString.toLong((String) dest_sw.getProperty("dpid")); |
| 279 | s_port = (Short) src_port.getProperty("number"); |
| 280 | d_port = (Short) dest_port.getProperty("number"); |
| 281 | |
| 282 | Link l = new Link(s_dpid,s_port,d_dpid,d_port); |
| 283 | |
| 284 | return l; |
| 285 | } |
| 286 | } |
Pankaj Berde | d18c762 | 2013-02-04 10:28:35 -0800 | [diff] [blame] | 287 | |
| 288 | public void finalize() { |
| 289 | close(); |
| 290 | } |
| 291 | |
| 292 | @Override |
| 293 | public void close() { |
| 294 | // TODO Auto-generated method stub |
| 295 | graph.shutdown(); |
| 296 | } |
Pankaj Berde | 5024ec1 | 2013-01-31 17:07:29 -0800 | [diff] [blame] | 297 | |
Pankaj Berde | ff42180 | 2013-01-29 20:28:52 -0800 | [diff] [blame] | 298 | |
Umesh Krishnaswamy | b676ca2 | 2013-01-11 12:39:25 -0800 | [diff] [blame] | 299 | } |