Nikhil Cheerla
Committed by Thomas Vachuska

Disjoint Path Utils Exposed

- to TopologyStores
- to TopologyServices
- to PathServices
- to REST API

Change-Id: Ib2b5840df0f8e94f327ec8f91827d3d850634562

Change-Id: I03e59210e9c79c4f92dcfa8c7983642572708429

Change-Id: Ia5c17d1ded374ef688990bd30e7f99184aaca95b

Change-Id: Ibebae50bc722701e8212263587727ad8abd79805
......@@ -15,9 +15,12 @@
*/
package org.onosproject.net.topology;
import org.onosproject.net.DisjointPath;
import org.onosproject.net.ElementId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import java.util.Map;
import java.util.Set;
/**
......@@ -48,4 +51,51 @@ public interface PathService {
*/
Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight);
/**
* Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
* between the specified source and destination devices.
*
* @param src source device
* @param dst destination device
* @return set of all shortest paths between the two devices
*/
Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst);
/**
* Returns the set of all disjoint shortest path pairs, computed using the supplied
* edge-weight entity, between the specified source and destination devices.
*
* @param src source device
* @param dst destination device
* @param weight edge-weight entity
* @return set of all shortest paths between the two devices
*/
Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
LinkWeight weight);
/**
* Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
* between the specified source and destination devices.
*
* @param src source device
* @param dst destination device
* @param riskProfile map of edges to risk profiles
* @return set of all shortest paths between the two devices
*/
Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst,
Map<Link, Object> riskProfile);
/**
* Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
* between the specified source and destination devices.
*
* @param src source device
* @param dst destination device
* @param weight edge-weight entity
* @param riskProfile map of edges to risk profiles
* @return set of all shortest paths between the two devices
*/
Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst,
LinkWeight weight, Map<Link, Object> riskProfile);
}
......
......@@ -18,9 +18,11 @@ package org.onosproject.net.topology;
import org.onosproject.event.ListenerService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.DisjointPath;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import java.util.Map;
import java.util.Set;
/**
......@@ -112,6 +114,56 @@ public interface TopologyService
LinkWeight weight);
/**
* Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
* between the specified source and destination devices.
*
* @param topology topology descriptor
* @param src source device
* @param dst destination device
* @return set of all shortest paths between the two devices
*/
Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst);
/**
* Returns the set of all disjoint shortest path pairs, computed using the supplied
* edge-weight entity, between the specified source and destination devices.
*
* @param topology topology descriptor
* @param src source device
* @param dst destination device
* @param weight edge-weight entity
* @return set of all shortest paths between the two devices
*/
Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
LinkWeight weight);
/**
* Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
* between the specified source and destination devices.
*
* @param topology topology descriptor
* @param src source device
* @param dst destination device
* @param riskProfile map of edges to risk profiles
* @return set of all shortest paths between the two devices
*/
Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
Map<Link, Object> riskProfile);
/**
* Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
* between the specified source and destination devices.
*
* @param topology topology descriptor
* @param src source device
* @param dst destination device
* @param weight edge-weight entity
* @param riskProfile map of edges to risk profiles
* @return set of all shortest paths between the two devices
*/
Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
LinkWeight weight, Map<Link, Object> riskProfile);
/**
* Indicates whether the specified connection point is part of the network
* infrastructure or part of network edge.
*
......
......@@ -20,11 +20,13 @@ import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.DisjointPath;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.store.Store;
import java.util.List;
import java.util.Set;
import java.util.Map;
/**
* Manages inventory of topology snapshots; not intended for direct use.
......@@ -112,6 +114,59 @@ public interface TopologyStore extends Store<TopologyEvent, TopologyStoreDelegat
LinkWeight weight);
/**
* Computes and returns the set of disjoint shortest path pairs
* between src and dst.
*
* @param topology topology descriptor
* @param src source device
* @param dst destination device
* @param weight link weight function
* @return set of shortest paths
*/
Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
LinkWeight weight);
/**
* Computes and returns the set of disjoint shortest path pairs
* between src and dst.
*
* @param topology topology descriptor
* @param src source device
* @param dst destination device
* @return set of shortest paths
*/
Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst);
/**
* Computes and returns the set of SRLG disjoint shortest path pairs between source
* and dst, given a mapping of edges to SRLG risk groups.
*
* @param topology topology descriptor
* @param src source device
* @param dst destination device
* @param weight link weight function
* @param riskProfile map of edges to objects. Edges that map to the same object will
* be treated as if they were in the same risk group.
* @return set of shortest paths
*/
Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
LinkWeight weight, Map<Link, Object> riskProfile);
/**
* Returns the set of pre-computed SRLG shortest paths between src and dest.
*
* @param topology topology descriptor
* @param src source device
* @param dst destination device
* @param riskProfile map of edges to objects. Edges that map to the same object will
* be treated as if they were in the same risk group.
* @return set of shortest paths
*/
Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
Map<Link, Object> riskProfile);
/**
* Indicates whether the given connect point is part of the network fabric.
*
* @param topology topology descriptor
......
......@@ -22,6 +22,7 @@ import org.onlab.util.Bandwidth;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.core.GroupId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.DisjointPath;
import org.onosproject.net.ElementId;
import org.onosproject.net.Link;
import org.onosproject.net.NetTestTools;
......@@ -64,6 +65,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
......@@ -185,6 +187,28 @@ public class IntentTestsMocks {
}
return paths;
}
@Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
return null;
}
@Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
return null;
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst,
Map<Link, Object> riskProfile) {
return null;
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst, LinkWeight weight,
Map<Link, Object> riskProfile) {
return null;
}
}
public static class MockLinkResourceAllocations implements LinkResourceAllocations {
......
......@@ -17,9 +17,11 @@ package org.onosproject.net.topology;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.DisjointPath;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import java.util.Map;
import java.util.Set;
/**
......@@ -88,5 +90,26 @@ public class TopologyServiceAdapter implements TopologyService {
@Override
public void removeListener(TopologyListener listener) {
}
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst) {
return null;
}
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
return null;
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
Map<Link, Object> riskProfile) {
return null;
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight,
Map<Link, Object> riskProfile) {
return null;
}
}
......
......@@ -322,8 +322,9 @@ public class DefaultTopology extends AbstractModel implements Topology {
}
return builder.build();
}
/**
/**
* /**
* Returns the set of pre-computed shortest disjoint path pairs between source and
* destination devices.
*
......@@ -331,7 +332,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
* @param dst destination device
* @return set of shortest disjoint path pairs
*/
Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst) {
public Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst) {
return getDisjointPaths(src, dst, null);
}
......@@ -344,7 +345,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
* @param weight link weight function
* @return set of disjoint shortest path pairs
*/
Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst, LinkWeight weight) {
public Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst, LinkWeight weight) {
final DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
final DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
Set<TopologyVertex> vertices = graph.getVertexes();
......@@ -371,7 +372,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
* @param riskProfile map representing risk groups for each edge
* @return set of shortest disjoint paths
*/
Set<DisjointPath> getSRLGDisjointPathsD(DeviceId src, DeviceId dst, Map<TopologyEdge, Object> riskProfile) {
public Set<DisjointPath> getSRLGDisjointPathsD(DeviceId src, DeviceId dst, Map<TopologyEdge, Object> riskProfile) {
return getSRLGDisjointPathsD(src, dst, null, riskProfile);
}
......@@ -385,7 +386,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
* @param riskProfile map representing risk groups for each edge
* @return set of shortest disjoint paths
*/
Set<DisjointPath> getSRLGDisjointPathsD(DeviceId src, DeviceId dst, LinkWeight weight, Map<TopologyEdge,
public Set<DisjointPath> getSRLGDisjointPathsD(DeviceId src, DeviceId dst, LinkWeight weight, Map<TopologyEdge,
Object> riskProfile) {
final DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
final DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
......@@ -415,7 +416,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
* @param riskProfile map representing risk groups for each link
* @return set of shortest disjoint paths
*/
Set<DisjointPath> getSRLGDisjointPaths(DeviceId src, DeviceId dst, LinkWeight weight,
public Set<DisjointPath> getSRLGDisjointPaths(DeviceId src, DeviceId dst, LinkWeight weight,
Map<Link, Object> riskProfile) {
Map<TopologyEdge, Object> riskProfile2 = new HashMap<>();
for (Link l : riskProfile.keySet()) {
......@@ -455,7 +456,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
* @param riskProfile map representing risk groups for each link
* @return set of shortest disjoint paths
*/
Set<DisjointPath> getSRLGDisjointPaths(DeviceId src, DeviceId dst, Map<Link, Object> riskProfile) {
public Set<DisjointPath> getSRLGDisjointPaths(DeviceId src, DeviceId dst, Map<Link, Object> riskProfile) {
return getSRLGDisjointPaths(src, dst, null, riskProfile);
}
......
......@@ -23,6 +23,7 @@ import org.onosproject.common.DefaultTopology;
import org.onosproject.event.Event;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.DisjointPath;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.provider.ProviderId;
......@@ -39,6 +40,7 @@ import org.onosproject.store.AbstractStore;
import org.slf4j.Logger;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.slf4j.LoggerFactory.getLogger;
......@@ -114,6 +116,29 @@ public class SimpleTopologyStore
}
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst) {
return defaultTopology(topology).getDisjointPaths(src, dst);
}
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
LinkWeight weight) {
return defaultTopology(topology).getDisjointPaths(src, dst, weight);
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
Map<Link, Object> riskProfile) {
return defaultTopology(topology).getSRLGDisjointPaths(src, dst, riskProfile);
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
LinkWeight weight, Map<Link, Object> riskProfile) {
return defaultTopology(topology).getSRLGDisjointPaths(src, dst, weight, riskProfile);
}
@Override
public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) {
return defaultTopology(topology).isInfrastructure(connectPoint);
}
......
......@@ -27,6 +27,8 @@ import org.apache.felix.scr.annotations.Service;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultEdgeLink;
import org.onosproject.net.DefaultPath;
import org.onosproject.net.DisjointPath;
import org.onosproject.net.DefaultDisjointPath;
import org.onosproject.net.DeviceId;
import org.onosproject.net.EdgeLink;
import org.onosproject.net.ElementId;
......@@ -46,6 +48,8 @@ import org.slf4j.Logger;
import java.util.List;
import java.util.Set;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
......@@ -128,6 +132,84 @@ public class PathManager implements PathService {
return edgeToEdgePaths(srcEdge, dstEdge, paths);
}
@Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
return getDisjointPaths(src, dst, null);
}
@Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
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 edgeToEdgePathsDisjoint(srcEdge, dstEdge);
}
// Otherwise get all paths between the source and destination edge
// devices.
Topology topology = topologyService.currentTopology();
Set<DisjointPath> paths = weight == null ?
topologyService.getDisjointPaths(topology, srcDevice, dstDevice) :
topologyService.getDisjointPaths(topology, srcDevice, dstDevice, weight);
return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths);
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst,
Map<Link, Object> riskProfile) {
return getSRLGDisjointPaths(src, dst, null, riskProfile);
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst, LinkWeight weight,
Map<Link, Object> riskProfile) {
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 edgeToEdgePathsDisjoint(srcEdge, dstEdge);
}
// Otherwise get all paths between the source and destination edge
// devices.
Topology topology = topologyService.currentTopology();
Set<DisjointPath> paths = weight == null ?
topologyService.getSRLGDisjointPaths(topology, srcDevice, dstDevice, riskProfile) :
topologyService.getSRLGDisjointPaths(topology, srcDevice, dstDevice, weight, riskProfile);
return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths);
}
// Finds the host edge link if the element ID is a host id of an existing
// host. Otherwise, if the host does not exist, it returns null and if
// the element ID is not a host ID, returns NOT_HOST edge link.
......@@ -162,6 +244,19 @@ public class PathManager implements PathService {
return endToEndPaths;
}
private Set<DisjointPath> edgeToEdgePathsDisjoint(EdgeLink srcLink, EdgeLink dstLink) {
Set<DisjointPath> endToEndPaths = Sets.newHashSetWithExpectedSize(1);
endToEndPaths.add(edgeToEdgePathD(srcLink, dstLink, null));
return endToEndPaths;
}
private Set<DisjointPath> edgeToEdgePathsDisjoint(EdgeLink srcLink, EdgeLink dstLink, Set<DisjointPath> paths) {
Set<DisjointPath> endToEndPaths = Sets.newHashSetWithExpectedSize(paths.size());
for (DisjointPath path : paths) {
endToEndPaths.add(edgeToEdgePathD(srcLink, dstLink, path));
}
return endToEndPaths;
}
// Produces a direct edge-to-edge path.
private Path edgeToEdgePath(EdgeLink srcLink, EdgeLink dstLink, Path path) {
List<Link> links = Lists.newArrayListWithCapacity(2);
......@@ -179,6 +274,13 @@ public class PathManager implements PathService {
return new DefaultPath(PID, links, 2);
}
// Produces a direct edge-to-edge path.
private DisjointPath edgeToEdgePathD(EdgeLink srcLink, EdgeLink dstLink, DisjointPath path) {
return new DefaultDisjointPath(PID, (DefaultPath) edgeToEdgePath(srcLink, dstLink, path.primary()),
(DefaultPath) edgeToEdgePath(srcLink, dstLink, path.backup()));
}
// Special value for edge link to represent that this is really not an
// edge link since the src or dst are really an infrastructure device.
private static class NotHost extends DefaultEdgeLink implements EdgeLink {
......
......@@ -21,6 +21,7 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.net.DisjointPath;
import org.onosproject.net.provider.AbstractListenerProviderRegistry;
import org.onosproject.event.Event;
import org.onosproject.net.ConnectPoint;
......@@ -46,6 +47,7 @@ import org.slf4j.Logger;
import java.util.List;
import java.util.Set;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.security.AppGuard.checkPermission;
......@@ -162,6 +164,42 @@ public class TopologyManager
}
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst) {
checkNotNull(topology, TOPOLOGY_NULL);
checkNotNull(src, DEVICE_ID_NULL);
checkNotNull(dst, DEVICE_ID_NULL);
return store.getDisjointPaths(topology, src, dst);
}
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
checkNotNull(topology, TOPOLOGY_NULL);
checkNotNull(src, DEVICE_ID_NULL);
checkNotNull(dst, DEVICE_ID_NULL);
checkNotNull(weight, "Link weight cannot be null");
return store.getDisjointPaths(topology, src, dst, weight);
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
Map<Link, Object> riskProfile) {
checkNotNull(topology, TOPOLOGY_NULL);
checkNotNull(src, DEVICE_ID_NULL);
checkNotNull(dst, DEVICE_ID_NULL);
return store.getSRLGDisjointPaths(topology, src, dst, riskProfile);
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight,
Map<Link, Object> riskProfile) {
checkNotNull(topology, TOPOLOGY_NULL);
checkNotNull(src, DEVICE_ID_NULL);
checkNotNull(dst, DEVICE_ID_NULL);
checkNotNull(weight, "Link weight cannot be null");
return store.getSRLGDisjointPaths(topology, src, dst, weight, riskProfile);
}
@Override
public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) {
checkPermission(TOPOLOGY_READ);
checkNotNull(topology, TOPOLOGY_NULL);
......
......@@ -21,7 +21,9 @@ import org.onosproject.TestApplicationId;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.DisjointPath;
import org.onosproject.net.ElementId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.device.DeviceServiceAdapter;
import org.onosproject.net.flow.TrafficSelector;
......@@ -36,6 +38,7 @@ import org.onosproject.net.topology.PathService;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.hamcrest.CoreMatchers.instanceOf;
......@@ -91,6 +94,28 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes
public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
return null;
}
@Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
return null;
}
@Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
return null;
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst,
Map<Link, Object> riskProfile) {
return null;
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst, LinkWeight weight,
Map<Link, Object> riskProfile) {
return null;
}
}
/**
......
......@@ -19,9 +19,11 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onosproject.net.DeviceId;
import org.onosproject.net.DisjointPath;
import org.onosproject.net.ElementId;
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.host.HostService;
import org.onosproject.net.host.HostServiceAdapter;
......@@ -149,6 +151,28 @@ public class PathManagerTest {
public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
return paths;
}
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst) {
return null;
}
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
return null;
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
Map<Link, Object> riskProfile) {
return null;
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight,
Map<Link, Object> riskProfile) {
return null;
}
}
// Fake entity to give out hosts.
......
......@@ -21,6 +21,7 @@ import static org.onosproject.net.topology.TopologyEvent.Type.TOPOLOGY_CHANGED;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Collections;
import java.util.Map;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
......@@ -40,6 +41,7 @@ import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.DisjointPath;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.topology.ClusterId;
import org.onosproject.net.topology.DefaultGraphDescription;
......@@ -74,7 +76,6 @@ public class DistributedTopologyStore
implements TopologyStore {
private final Logger log = getLogger(getClass());
private volatile DefaultTopology current =
new DefaultTopology(ProviderId.NONE,
new DefaultGraphDescription(0L, System.currentTimeMillis(),
......@@ -167,6 +168,29 @@ public class DistributedTopologyStore
}
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst) {
return defaultTopology(topology).getDisjointPaths(src, dst);
}
@Override
public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
LinkWeight weight) {
return defaultTopology(topology).getDisjointPaths(src, dst, weight);
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
Map<Link, Object> riskProfile) {
return defaultTopology(topology).getSRLGDisjointPaths(src, dst, riskProfile);
}
@Override
public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
LinkWeight weight, Map<Link, Object> riskProfile) {
return defaultTopology(topology).getSRLGDisjointPaths(src, dst, weight, riskProfile);
}
@Override
public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) {
return defaultTopology(topology).isInfrastructure(connectPoint);
}
......
......@@ -82,4 +82,30 @@ public class PathsWebResource extends AbstractWebResource {
return ok(root).build();
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{src}/{dst}/disjoint")
public Response getDisjointPath(@PathParam("src") String src,
@PathParam("dst") String dst) {
PathService pathService = get(PathService.class);
ElementId srcElement = isHostId(src);
ElementId dstElement = isHostId(dst);
if (srcElement == null) {
// Doesn't look like a host, assume it is a device
srcElement = DeviceId.deviceId(src);
}
if (dstElement == null) {
// Doesn't look like a host, assume it is a device
dstElement = DeviceId.deviceId(dst);
}
Set<org.onosproject.net.DisjointPath> paths =
pathService.getDisjointPaths(srcElement, dstElement);
ObjectNode root =
encodeArray(org.onosproject.net.DisjointPath.class, "paths", paths);
return ok(root).build();
}
}
......