Thomas Vachuska
Committed by Gerrit Code Review

Cleaned up the SRLG and disjoint path code and naming.

Change-Id: I02b6fe5ee1e3f5eadc4e88800386a23349ee5e58
...@@ -44,8 +44,8 @@ public interface PathService { ...@@ -44,8 +44,8 @@ public interface PathService {
44 * edge-weight entity, between the specified source and destination 44 * edge-weight entity, between the specified source and destination
45 * network elements. 45 * network elements.
46 * 46 *
47 - * @param src source element 47 + * @param src source element
48 - * @param dst destination element 48 + * @param dst destination element
49 * @param weight edge-weight entity 49 * @param weight edge-weight entity
50 * @return set of all shortest paths between the two element 50 * @return set of all shortest paths between the two element
51 */ 51 */
...@@ -55,8 +55,8 @@ public interface PathService { ...@@ -55,8 +55,8 @@ public interface PathService {
55 * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count, 55 * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
56 * between the specified source and destination devices. 56 * between the specified source and destination devices.
57 * 57 *
58 - * @param src source device 58 + * @param src source device
59 - * @param dst destination device 59 + * @param dst destination device
60 * @return set of all shortest paths between the two devices 60 * @return set of all shortest paths between the two devices
61 */ 61 */
62 Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst); 62 Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst);
...@@ -65,9 +65,9 @@ public interface PathService { ...@@ -65,9 +65,9 @@ public interface PathService {
65 * Returns the set of all disjoint shortest path pairs, computed using the supplied 65 * Returns the set of all disjoint shortest path pairs, computed using the supplied
66 * edge-weight entity, between the specified source and destination devices. 66 * edge-weight entity, between the specified source and destination devices.
67 * 67 *
68 - * @param src source device 68 + * @param src source device
69 - * @param dst destination device 69 + * @param dst destination device
70 - * @param weight edge-weight entity 70 + * @param weight edge-weight entity
71 * @return set of all shortest paths between the two devices 71 * @return set of all shortest paths between the two devices
72 */ 72 */
73 Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, 73 Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
...@@ -77,25 +77,25 @@ public interface PathService { ...@@ -77,25 +77,25 @@ public interface PathService {
77 * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count, 77 * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
78 * between the specified source and destination devices. 78 * between the specified source and destination devices.
79 * 79 *
80 - * @param src source device 80 + * @param src source device
81 - * @param dst destination device 81 + * @param dst destination device
82 * @param riskProfile map of edges to risk profiles 82 * @param riskProfile map of edges to risk profiles
83 * @return set of all shortest paths between the two devices 83 * @return set of all shortest paths between the two devices
84 */ 84 */
85 - Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst, 85 + Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
86 - Map<Link, Object> riskProfile); 86 + Map<Link, Object> riskProfile);
87 87
88 /** 88 /**
89 * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count, 89 * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
90 * between the specified source and destination devices. 90 * between the specified source and destination devices.
91 * 91 *
92 - * @param src source device 92 + * @param src source device
93 - * @param dst destination device 93 + * @param dst destination device
94 - * @param weight edge-weight entity 94 + * @param weight edge-weight entity
95 * @param riskProfile map of edges to risk profiles 95 * @param riskProfile map of edges to risk profiles
96 * @return set of all shortest paths between the two devices 96 * @return set of all shortest paths between the two devices
97 */ 97 */
98 - Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst, 98 + Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
99 - LinkWeight weight, Map<Link, Object> riskProfile); 99 + LinkWeight weight, Map<Link, Object> riskProfile);
100 100
101 } 101 }
......
...@@ -29,7 +29,7 @@ import java.util.Set; ...@@ -29,7 +29,7 @@ import java.util.Set;
29 * Service for providing network topology information. 29 * Service for providing network topology information.
30 */ 30 */
31 public interface TopologyService 31 public interface TopologyService
32 - extends ListenerService<TopologyEvent, TopologyListener> { 32 + extends ListenerService<TopologyEvent, TopologyListener> {
33 33
34 /** 34 /**
35 * Returns the current topology descriptor. 35 * Returns the current topology descriptor.
...@@ -74,8 +74,8 @@ public interface TopologyService ...@@ -74,8 +74,8 @@ public interface TopologyService
74 /** 74 /**
75 * Returns the set of devices that belong to the specified cluster. 75 * Returns the set of devices that belong to the specified cluster.
76 * 76 *
77 - * @param topology topology descriptor 77 + * @param topology topology descriptor
78 - * @param cluster topology cluster 78 + * @param cluster topology cluster
79 * @return set of cluster devices 79 * @return set of cluster devices
80 */ 80 */
81 Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster); 81 Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster);
...@@ -83,8 +83,8 @@ public interface TopologyService ...@@ -83,8 +83,8 @@ public interface TopologyService
83 /** 83 /**
84 * Returns the set of links that form the specified cluster. 84 * Returns the set of links that form the specified cluster.
85 * 85 *
86 - * @param topology topology descriptor 86 + * @param topology topology descriptor
87 - * @param cluster topology cluster 87 + * @param cluster topology cluster
88 * @return set of cluster links 88 * @return set of cluster links
89 */ 89 */
90 Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster); 90 Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster);
...@@ -141,28 +141,29 @@ public interface TopologyService ...@@ -141,28 +141,29 @@ public interface TopologyService
141 * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count, 141 * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
142 * between the specified source and destination devices. 142 * between the specified source and destination devices.
143 * 143 *
144 - * @param topology topology descriptor 144 + * @param topology topology descriptor
145 - * @param src source device 145 + * @param src source device
146 - * @param dst destination device 146 + * @param dst destination device
147 * @param riskProfile map of edges to risk profiles 147 * @param riskProfile map of edges to risk profiles
148 * @return set of all shortest paths between the two devices 148 * @return set of all shortest paths between the two devices
149 */ 149 */
150 - Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, 150 + Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
151 - Map<Link, Object> riskProfile); 151 + Map<Link, Object> riskProfile);
152 152
153 /** 153 /**
154 * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count, 154 * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
155 * between the specified source and destination devices. 155 * between the specified source and destination devices.
156 * 156 *
157 - * @param topology topology descriptor 157 + * @param topology topology descriptor
158 - * @param src source device 158 + * @param src source device
159 - * @param dst destination device 159 + * @param dst destination device
160 - * @param weight edge-weight entity 160 + * @param weight edge-weight entity
161 * @param riskProfile map of edges to risk profiles 161 * @param riskProfile map of edges to risk profiles
162 * @return set of all shortest paths between the two devices 162 * @return set of all shortest paths between the two devices
163 */ 163 */
164 - Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, 164 + Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
165 - LinkWeight weight, Map<Link, Object> riskProfile); 165 + LinkWeight weight, Map<Link, Object> riskProfile);
166 +
166 /** 167 /**
167 * Indicates whether the specified connection point is part of the network 168 * Indicates whether the specified connection point is part of the network
168 * infrastructure or part of network edge. 169 * infrastructure or part of network edge.
......
...@@ -149,8 +149,8 @@ public interface TopologyStore extends Store<TopologyEvent, TopologyStoreDelegat ...@@ -149,8 +149,8 @@ public interface TopologyStore extends Store<TopologyEvent, TopologyStoreDelegat
149 * be treated as if they were in the same risk group. 149 * be treated as if they were in the same risk group.
150 * @return set of shortest paths 150 * @return set of shortest paths
151 */ 151 */
152 - Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, 152 + Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
153 - LinkWeight weight, Map<Link, Object> riskProfile); 153 + LinkWeight weight, Map<Link, Object> riskProfile);
154 154
155 /** 155 /**
156 * Returns the set of pre-computed SRLG shortest paths between src and dest. 156 * Returns the set of pre-computed SRLG shortest paths between src and dest.
...@@ -162,8 +162,8 @@ public interface TopologyStore extends Store<TopologyEvent, TopologyStoreDelegat ...@@ -162,8 +162,8 @@ public interface TopologyStore extends Store<TopologyEvent, TopologyStoreDelegat
162 * be treated as if they were in the same risk group. 162 * be treated as if they were in the same risk group.
163 * @return set of shortest paths 163 * @return set of shortest paths
164 */ 164 */
165 - Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, 165 + Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
166 - Map<Link, Object> riskProfile); 166 + Map<Link, Object> riskProfile);
167 167
168 168
169 /** 169 /**
......
...@@ -17,12 +17,10 @@ package org.onosproject.net.intent; ...@@ -17,12 +17,10 @@ package org.onosproject.net.intent;
17 17
18 import com.google.common.base.MoreObjects; 18 import com.google.common.base.MoreObjects;
19 import com.google.common.collect.ImmutableSet; 19 import com.google.common.collect.ImmutableSet;
20 -
21 import org.onlab.util.Bandwidth; 20 import org.onlab.util.Bandwidth;
22 import org.onosproject.core.DefaultGroupId; 21 import org.onosproject.core.DefaultGroupId;
23 import org.onosproject.core.GroupId; 22 import org.onosproject.core.GroupId;
24 import org.onosproject.net.DeviceId; 23 import org.onosproject.net.DeviceId;
25 -import org.onosproject.net.DisjointPath;
26 import org.onosproject.net.ElementId; 24 import org.onosproject.net.ElementId;
27 import org.onosproject.net.Link; 25 import org.onosproject.net.Link;
28 import org.onosproject.net.NetTestTools; 26 import org.onosproject.net.NetTestTools;
...@@ -38,6 +36,9 @@ import org.onosproject.net.flow.criteria.Criterion.Type; ...@@ -38,6 +36,9 @@ import org.onosproject.net.flow.criteria.Criterion.Type;
38 import org.onosproject.net.flow.instructions.Instruction; 36 import org.onosproject.net.flow.instructions.Instruction;
39 import org.onosproject.net.flow.instructions.Instructions; 37 import org.onosproject.net.flow.instructions.Instructions;
40 import org.onosproject.net.flow.instructions.Instructions.MetadataInstruction; 38 import org.onosproject.net.flow.instructions.Instructions.MetadataInstruction;
39 +import org.onosproject.net.resource.ResourceAllocation;
40 +import org.onosproject.net.resource.ResourceRequest;
41 +import org.onosproject.net.resource.ResourceType;
41 import org.onosproject.net.resource.link.BandwidthResource; 42 import org.onosproject.net.resource.link.BandwidthResource;
42 import org.onosproject.net.resource.link.BandwidthResourceRequest; 43 import org.onosproject.net.resource.link.BandwidthResourceRequest;
43 import org.onosproject.net.resource.link.LambdaResource; 44 import org.onosproject.net.resource.link.LambdaResource;
...@@ -49,13 +50,10 @@ import org.onosproject.net.resource.link.LinkResourceRequest; ...@@ -49,13 +50,10 @@ import org.onosproject.net.resource.link.LinkResourceRequest;
49 import org.onosproject.net.resource.link.LinkResourceService; 50 import org.onosproject.net.resource.link.LinkResourceService;
50 import org.onosproject.net.resource.link.MplsLabel; 51 import org.onosproject.net.resource.link.MplsLabel;
51 import org.onosproject.net.resource.link.MplsLabelResourceAllocation; 52 import org.onosproject.net.resource.link.MplsLabelResourceAllocation;
52 -import org.onosproject.net.resource.ResourceAllocation;
53 -import org.onosproject.net.resource.ResourceRequest;
54 -import org.onosproject.net.resource.ResourceType;
55 import org.onosproject.net.topology.DefaultTopologyEdge; 53 import org.onosproject.net.topology.DefaultTopologyEdge;
56 import org.onosproject.net.topology.DefaultTopologyVertex; 54 import org.onosproject.net.topology.DefaultTopologyVertex;
57 import org.onosproject.net.topology.LinkWeight; 55 import org.onosproject.net.topology.LinkWeight;
58 -import org.onosproject.net.topology.PathService; 56 +import org.onosproject.net.topology.PathServiceAdapter;
59 import org.onosproject.net.topology.TopologyVertex; 57 import org.onosproject.net.topology.TopologyVertex;
60 import org.onosproject.store.Timestamp; 58 import org.onosproject.store.Timestamp;
61 59
...@@ -65,14 +63,11 @@ import java.util.Collections; ...@@ -65,14 +63,11 @@ import java.util.Collections;
65 import java.util.HashSet; 63 import java.util.HashSet;
66 import java.util.LinkedList; 64 import java.util.LinkedList;
67 import java.util.List; 65 import java.util.List;
68 -import java.util.Map;
69 import java.util.Objects; 66 import java.util.Objects;
70 import java.util.Set; 67 import java.util.Set;
71 import java.util.concurrent.atomic.AtomicLong; 68 import java.util.concurrent.atomic.AtomicLong;
72 69
73 -import static org.onosproject.net.NetTestTools.createPath; 70 +import static org.onosproject.net.NetTestTools.*;
74 -import static org.onosproject.net.NetTestTools.did;
75 -import static org.onosproject.net.NetTestTools.link;
76 71
77 /** 72 /**
78 * Common mocks used by the intent framework tests. 73 * Common mocks used by the intent framework tests.
...@@ -136,7 +131,7 @@ public class IntentTestsMocks { ...@@ -136,7 +131,7 @@ public class IntentTestsMocks {
136 /** 131 /**
137 * Mock path service for creating paths within the test. 132 * Mock path service for creating paths within the test.
138 */ 133 */
139 - public static class MockPathService implements PathService { 134 + public static class MockPathService extends PathServiceAdapter {
140 135
141 final String[] pathHops; 136 final String[] pathHops;
142 final String[] reversePathHops; 137 final String[] reversePathHops;
...@@ -187,28 +182,6 @@ public class IntentTestsMocks { ...@@ -187,28 +182,6 @@ public class IntentTestsMocks {
187 } 182 }
188 return paths; 183 return paths;
189 } 184 }
190 -
191 - @Override
192 - public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
193 - return null;
194 - }
195 -
196 - @Override
197 - public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
198 - return null;
199 - }
200 -
201 - @Override
202 - public Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst,
203 - Map<Link, Object> riskProfile) {
204 - return null;
205 - }
206 -
207 - @Override
208 - public Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst, LinkWeight weight,
209 - Map<Link, Object> riskProfile) {
210 - return null;
211 - }
212 } 185 }
213 186
214 public static class MockLinkResourceAllocations implements LinkResourceAllocations { 187 public static class MockLinkResourceAllocations implements LinkResourceAllocations {
......
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.topology;
17 +
18 +import org.onosproject.net.DisjointPath;
19 +import org.onosproject.net.ElementId;
20 +import org.onosproject.net.Link;
21 +import org.onosproject.net.Path;
22 +
23 +import java.util.Map;
24 +import java.util.Set;
25 +
26 +/**
27 + * Test adapter for path service.
28 + */
29 +public class PathServiceAdapter implements PathService {
30 + @Override
31 + public Set<Path> getPaths(ElementId src, ElementId dst) {
32 + return null;
33 + }
34 +
35 + @Override
36 + public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
37 + return null;
38 + }
39 +
40 + @Override
41 + public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
42 + return null;
43 + }
44 +
45 + @Override
46 + public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
47 + return null;
48 + }
49 +
50 + @Override
51 + public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
52 + Map<Link, Object> riskProfile) {
53 + return null;
54 + }
55 +
56 + @Override
57 + public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
58 + LinkWeight weight,
59 + Map<Link, Object> riskProfile) {
60 + return null;
61 + }
62 +}
...@@ -90,25 +90,28 @@ public class TopologyServiceAdapter implements TopologyService { ...@@ -90,25 +90,28 @@ public class TopologyServiceAdapter implements TopologyService {
90 @Override 90 @Override
91 public void removeListener(TopologyListener listener) { 91 public void removeListener(TopologyListener listener) {
92 } 92 }
93 +
93 @Override 94 @Override
94 public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst) { 95 public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst) {
95 return null; 96 return null;
96 } 97 }
97 98
98 @Override 99 @Override
99 - public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) { 100 + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
101 + DeviceId dst, LinkWeight weight) {
100 return null; 102 return null;
101 } 103 }
102 104
103 @Override 105 @Override
104 - public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, 106 + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
105 - Map<Link, Object> riskProfile) { 107 + Map<Link, Object> riskProfile) {
106 return null; 108 return null;
107 } 109 }
108 110
109 @Override 111 @Override
110 - public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight, 112 + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
111 - Map<Link, Object> riskProfile) { 113 + DeviceId dst, LinkWeight weight,
114 + Map<Link, Object> riskProfile) {
112 return null; 115 return null;
113 } 116 }
114 117
......
...@@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableSet; ...@@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableSet;
23 import com.google.common.collect.ImmutableSetMultimap; 23 import com.google.common.collect.ImmutableSetMultimap;
24 import com.google.common.collect.ImmutableSetMultimap.Builder; 24 import com.google.common.collect.ImmutableSetMultimap.Builder;
25 import org.onlab.graph.DijkstraGraphSearch; 25 import org.onlab.graph.DijkstraGraphSearch;
26 +import org.onlab.graph.DisjointPathPair;
26 import org.onlab.graph.GraphPathSearch; 27 import org.onlab.graph.GraphPathSearch;
27 import org.onlab.graph.GraphPathSearch.Result; 28 import org.onlab.graph.GraphPathSearch.Result;
28 import org.onlab.graph.SRLGGraphSearch; 29 import org.onlab.graph.SRLGGraphSearch;
...@@ -49,11 +50,11 @@ import org.onosproject.net.topology.TopologyEdge; ...@@ -49,11 +50,11 @@ import org.onosproject.net.topology.TopologyEdge;
49 import org.onosproject.net.topology.TopologyGraph; 50 import org.onosproject.net.topology.TopologyGraph;
50 import org.onosproject.net.topology.TopologyVertex; 51 import org.onosproject.net.topology.TopologyVertex;
51 52
52 -import java.util.ArrayList;
53 import java.util.HashMap; 53 import java.util.HashMap;
54 import java.util.List; 54 import java.util.List;
55 import java.util.Map; 55 import java.util.Map;
56 import java.util.Set; 56 import java.util.Set;
57 +import java.util.stream.Collectors;
57 58
58 import static com.google.common.base.MoreObjects.toStringHelper; 59 import static com.google.common.base.MoreObjects.toStringHelper;
59 import static com.google.common.base.Preconditions.checkArgument; 60 import static com.google.common.base.Preconditions.checkArgument;
...@@ -333,7 +334,7 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -333,7 +334,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
333 * @return set of shortest disjoint path pairs 334 * @return set of shortest disjoint path pairs
334 */ 335 */
335 public Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst) { 336 public Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst) {
336 - return getDisjointPaths(src, dst, null); 337 + return getDisjointPaths(src, dst, (LinkWeight) null);
337 } 338 }
338 339
339 /** 340 /**
...@@ -369,27 +370,15 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -369,27 +370,15 @@ public class DefaultTopology extends AbstractModel implements Topology {
369 * 370 *
370 * @param src source device 371 * @param src source device
371 * @param dst destination device 372 * @param dst destination device
372 - * @param riskProfile map representing risk groups for each edge
373 - * @return set of shortest disjoint paths
374 - */
375 - public Set<DisjointPath> getSRLGDisjointPathsD(DeviceId src, DeviceId dst, Map<TopologyEdge, Object> riskProfile) {
376 - return getSRLGDisjointPathsD(src, dst, null, riskProfile);
377 - }
378 -
379 - /**
380 - * Computes on-demand the set of shortest disjoint risk groups path pairs between source and
381 - * destination devices.
382 - *
383 - * @param src source device
384 - * @param dst destination device
385 * @param weight edge weight object 373 * @param weight edge weight object
386 * @param riskProfile map representing risk groups for each edge 374 * @param riskProfile map representing risk groups for each edge
387 * @return set of shortest disjoint paths 375 * @return set of shortest disjoint paths
388 */ 376 */
389 - public Set<DisjointPath> getSRLGDisjointPathsD(DeviceId src, DeviceId dst, LinkWeight weight, Map<TopologyEdge, 377 + private Set<DisjointPath> disjointPaths(DeviceId src, DeviceId dst, LinkWeight weight,
390 - Object> riskProfile) { 378 + Map<TopologyEdge, Object> riskProfile) {
391 - final DefaultTopologyVertex srcV = new DefaultTopologyVertex(src); 379 + DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
392 - final DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst); 380 + DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
381 +
393 Set<TopologyVertex> vertices = graph.getVertexes(); 382 Set<TopologyVertex> vertices = graph.getVertexes();
394 if (!vertices.contains(srcV) || !vertices.contains(dstV)) { 383 if (!vertices.contains(srcV) || !vertices.contains(dstV)) {
395 // src or dst not part of the current graph 384 // src or dst not part of the current graph
...@@ -416,35 +405,27 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -416,35 +405,27 @@ public class DefaultTopology extends AbstractModel implements Topology {
416 * @param riskProfile map representing risk groups for each link 405 * @param riskProfile map representing risk groups for each link
417 * @return set of shortest disjoint paths 406 * @return set of shortest disjoint paths
418 */ 407 */
419 - public Set<DisjointPath> getSRLGDisjointPaths(DeviceId src, DeviceId dst, LinkWeight weight, 408 + public Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst, LinkWeight weight,
420 - Map<Link, Object> riskProfile) { 409 + Map<Link, Object> riskProfile) {
421 Map<TopologyEdge, Object> riskProfile2 = new HashMap<>(); 410 Map<TopologyEdge, Object> riskProfile2 = new HashMap<>();
422 for (Link l : riskProfile.keySet()) { 411 for (Link l : riskProfile.keySet()) {
423 riskProfile2.put(new TopologyEdge() { 412 riskProfile2.put(new TopologyEdge() {
424 - final Link cur = l; 413 + Link cur = l;
425 414
426 public Link link() { 415 public Link link() {
427 return cur; 416 return cur;
428 } 417 }
429 418
430 public TopologyVertex src() { 419 public TopologyVertex src() {
431 - return new TopologyVertex() { 420 + return () -> src;
432 - public DeviceId deviceId() {
433 - return src;
434 - }
435 - };
436 } 421 }
437 422
438 public TopologyVertex dst() { 423 public TopologyVertex dst() {
439 - return new TopologyVertex() { 424 + return () -> dst;
440 - public DeviceId deviceId() {
441 - return dst;
442 - }
443 - };
444 } 425 }
445 }, riskProfile.get(l)); 426 }, riskProfile.get(l));
446 } 427 }
447 - return getSRLGDisjointPathsD(src, dst, weight, riskProfile2); 428 + return disjointPaths(src, dst, weight, riskProfile2);
448 } 429 }
449 430
450 /** 431 /**
...@@ -456,22 +437,20 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -456,22 +437,20 @@ public class DefaultTopology extends AbstractModel implements Topology {
456 * @param riskProfile map representing risk groups for each link 437 * @param riskProfile map representing risk groups for each link
457 * @return set of shortest disjoint paths 438 * @return set of shortest disjoint paths
458 */ 439 */
459 - public Set<DisjointPath> getSRLGDisjointPaths(DeviceId src, DeviceId dst, Map<Link, Object> riskProfile) { 440 + public Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst, Map<Link, Object> riskProfile) {
460 - return getSRLGDisjointPaths(src, dst, null, riskProfile); 441 + return getDisjointPaths(src, dst, null, riskProfile);
461 } 442 }
462 443
463 // Converts graph path to a network path with the same cost. 444 // Converts graph path to a network path with the same cost.
464 private Path networkPath(org.onlab.graph.Path<TopologyVertex, TopologyEdge> path) { 445 private Path networkPath(org.onlab.graph.Path<TopologyVertex, TopologyEdge> path) {
465 - List<Link> links = new ArrayList<>(); 446 + List<Link> links = path.edges().stream().map(TopologyEdge::link).collect(Collectors.toList());
466 - for (TopologyEdge edge : path.edges()) {
467 - links.add(edge.link());
468 - }
469 return new DefaultPath(CORE_PROVIDER_ID, links, path.cost()); 447 return new DefaultPath(CORE_PROVIDER_ID, links, path.cost());
470 } 448 }
471 449
472 - private DisjointPath networkDisjointPath(org.onlab.graph.DisjointPathPair<TopologyVertex, TopologyEdge> path) { 450 + private DisjointPath networkDisjointPath(DisjointPathPair<TopologyVertex, TopologyEdge> path) {
473 return new DefaultDisjointPath(CORE_PROVIDER_ID, 451 return new DefaultDisjointPath(CORE_PROVIDER_ID,
474 - (DefaultPath) networkPath(path.path1), (DefaultPath) networkPath(path.path2)); 452 + (DefaultPath) networkPath(path.primary()),
453 + (DefaultPath) networkPath(path.secondary()));
475 } 454 }
476 455
477 // Searches for SCC clusters in the network topology graph using Tarjan 456 // Searches for SCC clusters in the network topology graph using Tarjan
...@@ -484,6 +463,7 @@ public class DefaultTopology extends AbstractModel implements Topology { ...@@ -484,6 +463,7 @@ public class DefaultTopology extends AbstractModel implements Topology {
484 private ImmutableMap<ClusterId, TopologyCluster> buildTopologyClusters() { 463 private ImmutableMap<ClusterId, TopologyCluster> buildTopologyClusters() {
485 ImmutableMap.Builder<ClusterId, TopologyCluster> clusterBuilder = ImmutableMap.builder(); 464 ImmutableMap.Builder<ClusterId, TopologyCluster> clusterBuilder = ImmutableMap.builder();
486 SCCResult<TopologyVertex, TopologyEdge> results = clusterResults.get(); 465 SCCResult<TopologyVertex, TopologyEdge> results = clusterResults.get();
466 +
487 // Extract both vertexes and edges from the results; the lists form 467 // Extract both vertexes and edges from the results; the lists form
488 // pairs along the same index. 468 // pairs along the same index.
489 List<Set<TopologyVertex>> clusterVertexes = results.clusterVertexes(); 469 List<Set<TopologyVertex>> clusterVertexes = results.clusterVertexes();
......
...@@ -127,15 +127,15 @@ public class SimpleTopologyStore ...@@ -127,15 +127,15 @@ public class SimpleTopologyStore
127 } 127 }
128 128
129 @Override 129 @Override
130 - public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, 130 + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
131 Map<Link, Object> riskProfile) { 131 Map<Link, Object> riskProfile) {
132 - return defaultTopology(topology).getSRLGDisjointPaths(src, dst, riskProfile); 132 + return defaultTopology(topology).getDisjointPaths(src, dst, riskProfile);
133 } 133 }
134 134
135 @Override 135 @Override
136 - public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, 136 + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
137 LinkWeight weight, Map<Link, Object> riskProfile) { 137 LinkWeight weight, Map<Link, Object> riskProfile) {
138 - return defaultTopology(topology).getSRLGDisjointPaths(src, dst, weight, riskProfile); 138 + return defaultTopology(topology).getDisjointPaths(src, dst, weight, riskProfile);
139 } 139 }
140 140
141 @Override 141 @Override
......
...@@ -134,7 +134,7 @@ public class PathManager implements PathService { ...@@ -134,7 +134,7 @@ public class PathManager implements PathService {
134 134
135 @Override 135 @Override
136 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) { 136 public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
137 - return getDisjointPaths(src, dst, null); 137 + return getDisjointPaths(src, dst, (LinkWeight) null);
138 } 138 }
139 139
140 @Override 140 @Override
...@@ -171,14 +171,14 @@ public class PathManager implements PathService { ...@@ -171,14 +171,14 @@ public class PathManager implements PathService {
171 } 171 }
172 172
173 @Override 173 @Override
174 - public Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst, 174 + public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
175 - Map<Link, Object> riskProfile) { 175 + Map<Link, Object> riskProfile) {
176 - return getSRLGDisjointPaths(src, dst, null, riskProfile); 176 + return getDisjointPaths(src, dst, null, riskProfile);
177 } 177 }
178 178
179 @Override 179 @Override
180 - public Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst, LinkWeight weight, 180 + public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight,
181 - Map<Link, Object> riskProfile) { 181 + Map<Link, Object> riskProfile) {
182 checkNotNull(src, ELEMENT_ID_NULL); 182 checkNotNull(src, ELEMENT_ID_NULL);
183 checkNotNull(dst, ELEMENT_ID_NULL); 183 checkNotNull(dst, ELEMENT_ID_NULL);
184 184
...@@ -204,8 +204,8 @@ public class PathManager implements PathService { ...@@ -204,8 +204,8 @@ public class PathManager implements PathService {
204 // devices. 204 // devices.
205 Topology topology = topologyService.currentTopology(); 205 Topology topology = topologyService.currentTopology();
206 Set<DisjointPath> paths = weight == null ? 206 Set<DisjointPath> paths = weight == null ?
207 - topologyService.getSRLGDisjointPaths(topology, srcDevice, dstDevice, riskProfile) : 207 + topologyService.getDisjointPaths(topology, srcDevice, dstDevice, riskProfile) :
208 - topologyService.getSRLGDisjointPaths(topology, srcDevice, dstDevice, weight, riskProfile); 208 + topologyService.getDisjointPaths(topology, srcDevice, dstDevice, weight, riskProfile);
209 209
210 return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths); 210 return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths);
211 } 211 }
...@@ -249,6 +249,7 @@ public class PathManager implements PathService { ...@@ -249,6 +249,7 @@ public class PathManager implements PathService {
249 endToEndPaths.add(edgeToEdgePathD(srcLink, dstLink, null)); 249 endToEndPaths.add(edgeToEdgePathD(srcLink, dstLink, null));
250 return endToEndPaths; 250 return endToEndPaths;
251 } 251 }
252 +
252 private Set<DisjointPath> edgeToEdgePathsDisjoint(EdgeLink srcLink, EdgeLink dstLink, Set<DisjointPath> paths) { 253 private Set<DisjointPath> edgeToEdgePathsDisjoint(EdgeLink srcLink, EdgeLink dstLink, Set<DisjointPath> paths) {
253 Set<DisjointPath> endToEndPaths = Sets.newHashSetWithExpectedSize(paths.size()); 254 Set<DisjointPath> endToEndPaths = Sets.newHashSetWithExpectedSize(paths.size());
254 for (DisjointPath path : paths) { 255 for (DisjointPath path : paths) {
......
...@@ -62,7 +62,7 @@ import static org.onosproject.security.AppPermission.Type.*; ...@@ -62,7 +62,7 @@ import static org.onosproject.security.AppPermission.Type.*;
62 @Service 62 @Service
63 public class TopologyManager 63 public class TopologyManager
64 extends AbstractListenerProviderRegistry<TopologyEvent, TopologyListener, 64 extends AbstractListenerProviderRegistry<TopologyEvent, TopologyListener,
65 - TopologyProvider, TopologyProviderService> 65 + TopologyProvider, TopologyProviderService>
66 implements TopologyService, TopologyProviderRegistry { 66 implements TopologyService, TopologyProviderRegistry {
67 67
68 public static final String TOPOLOGY_NULL = "Topology cannot be null"; 68 public static final String TOPOLOGY_NULL = "Topology cannot be null";
...@@ -70,6 +70,7 @@ public class TopologyManager ...@@ -70,6 +70,7 @@ public class TopologyManager
70 private static final String CLUSTER_ID_NULL = "Cluster ID cannot be null"; 70 private static final String CLUSTER_ID_NULL = "Cluster ID cannot be null";
71 private static final String CLUSTER_NULL = "Topology cluster cannot be null"; 71 private static final String CLUSTER_NULL = "Topology cluster cannot be null";
72 public static final String CONNECTION_POINT_NULL = "Connection point cannot be null"; 72 public static final String CONNECTION_POINT_NULL = "Connection point cannot be null";
73 + public static final String LINK_WEIGHT_NULL = "Link weight cannot be null";
73 74
74 private final Logger log = getLogger(getClass()); 75 private final Logger log = getLogger(getClass());
75 76
...@@ -172,31 +173,33 @@ public class TopologyManager ...@@ -172,31 +173,33 @@ public class TopologyManager
172 } 173 }
173 174
174 @Override 175 @Override
175 - public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) { 176 + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
177 + DeviceId dst, LinkWeight weight) {
176 checkNotNull(topology, TOPOLOGY_NULL); 178 checkNotNull(topology, TOPOLOGY_NULL);
177 checkNotNull(src, DEVICE_ID_NULL); 179 checkNotNull(src, DEVICE_ID_NULL);
178 checkNotNull(dst, DEVICE_ID_NULL); 180 checkNotNull(dst, DEVICE_ID_NULL);
179 - checkNotNull(weight, "Link weight cannot be null"); 181 + checkNotNull(weight, LINK_WEIGHT_NULL);
180 return store.getDisjointPaths(topology, src, dst, weight); 182 return store.getDisjointPaths(topology, src, dst, weight);
181 } 183 }
182 184
183 @Override 185 @Override
184 - public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, 186 + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
185 - Map<Link, Object> riskProfile) { 187 + Map<Link, Object> riskProfile) {
186 checkNotNull(topology, TOPOLOGY_NULL); 188 checkNotNull(topology, TOPOLOGY_NULL);
187 checkNotNull(src, DEVICE_ID_NULL); 189 checkNotNull(src, DEVICE_ID_NULL);
188 checkNotNull(dst, DEVICE_ID_NULL); 190 checkNotNull(dst, DEVICE_ID_NULL);
189 - return store.getSRLGDisjointPaths(topology, src, dst, riskProfile); 191 + return store.getDisjointPaths(topology, src, dst, riskProfile);
190 } 192 }
191 193
192 @Override 194 @Override
193 - public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight, 195 + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
194 - Map<Link, Object> riskProfile) { 196 + DeviceId dst, LinkWeight weight,
197 + Map<Link, Object> riskProfile) {
195 checkNotNull(topology, TOPOLOGY_NULL); 198 checkNotNull(topology, TOPOLOGY_NULL);
196 checkNotNull(src, DEVICE_ID_NULL); 199 checkNotNull(src, DEVICE_ID_NULL);
197 checkNotNull(dst, DEVICE_ID_NULL); 200 checkNotNull(dst, DEVICE_ID_NULL);
198 - checkNotNull(weight, "Link weight cannot be null"); 201 + checkNotNull(weight, LINK_WEIGHT_NULL);
199 - return store.getSRLGDisjointPaths(topology, src, dst, weight, riskProfile); 202 + return store.getDisjointPaths(topology, src, dst, weight, riskProfile);
200 } 203 }
201 204
202 @Override 205 @Override
......
...@@ -21,9 +21,7 @@ import org.onosproject.TestApplicationId; ...@@ -21,9 +21,7 @@ import org.onosproject.TestApplicationId;
21 import org.onosproject.core.ApplicationId; 21 import org.onosproject.core.ApplicationId;
22 import org.onosproject.net.ConnectPoint; 22 import org.onosproject.net.ConnectPoint;
23 import org.onosproject.net.DeviceId; 23 import org.onosproject.net.DeviceId;
24 -import org.onosproject.net.DisjointPath;
25 import org.onosproject.net.ElementId; 24 import org.onosproject.net.ElementId;
26 -import org.onosproject.net.Link;
27 import org.onosproject.net.Path; 25 import org.onosproject.net.Path;
28 import org.onosproject.net.device.DeviceServiceAdapter; 26 import org.onosproject.net.device.DeviceServiceAdapter;
29 import org.onosproject.net.flow.TrafficSelector; 27 import org.onosproject.net.flow.TrafficSelector;
...@@ -33,12 +31,10 @@ import org.onosproject.net.intent.Intent; ...@@ -33,12 +31,10 @@ import org.onosproject.net.intent.Intent;
33 import org.onosproject.net.intent.IntentTestsMocks; 31 import org.onosproject.net.intent.IntentTestsMocks;
34 import org.onosproject.net.intent.LinkCollectionIntent; 32 import org.onosproject.net.intent.LinkCollectionIntent;
35 import org.onosproject.net.intent.MultiPointToSinglePointIntent; 33 import org.onosproject.net.intent.MultiPointToSinglePointIntent;
36 -import org.onosproject.net.topology.LinkWeight; 34 +import org.onosproject.net.topology.PathServiceAdapter;
37 -import org.onosproject.net.topology.PathService;
38 35
39 import java.util.HashSet; 36 import java.util.HashSet;
40 import java.util.List; 37 import java.util.List;
41 -import java.util.Map;
42 import java.util.Set; 38 import java.util.Set;
43 39
44 import static org.hamcrest.CoreMatchers.instanceOf; 40 import static org.hamcrest.CoreMatchers.instanceOf;
...@@ -63,7 +59,7 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes ...@@ -63,7 +59,7 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes
63 /** 59 /**
64 * Mock path service for creating paths within the test. 60 * Mock path service for creating paths within the test.
65 */ 61 */
66 - private static class MockPathService implements PathService { 62 + private static class MockPathService extends PathServiceAdapter {
67 63
68 final String[] pathHops; 64 final String[] pathHops;
69 65
...@@ -89,33 +85,6 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes ...@@ -89,33 +85,6 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes
89 85
90 return result; 86 return result;
91 } 87 }
92 -
93 - @Override
94 - public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
95 - return null;
96 - }
97 -
98 - @Override
99 - public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
100 - return null;
101 - }
102 -
103 - @Override
104 - public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
105 - return null;
106 - }
107 -
108 - @Override
109 - public Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst,
110 - Map<Link, Object> riskProfile) {
111 - return null;
112 - }
113 -
114 - @Override
115 - public Set<DisjointPath> getSRLGDisjointPaths(ElementId src, ElementId dst, LinkWeight weight,
116 - Map<Link, Object> riskProfile) {
117 - return null;
118 - }
119 } 88 }
120 89
121 /** 90 /**
......
...@@ -19,19 +19,15 @@ import org.junit.After; ...@@ -19,19 +19,15 @@ import org.junit.After;
19 import org.junit.Before; 19 import org.junit.Before;
20 import org.junit.Test; 20 import org.junit.Test;
21 import org.onosproject.net.DeviceId; 21 import org.onosproject.net.DeviceId;
22 -import org.onosproject.net.DisjointPath;
23 import org.onosproject.net.ElementId; 22 import org.onosproject.net.ElementId;
24 import org.onosproject.net.Host; 23 import org.onosproject.net.Host;
25 import org.onosproject.net.HostId; 24 import org.onosproject.net.HostId;
26 -import org.onosproject.net.Link;
27 import org.onosproject.net.Path; 25 import org.onosproject.net.Path;
28 -import org.onosproject.net.host.HostService;
29 import org.onosproject.net.host.HostServiceAdapter; 26 import org.onosproject.net.host.HostServiceAdapter;
30 import org.onosproject.net.provider.ProviderId; 27 import org.onosproject.net.provider.ProviderId;
31 import org.onosproject.net.topology.LinkWeight; 28 import org.onosproject.net.topology.LinkWeight;
32 import org.onosproject.net.topology.PathService; 29 import org.onosproject.net.topology.PathService;
33 import org.onosproject.net.topology.Topology; 30 import org.onosproject.net.topology.Topology;
34 -import org.onosproject.net.topology.TopologyService;
35 import org.onosproject.net.topology.TopologyServiceAdapter; 31 import org.onosproject.net.topology.TopologyServiceAdapter;
36 32
37 import java.util.HashMap; 33 import java.util.HashMap;
...@@ -139,7 +135,7 @@ public class PathManagerTest { ...@@ -139,7 +135,7 @@ public class PathManagerTest {
139 } 135 }
140 136
141 // Fake entity to give out paths. 137 // Fake entity to give out paths.
142 - private class FakeTopoMgr extends TopologyServiceAdapter implements TopologyService { 138 + private class FakeTopoMgr extends TopologyServiceAdapter {
143 Set<Path> paths = new HashSet<>(); 139 Set<Path> paths = new HashSet<>();
144 140
145 @Override 141 @Override
...@@ -151,32 +147,10 @@ public class PathManagerTest { ...@@ -151,32 +147,10 @@ public class PathManagerTest {
151 public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) { 147 public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
152 return paths; 148 return paths;
153 } 149 }
154 -
155 - @Override
156 - public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst) {
157 - return null;
158 - }
159 -
160 - @Override
161 - public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
162 - return null;
163 - }
164 -
165 - @Override
166 - public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
167 - Map<Link, Object> riskProfile) {
168 - return null;
169 - }
170 -
171 - @Override
172 - public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight,
173 - Map<Link, Object> riskProfile) {
174 - return null;
175 - }
176 } 150 }
177 151
178 // Fake entity to give out hosts. 152 // Fake entity to give out hosts.
179 - private class FakeHostMgr extends HostServiceAdapter implements HostService { 153 + private class FakeHostMgr extends HostServiceAdapter {
180 private Map<HostId, Host> hosts = new HashMap<>(); 154 private Map<HostId, Host> hosts = new HashMap<>();
181 155
182 @Override 156 @Override
......
...@@ -179,15 +179,15 @@ public class DistributedTopologyStore ...@@ -179,15 +179,15 @@ public class DistributedTopologyStore
179 } 179 }
180 180
181 @Override 181 @Override
182 - public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, 182 + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
183 - Map<Link, Object> riskProfile) { 183 + Map<Link, Object> riskProfile) {
184 - return defaultTopology(topology).getSRLGDisjointPaths(src, dst, riskProfile); 184 + return defaultTopology(topology).getDisjointPaths(src, dst, riskProfile);
185 } 185 }
186 186
187 @Override 187 @Override
188 - public Set<DisjointPath> getSRLGDisjointPaths(Topology topology, DeviceId src, DeviceId dst, 188 + public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
189 - LinkWeight weight, Map<Link, Object> riskProfile) { 189 + LinkWeight weight, Map<Link, Object> riskProfile) {
190 - return defaultTopology(topology).getSRLGDisjointPaths(src, dst, weight, riskProfile); 190 + return defaultTopology(topology).getDisjointPaths(src, dst, weight, riskProfile);
191 } 191 }
192 192
193 @Override 193 @Override
......
...@@ -19,52 +19,67 @@ package org.onlab.graph; ...@@ -19,52 +19,67 @@ package org.onlab.graph;
19 19
20 import java.util.List; 20 import java.util.List;
21 import java.util.Objects; 21 import java.util.Objects;
22 -import java.util.Set;
23 22
24 -import static com.google.common.collect.ImmutableSet.of;
25 import static com.google.common.base.MoreObjects.toStringHelper; 23 import static com.google.common.base.MoreObjects.toStringHelper;
26 24
27 - 25 +/**
26 + * Pair of disjoint paths.
27 + *
28 + * @param <V> type of vertex
29 + * @param <E> type of edge
30 + */
28 public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Path<V, E> { 31 public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Path<V, E> {
29 - public Path<V, E> path1, path2; 32 +
30 - boolean usingPath1 = true; 33 + private Path<V, E> primary, secondary;
34 + boolean primaryActive = true;
31 35
32 /** 36 /**
33 - * Creates a Disjoint Path Pair from two paths. 37 + * Creates a disjoint path pair from two paths.
34 * 38 *
35 - * @param p1 first path 39 + * @param primary primary path
36 - * @param p2 second path 40 + * @param secondary secondary path
37 */ 41 */
38 - public DisjointPathPair(Path<V, E> p1, Path<V, E> p2) { 42 + public DisjointPathPair(Path<V, E> primary, Path<V, E> secondary) {
39 - path1 = p1; 43 + this.primary = primary;
40 - path2 = p2; 44 + this.secondary = secondary;
41 } 45 }
42 46
43 @Override 47 @Override
44 public V src() { 48 public V src() {
45 - return path1.src(); 49 + return primary.src();
46 } 50 }
47 51
48 @Override 52 @Override
49 public V dst() { 53 public V dst() {
50 - return path1.dst(); 54 + return primary.dst();
55 + }
56 +
57 + /**
58 + * Returns the primary path.
59 + *
60 + * @return primary path
61 + */
62 + public Path<V, E> primary() {
63 + return primary;
64 + }
65 +
66 + /**
67 + * Returns the secondary path.
68 + *
69 + * @return primary path
70 + */
71 + public Path<V, E> secondary() {
72 + return secondary;
51 } 73 }
52 74
53 @Override 75 @Override
54 public double cost() { 76 public double cost() {
55 - if (!hasBackup()) { 77 + return hasBackup() ? primary.cost() + secondary.cost() : primary.cost();
56 - return path1.cost();
57 - }
58 - return path1.cost() + path2.cost();
59 } 78 }
60 79
61 @Override 80 @Override
62 public List<E> edges() { 81 public List<E> edges() {
63 - if (usingPath1 || !hasBackup()) { 82 + return primaryActive || !hasBackup() ? primary.edges() : secondary.edges();
64 - return path1.edges();
65 - } else {
66 - return path2.edges();
67 - }
68 } 83 }
69 84
70 /** 85 /**
...@@ -73,7 +88,7 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa ...@@ -73,7 +88,7 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa
73 * @return boolean representing whether it has backup 88 * @return boolean representing whether it has backup
74 */ 89 */
75 public boolean hasBackup() { 90 public boolean hasBackup() {
76 - return path2 != null && path2.edges() != null; 91 + return secondary != null && secondary.edges() != null;
77 } 92 }
78 93
79 @Override 94 @Override
...@@ -88,13 +103,8 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa ...@@ -88,13 +103,8 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa
88 103
89 @Override 104 @Override
90 public int hashCode() { 105 public int hashCode() {
91 - Set<Path<V, E>> paths; 106 + return hasBackup() ? Objects.hash(primary) + Objects.hash(secondary) :
92 - if (!hasBackup()) { 107 + Objects.hash(primary);
93 - paths = of(path1);
94 - } else {
95 - paths = of(path1, path2);
96 - }
97 - return Objects.hash(paths);
98 } 108 }
99 109
100 @Override 110 @Override
...@@ -106,10 +116,10 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa ...@@ -106,10 +116,10 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa
106 final DisjointPathPair other = (DisjointPathPair) obj; 116 final DisjointPathPair other = (DisjointPathPair) obj;
107 return Objects.equals(this.src(), other.src()) && 117 return Objects.equals(this.src(), other.src()) &&
108 Objects.equals(this.dst(), other.dst()) && 118 Objects.equals(this.dst(), other.dst()) &&
109 - (Objects.equals(this.path1, other.path1) && 119 + (Objects.equals(this.primary, other.primary) &&
110 - Objects.equals(this.path2, other.path2)) || 120 + Objects.equals(this.secondary, other.secondary)) ||
111 - (Objects.equals(this.path1, other.path2) && 121 + (Objects.equals(this.primary, other.secondary) &&
112 - Objects.equals(this.path2, other.path1)); 122 + Objects.equals(this.secondary, other.primary));
113 } 123 }
114 return false; 124 return false;
115 } 125 }
...@@ -120,9 +130,6 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa ...@@ -120,9 +130,6 @@ public class DisjointPathPair<V extends Vertex, E extends Edge<V>> implements Pa
120 * @return number of paths 130 * @return number of paths
121 */ 131 */
122 public int size() { 132 public int size() {
123 - if (hasBackup()) { 133 + return hasBackup() ? 2 : 1;
124 - return 2;
125 - }
126 - return 1;
127 } 134 }
128 } 135 }
......
...@@ -17,44 +17,37 @@ ...@@ -17,44 +17,37 @@
17 package org.onlab.graph; 17 package org.onlab.graph;
18 18
19 import org.junit.Test; 19 import org.junit.Test;
20 -import java.util.Set; 20 +
21 +import java.util.HashMap;
21 import java.util.HashSet; 22 import java.util.HashSet;
22 import java.util.Map; 23 import java.util.Map;
23 -import java.util.HashMap; 24 +import java.util.Set;
24 25
25 import static com.google.common.collect.ImmutableSet.of; 26 import static com.google.common.collect.ImmutableSet.of;
27 +import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertTrue; 28 import static org.junit.Assert.assertTrue;
27 - 29 +import static org.onlab.graph.GraphPathSearch.ALL_PATHS;
28 -
29 30
30 /** 31 /**
31 * Test of the Suurballe backup path algorithm. 32 * Test of the Suurballe backup path algorithm.
32 */ 33 */
33 public class SRLGGraphSearchTest extends BreadthFirstSearchTest { 34 public class SRLGGraphSearchTest extends BreadthFirstSearchTest {
35 +
34 @Override 36 @Override
35 protected AbstractGraphPathSearch<TestVertex, TestEdge> graphSearch() { 37 protected AbstractGraphPathSearch<TestVertex, TestEdge> graphSearch() {
36 - return new SRLGGraphSearch<TestVertex, TestEdge>(null); 38 + return new SRLGGraphSearch<>(null);
37 } 39 }
38 40
39 - public void setWeights() {
40 - weight = new EdgeWeight<TestVertex, TestEdge>() {
41 - @Override
42 - public double weight(TestEdge edge) {
43 - return edge.weight();
44 - }
45 - };
46 - }
47 public void setDefaultWeights() { 41 public void setDefaultWeights() {
48 weight = null; 42 weight = null;
49 } 43 }
44 +
50 @Override 45 @Override
51 public void defaultGraphTest() { 46 public void defaultGraphTest() {
52 -
53 } 47 }
54 48
55 @Override 49 @Override
56 public void defaultHopCountWeight() { 50 public void defaultHopCountWeight() {
57 -
58 } 51 }
59 52
60 @Test 53 @Test
...@@ -66,34 +59,34 @@ public class SRLGGraphSearchTest extends BreadthFirstSearchTest { ...@@ -66,34 +59,34 @@ public class SRLGGraphSearchTest extends BreadthFirstSearchTest {
66 TestEdge dC = new TestEdge(D, C, 1); 59 TestEdge dC = new TestEdge(D, C, 1);
67 Graph<TestVertex, TestEdge> graph = new AdjacencyListsGraph<>(of(A, B, C, D), 60 Graph<TestVertex, TestEdge> graph = new AdjacencyListsGraph<>(of(A, B, C, D),
68 of(aB, bC, aD, dC)); 61 of(aB, bC, aD, dC));
69 - Map<TestEdge, Integer> riskProfile = new HashMap<TestEdge, Integer>(); 62 + Map<TestEdge, Integer> riskProfile = new HashMap<>();
70 riskProfile.put(aB, 0); 63 riskProfile.put(aB, 0);
71 riskProfile.put(bC, 0); 64 riskProfile.put(bC, 0);
72 riskProfile.put(aD, 1); 65 riskProfile.put(aD, 1);
73 riskProfile.put(dC, 1); 66 riskProfile.put(dC, 1);
74 - SRLGGraphSearch<TestVertex, TestEdge> search = 67 + SRLGGraphSearch<TestVertex, TestEdge> search = new SRLGGraphSearch<>(2, riskProfile);
75 - new SRLGGraphSearch<TestVertex, TestEdge>(2, riskProfile); 68 + Set<Path<TestVertex, TestEdge>> paths = search.search(graph, A, C, weight, ALL_PATHS).paths();
76 - Set<Path<TestVertex, TestEdge>> paths = search.search(graph, A, C, weight, GraphPathSearch.ALL_PATHS).paths();
77 System.out.println("\n\n\n" + paths + "\n\n\n"); 69 System.out.println("\n\n\n" + paths + "\n\n\n");
78 - assertTrue("one disjoint path pair found", paths.size() == 1); 70 + assertEquals("one disjoint path pair found", 1, paths.size());
79 checkIsDisjoint(paths.iterator().next(), riskProfile); 71 checkIsDisjoint(paths.iterator().next(), riskProfile);
80 } 72 }
73 +
81 public void checkIsDisjoint(Path<TestVertex, TestEdge> p, Map<TestEdge, Integer> risks) { 74 public void checkIsDisjoint(Path<TestVertex, TestEdge> p, Map<TestEdge, Integer> risks) {
82 assertTrue("The path is not a DisjointPathPair", (p instanceof DisjointPathPair)); 75 assertTrue("The path is not a DisjointPathPair", (p instanceof DisjointPathPair));
83 DisjointPathPair<TestVertex, TestEdge> q = (DisjointPathPair) p; 76 DisjointPathPair<TestVertex, TestEdge> q = (DisjointPathPair) p;
84 - Set<Integer> p1Risks = new HashSet<Integer>(); 77 + Set<Integer> p1Risks = new HashSet<>();
85 - Set<Integer> p2Risks = new HashSet<Integer>(); 78 + for (TestEdge e : q.edges()) {
86 - for (TestEdge e: q.edges()) {
87 p1Risks.add(risks.get(e)); 79 p1Risks.add(risks.get(e));
88 } 80 }
89 if (!q.hasBackup()) { 81 if (!q.hasBackup()) {
90 return; 82 return;
91 } 83 }
92 - Path<TestVertex, TestEdge> pq = q.path2; 84 + Path<TestVertex, TestEdge> pq = q.secondary();
93 for (TestEdge e: pq.edges()) { 85 for (TestEdge e: pq.edges()) {
94 assertTrue("The paths are not disjoint", !p1Risks.contains(risks.get(e))); 86 assertTrue("The paths are not disjoint", !p1Risks.contains(risks.get(e)));
95 } 87 }
96 } 88 }
89 +
97 @Test 90 @Test
98 public void complexGraphTest() { 91 public void complexGraphTest() {
99 setDefaultWeights(); 92 setDefaultWeights();
...@@ -105,16 +98,15 @@ public class SRLGGraphSearchTest extends BreadthFirstSearchTest { ...@@ -105,16 +98,15 @@ public class SRLGGraphSearchTest extends BreadthFirstSearchTest {
105 TestEdge bE = new TestEdge(B, E, 1); 98 TestEdge bE = new TestEdge(B, E, 1);
106 Graph<TestVertex, TestEdge> graph = new AdjacencyListsGraph<>(of(A, B, C, D, E), 99 Graph<TestVertex, TestEdge> graph = new AdjacencyListsGraph<>(of(A, B, C, D, E),
107 of(aB, bC, aD, dC, cE, bE)); 100 of(aB, bC, aD, dC, cE, bE));
108 - Map<TestEdge, Integer> riskProfile = new HashMap<TestEdge, Integer>(); 101 + Map<TestEdge, Integer> riskProfile = new HashMap<>();
109 riskProfile.put(aB, 0); 102 riskProfile.put(aB, 0);
110 riskProfile.put(bC, 0); 103 riskProfile.put(bC, 0);
111 riskProfile.put(aD, 1); 104 riskProfile.put(aD, 1);
112 riskProfile.put(dC, 1); 105 riskProfile.put(dC, 1);
113 riskProfile.put(cE, 2); 106 riskProfile.put(cE, 2);
114 riskProfile.put(bE, 3); 107 riskProfile.put(bE, 3);
115 - SRLGGraphSearch<TestVertex, TestEdge> search = 108 + SRLGGraphSearch<TestVertex, TestEdge> search = new SRLGGraphSearch<>(4, riskProfile);
116 - new SRLGGraphSearch<TestVertex, TestEdge>(4, riskProfile); 109 + search.search(graph, A, E, weight, ALL_PATHS).paths();
117 - Set<Path<TestVertex, TestEdge>> paths = search.search(graph, A, E, weight, GraphPathSearch.ALL_PATHS).paths();
118 } 110 }
119 111
120 @Test 112 @Test
...@@ -128,19 +120,19 @@ public class SRLGGraphSearchTest extends BreadthFirstSearchTest { ...@@ -128,19 +120,19 @@ public class SRLGGraphSearchTest extends BreadthFirstSearchTest {
128 TestEdge cE = new TestEdge(C, E, 1); 120 TestEdge cE = new TestEdge(C, E, 1);
129 Graph<TestVertex, TestEdge> graph = new AdjacencyListsGraph<>(of(A, B, C, D, E), 121 Graph<TestVertex, TestEdge> graph = new AdjacencyListsGraph<>(of(A, B, C, D, E),
130 of(aB, bE, aD, dE, aC, cE)); 122 of(aB, bE, aD, dE, aC, cE));
131 - Map<TestEdge, Integer> riskProfile = new HashMap<TestEdge, Integer>(); 123 + Map<TestEdge, Integer> riskProfile = new HashMap<>();
132 riskProfile.put(aB, 0); 124 riskProfile.put(aB, 0);
133 riskProfile.put(bE, 1); 125 riskProfile.put(bE, 1);
134 riskProfile.put(aD, 2); 126 riskProfile.put(aD, 2);
135 riskProfile.put(dE, 3); 127 riskProfile.put(dE, 3);
136 riskProfile.put(aC, 4); 128 riskProfile.put(aC, 4);
137 riskProfile.put(cE, 5); 129 riskProfile.put(cE, 5);
138 - SRLGGraphSearch<TestVertex, TestEdge> search = 130 + SRLGGraphSearch<TestVertex, TestEdge> search = new SRLGGraphSearch<>(6, riskProfile);
139 - new SRLGGraphSearch<TestVertex, TestEdge>(6, riskProfile); 131 + Set<Path<TestVertex, TestEdge>> paths = search.search(graph, A, E, weight, ALL_PATHS).paths();
140 - Set<Path<TestVertex, TestEdge>> paths = search.search(graph, A, E, weight, GraphPathSearch.ALL_PATHS).paths();
141 assertTrue("> one disjoint path pair found", paths.size() >= 1); 132 assertTrue("> one disjoint path pair found", paths.size() >= 1);
142 checkIsDisjoint(paths.iterator().next(), riskProfile); 133 checkIsDisjoint(paths.iterator().next(), riskProfile);
143 } 134 }
135 +
144 @Test 136 @Test
145 public void onePath() { 137 public void onePath() {
146 setDefaultWeights(); 138 setDefaultWeights();
...@@ -150,17 +142,17 @@ public class SRLGGraphSearchTest extends BreadthFirstSearchTest { ...@@ -150,17 +142,17 @@ public class SRLGGraphSearchTest extends BreadthFirstSearchTest {
150 TestEdge dC = new TestEdge(D, C, 1); 142 TestEdge dC = new TestEdge(D, C, 1);
151 Graph<TestVertex, TestEdge> graph = new AdjacencyListsGraph<>(of(A, B, C, D), 143 Graph<TestVertex, TestEdge> graph = new AdjacencyListsGraph<>(of(A, B, C, D),
152 of(aB, bC, aD, dC)); 144 of(aB, bC, aD, dC));
153 - Map<TestEdge, Integer> riskProfile = new HashMap<TestEdge, Integer>(); 145 + Map<TestEdge, Integer> riskProfile = new HashMap<>();
154 riskProfile.put(aB, 0); 146 riskProfile.put(aB, 0);
155 riskProfile.put(bC, 0); 147 riskProfile.put(bC, 0);
156 riskProfile.put(aD, 1); 148 riskProfile.put(aD, 1);
157 riskProfile.put(dC, 0); 149 riskProfile.put(dC, 0);
158 - SRLGGraphSearch<TestVertex, TestEdge> search = 150 + SRLGGraphSearch<TestVertex, TestEdge> search = new SRLGGraphSearch<>(2, riskProfile);
159 - new SRLGGraphSearch<TestVertex, TestEdge>(2, riskProfile); 151 + Set<Path<TestVertex, TestEdge>> paths = search.search(graph, A, C, weight, ALL_PATHS).paths();
160 - Set<Path<TestVertex, TestEdge>> paths = search.search(graph, A, C, weight, GraphPathSearch.ALL_PATHS).paths();
161 System.out.println(paths); 152 System.out.println(paths);
162 assertTrue("no disjoint path pairs found", paths.size() == 0); 153 assertTrue("no disjoint path pairs found", paths.size() == 0);
163 } 154 }
155 +
164 @Test 156 @Test
165 public void noPath() { 157 public void noPath() {
166 setDefaultWeights(); 158 setDefaultWeights();
...@@ -175,9 +167,8 @@ public class SRLGGraphSearchTest extends BreadthFirstSearchTest { ...@@ -175,9 +167,8 @@ public class SRLGGraphSearchTest extends BreadthFirstSearchTest {
175 riskProfile.put(bC, 0); 167 riskProfile.put(bC, 0);
176 riskProfile.put(aD, 1); 168 riskProfile.put(aD, 1);
177 riskProfile.put(dC, 0); 169 riskProfile.put(dC, 0);
178 - SRLGGraphSearch<TestVertex, TestEdge> search = 170 + SRLGGraphSearch<TestVertex, TestEdge> search = new SRLGGraphSearch<>(2, riskProfile);
179 - new SRLGGraphSearch<>(2, riskProfile); 171 + Set<Path<TestVertex, TestEdge>> paths = search.search(graph, A, E, weight, ALL_PATHS).paths();
180 - Set<Path<TestVertex, TestEdge>> paths = search.search(graph, A, E, weight, GraphPathSearch.ALL_PATHS).paths();
181 assertTrue("no disjoint path pairs found", paths.size() == 0); 172 assertTrue("no disjoint path pairs found", paths.size() == 0);
182 } 173 }
183 } 174 }
......
...@@ -15,7 +15,11 @@ ...@@ -15,7 +15,11 @@
15 */ 15 */
16 package org.onosproject.rest.resources; 16 package org.onosproject.rest.resources;
17 17
18 -import java.util.Set; 18 +import org.onosproject.net.DeviceId;
19 +import org.onosproject.net.ElementId;
20 +import org.onosproject.net.HostId;
21 +import org.onosproject.net.topology.PathService;
22 +import org.onosproject.rest.AbstractWebResource;
19 23
20 import javax.ws.rs.GET; 24 import javax.ws.rs.GET;
21 import javax.ws.rs.Path; 25 import javax.ws.rs.Path;
...@@ -23,14 +27,7 @@ import javax.ws.rs.PathParam; ...@@ -23,14 +27,7 @@ import javax.ws.rs.PathParam;
23 import javax.ws.rs.Produces; 27 import javax.ws.rs.Produces;
24 import javax.ws.rs.core.MediaType; 28 import javax.ws.rs.core.MediaType;
25 import javax.ws.rs.core.Response; 29 import javax.ws.rs.core.Response;
26 - 30 +import java.util.Set;
27 -import org.onosproject.net.DeviceId;
28 -import org.onosproject.net.ElementId;
29 -import org.onosproject.net.HostId;
30 -import org.onosproject.net.topology.PathService;
31 -
32 -import com.fasterxml.jackson.databind.node.ObjectNode;
33 -import org.onosproject.rest.AbstractWebResource;
34 31
35 /** 32 /**
36 * Compute paths in the network graph. 33 * Compute paths in the network graph.
...@@ -50,6 +47,17 @@ public class PathsWebResource extends AbstractWebResource { ...@@ -50,6 +47,17 @@ public class PathsWebResource extends AbstractWebResource {
50 } 47 }
51 48
52 /** 49 /**
50 + * Returns either host id or device id, depending on the ID format.
51 + *
52 + * @param id host or device id string
53 + * @return element id
54 + */
55 + private ElementId elementId(String id) {
56 + ElementId elementId = isHostId(id);
57 + return elementId != null ? elementId : DeviceId.deviceId(id);
58 + }
59 +
60 + /**
53 * Get all shortest paths between any two hosts or devices. 61 * Get all shortest paths between any two hosts or devices.
54 * Returns array of all shortest paths between any two elements. 62 * Returns array of all shortest paths between any two elements.
55 * 63 *
...@@ -63,49 +71,27 @@ public class PathsWebResource extends AbstractWebResource { ...@@ -63,49 +71,27 @@ public class PathsWebResource extends AbstractWebResource {
63 public Response getPath(@PathParam("src") String src, 71 public Response getPath(@PathParam("src") String src,
64 @PathParam("dst") String dst) { 72 @PathParam("dst") String dst) {
65 PathService pathService = get(PathService.class); 73 PathService pathService = get(PathService.class);
66 - 74 + Set<org.onosproject.net.Path> paths =
67 - ElementId srcElement = isHostId(src); 75 + pathService.getPaths(elementId(src), elementId(dst));
68 - ElementId dstElement = isHostId(dst); 76 + return ok(encodeArray(org.onosproject.net.Path.class, "paths", paths)).build();
69 -
70 - if (srcElement == null) {
71 - // Doesn't look like a host, assume it is a device
72 - srcElement = DeviceId.deviceId(src);
73 - }
74 -
75 - if (dstElement == null) {
76 - // Doesn't look like a host, assume it is a device
77 - dstElement = DeviceId.deviceId(dst);
78 - }
79 -
80 - Set<org.onosproject.net.Path> paths = pathService.getPaths(srcElement, dstElement);
81 - ObjectNode root = encodeArray(org.onosproject.net.Path.class, "paths", paths);
82 - return ok(root).build();
83 } 77 }
84 78
79 + /**
80 + * Get all shortest disjoint paths between any two hosts or devices.
81 + * Returns array of all shortest disjoint paths between any two elements.
82 + *
83 + * @param src source identifier
84 + * @param dst destination identifier
85 + * @return path data
86 + */
85 @GET 87 @GET
86 @Produces(MediaType.APPLICATION_JSON) 88 @Produces(MediaType.APPLICATION_JSON)
87 @Path("{src}/{dst}/disjoint") 89 @Path("{src}/{dst}/disjoint")
88 -
89 public Response getDisjointPath(@PathParam("src") String src, 90 public Response getDisjointPath(@PathParam("src") String src,
90 - @PathParam("dst") String dst) { 91 + @PathParam("dst") String dst) {
91 PathService pathService = get(PathService.class); 92 PathService pathService = get(PathService.class);
92 -
93 - ElementId srcElement = isHostId(src);
94 - ElementId dstElement = isHostId(dst);
95 -
96 - if (srcElement == null) {
97 - // Doesn't look like a host, assume it is a device
98 - srcElement = DeviceId.deviceId(src);
99 - }
100 -
101 - if (dstElement == null) {
102 - // Doesn't look like a host, assume it is a device
103 - dstElement = DeviceId.deviceId(dst);
104 - }
105 Set<org.onosproject.net.DisjointPath> paths = 93 Set<org.onosproject.net.DisjointPath> paths =
106 - pathService.getDisjointPaths(srcElement, dstElement); 94 + pathService.getDisjointPaths(elementId(src), elementId(dst));
107 - ObjectNode root = 95 + return ok(encodeArray(org.onosproject.net.DisjointPath.class, "paths", paths)).build();
108 - encodeArray(org.onosproject.net.DisjointPath.class, "paths", paths);
109 - return ok(root).build();
110 } 96 }
111 } 97 }
......