Committed by
Gerrit Code Review
Fixed a small issue with disjoint path visualization.
Change-Id: I135caecd4231192ca383d6a4a7e6764abc6e3d11
Showing
1 changed file
with
13 additions
and
13 deletions
... | @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableSet; | ... | @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableSet; |
21 | import com.google.common.collect.Sets; | 21 | import com.google.common.collect.Sets; |
22 | import org.onlab.osgi.ServiceDirectory; | 22 | import org.onlab.osgi.ServiceDirectory; |
23 | import org.onosproject.net.DeviceId; | 23 | import org.onosproject.net.DeviceId; |
24 | +import org.onosproject.net.DisjointPath; | ||
24 | import org.onosproject.net.ElementId; | 25 | import org.onosproject.net.ElementId; |
25 | import org.onosproject.net.HostId; | 26 | import org.onosproject.net.HostId; |
26 | import org.onosproject.net.Link; | 27 | import org.onosproject.net.Link; |
... | @@ -34,7 +35,6 @@ import org.onosproject.ui.topo.TopoJson; | ... | @@ -34,7 +35,6 @@ import org.onosproject.ui.topo.TopoJson; |
34 | import org.slf4j.Logger; | 35 | import org.slf4j.Logger; |
35 | import org.slf4j.LoggerFactory; | 36 | import org.slf4j.LoggerFactory; |
36 | 37 | ||
37 | -import java.util.ArrayList; | ||
38 | import java.util.Collection; | 38 | import java.util.Collection; |
39 | import java.util.List; | 39 | import java.util.List; |
40 | import java.util.Set; | 40 | import java.util.Set; |
... | @@ -56,7 +56,6 @@ public class PathPainterTopovMessageHandler extends UiMessageHandler { | ... | @@ -56,7 +56,6 @@ public class PathPainterTopovMessageHandler extends UiMessageHandler { |
56 | private static final String MODE = "mode"; | 56 | private static final String MODE = "mode"; |
57 | 57 | ||
58 | private Set<Link> allPathLinks; | 58 | private Set<Link> allPathLinks; |
59 | - private Set<Link> selectedPathLinks; | ||
60 | 59 | ||
61 | private enum Mode { | 60 | private enum Mode { |
62 | SHORTEST, DISJOINT, SRLG | 61 | SHORTEST, DISJOINT, SRLG |
... | @@ -215,16 +214,15 @@ public class PathPainterTopovMessageHandler extends UiMessageHandler { | ... | @@ -215,16 +214,15 @@ public class PathPainterTopovMessageHandler extends UiMessageHandler { |
215 | log.info("src={}; dst={}; mode={}", src, dst, currentMode); | 214 | log.info("src={}; dst={}; mode={}", src, dst, currentMode); |
216 | if (src != null && dst != null) { | 215 | if (src != null && dst != null) { |
217 | log.info("test" + src + dst); | 216 | log.info("test" + src + dst); |
218 | - paths = null; | 217 | + paths = ImmutableList.copyOf(pathService.getDisjointPaths(src, dst)); |
219 | - paths = new ArrayList<>(); | ||
220 | - pathService.getDisjointPaths(src, dst).forEach(djp -> { | ||
221 | - paths.add(djp.primary()); | ||
222 | - paths.add(djp.backup()); | ||
223 | - }); | ||
224 | pathIndex = 0; | 218 | pathIndex = 0; |
225 | 219 | ||
226 | ImmutableSet.Builder<Link> builder = ImmutableSet.builder(); | 220 | ImmutableSet.Builder<Link> builder = ImmutableSet.builder(); |
227 | - paths.forEach(path -> path.links().forEach(builder::add)); | 221 | + paths.forEach(path -> { |
222 | + DisjointPath dp = (DisjointPath) path; | ||
223 | + builder.addAll(dp.primary().links()); | ||
224 | + builder.addAll(dp.backup().links()); | ||
225 | + }); | ||
228 | allPathLinks = builder.build(); | 226 | allPathLinks = builder.build(); |
229 | } else { | 227 | } else { |
230 | paths = ImmutableList.of(); | 228 | paths = ImmutableList.of(); |
... | @@ -237,16 +235,18 @@ public class PathPainterTopovMessageHandler extends UiMessageHandler { | ... | @@ -237,16 +235,18 @@ public class PathPainterTopovMessageHandler extends UiMessageHandler { |
237 | PathLinkMap linkMap = new PathLinkMap(); | 235 | PathLinkMap linkMap = new PathLinkMap(); |
238 | allPathLinks.forEach(linkMap::add); | 236 | allPathLinks.forEach(linkMap::add); |
239 | 237 | ||
238 | + Set<Link> selectedPathLinks; | ||
239 | + | ||
240 | // Prepare two working sets; one containing selected path links and | 240 | // Prepare two working sets; one containing selected path links and |
241 | // the other containing all paths links. | 241 | // the other containing all paths links. |
242 | if (currentMode.equals(Mode.DISJOINT)) { | 242 | if (currentMode.equals(Mode.DISJOINT)) { |
243 | - //FIXME: find a way to skip 2 paths for disjoint | 243 | + DisjointPath dp = (DisjointPath) paths.get(pathIndex); |
244 | selectedPathLinks = paths.isEmpty() ? | 244 | selectedPathLinks = paths.isEmpty() ? |
245 | - ImmutableSet.of() : Sets.newHashSet(paths.get(pathIndex * 2).links()); | 245 | + ImmutableSet.of() : Sets.newHashSet(dp.primary().links()); |
246 | - selectedPathLinks.addAll(Sets.newHashSet(paths.get(pathIndex * 2 + 1).links())); | 246 | + selectedPathLinks.addAll(dp.backup().links()); |
247 | } else { | 247 | } else { |
248 | selectedPathLinks = paths.isEmpty() ? | 248 | selectedPathLinks = paths.isEmpty() ? |
249 | - ImmutableSet.of() : Sets.newHashSet(paths.get(pathIndex).links()); | 249 | + ImmutableSet.of() : ImmutableSet.copyOf(paths.get(pathIndex).links()); |
250 | } | 250 | } |
251 | Highlights highlights = new Highlights(); | 251 | Highlights highlights = new Highlights(); |
252 | for (PathLink plink : linkMap.biLinks()) { | 252 | for (PathLink plink : linkMap.biLinks()) { | ... | ... |
-
Please register or login to post a comment