@Override public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) { checkPermission(TOPOLOGY_READ); checkNotNull(src, ELEMENT_ID_NULL); checkNotNull(dst, ELEMENT_ID_NULL); // Get the source and destination edge locations EdgeLink srcEdge = getEdgeLink(src, true); EdgeLink dstEdge = getEdgeLink(dst, false); // If either edge is null, bail with no paths. if (srcEdge == null || dstEdge == null) { return ImmutableSet.of(); } DeviceId srcDevice = srcEdge != NOT_HOST ? srcEdge.dst().deviceId() : (DeviceId) src; DeviceId dstDevice = dstEdge != NOT_HOST ? dstEdge.src().deviceId() : (DeviceId) dst; // If the source and destination are on the same edge device, there // is just one path, so build it and return it. if (srcDevice.equals(dstDevice)) { return edgeToEdgePaths(srcEdge, dstEdge); } // Otherwise get all paths between the source and destination edge // devices. Topology topology = topologyService.currentTopology(); Set<Path> paths = weight == null ? topologyService.getPaths(topology, srcDevice, dstDevice) : topologyService.getPaths(topology, srcDevice, dstDevice, weight); return edgeToEdgePaths(srcEdge, dstEdge, paths); }
@Override public boolean matchesSafely(Collection<Link> links) { for (Link link : links) { if (source.equals(destination) && link instanceof EdgeLink) { EdgeLink edgeLink = (EdgeLink) link; if (edgeLink.hostLocation().elementId().toString().endsWith(source)) { return true; } } if (link.src().elementId().toString().endsWith(source) && link.dst().elementId().toString().endsWith(destination)) { return true; } } return false; }