Committed by
Gerrit Code Review
ONOS-2186 - GUI Topo Overlay - (WIP)
- Cleaned up intent highlighting in TrafficMonitor (deleted deprecated TrafficClass). - update traffic ESC handler to force cancel traffic. Change-Id: I9cab752152718c367ff0cbf4dcacc1dff299164b
Showing
3 changed files
with
56 additions
and
100 deletions
... | @@ -37,10 +37,11 @@ import org.onosproject.net.statistic.Load; | ... | @@ -37,10 +37,11 @@ import org.onosproject.net.statistic.Load; |
37 | import org.onosproject.ui.impl.topo.IntentSelection; | 37 | import org.onosproject.ui.impl.topo.IntentSelection; |
38 | import org.onosproject.ui.impl.topo.ServicesBundle; | 38 | import org.onosproject.ui.impl.topo.ServicesBundle; |
39 | import org.onosproject.ui.impl.topo.TopoIntentFilter; | 39 | import org.onosproject.ui.impl.topo.TopoIntentFilter; |
40 | -import org.onosproject.ui.impl.topo.TrafficClass; | ||
41 | import org.onosproject.ui.impl.topo.TrafficLink; | 40 | import org.onosproject.ui.impl.topo.TrafficLink; |
41 | +import org.onosproject.ui.impl.topo.TrafficLink.StatsType; | ||
42 | import org.onosproject.ui.impl.topo.TrafficLinkMap; | 42 | import org.onosproject.ui.impl.topo.TrafficLinkMap; |
43 | import org.onosproject.ui.topo.Highlights; | 43 | import org.onosproject.ui.topo.Highlights; |
44 | +import org.onosproject.ui.topo.LinkHighlight.Flavor; | ||
44 | import org.onosproject.ui.topo.NodeSelection; | 45 | import org.onosproject.ui.topo.NodeSelection; |
45 | import org.onosproject.ui.topo.TopoUtils; | 46 | import org.onosproject.ui.topo.TopoUtils; |
46 | import org.slf4j.Logger; | 47 | import org.slf4j.Logger; |
... | @@ -59,9 +60,8 @@ import java.util.TimerTask; | ... | @@ -59,9 +60,8 @@ import java.util.TimerTask; |
59 | 60 | ||
60 | import static org.onosproject.net.DefaultEdgeLink.createEdgeLink; | 61 | import static org.onosproject.net.DefaultEdgeLink.createEdgeLink; |
61 | import static org.onosproject.ui.impl.TrafficMonitor.Mode.IDLE; | 62 | import static org.onosproject.ui.impl.TrafficMonitor.Mode.IDLE; |
63 | +import static org.onosproject.ui.impl.TrafficMonitor.Mode.RELATED_INTENTS; | ||
62 | import static org.onosproject.ui.impl.TrafficMonitor.Mode.SELECTED_INTENT; | 64 | import static org.onosproject.ui.impl.TrafficMonitor.Mode.SELECTED_INTENT; |
63 | -import static org.onosproject.ui.topo.LinkHighlight.Flavor.PRIMARY_HIGHLIGHT; | ||
64 | -import static org.onosproject.ui.topo.LinkHighlight.Flavor.SECONDARY_HIGHLIGHT; | ||
65 | 65 | ||
66 | /** | 66 | /** |
67 | * Encapsulates the behavior of monitoring specific traffic patterns. | 67 | * Encapsulates the behavior of monitoring specific traffic patterns. |
... | @@ -239,6 +239,9 @@ public class TrafficMonitor { | ... | @@ -239,6 +239,9 @@ public class TrafficMonitor { |
239 | if (selectedIntents != null) { | 239 | if (selectedIntents != null) { |
240 | selectedIntents.next(); | 240 | selectedIntents.next(); |
241 | sendSelectedIntents(); | 241 | sendSelectedIntents(); |
242 | + if (mode == SELECTED_INTENT) { | ||
243 | + mode = RELATED_INTENTS; | ||
244 | + } | ||
242 | } | 245 | } |
243 | } | 246 | } |
244 | 247 | ||
... | @@ -251,6 +254,9 @@ public class TrafficMonitor { | ... | @@ -251,6 +254,9 @@ public class TrafficMonitor { |
251 | if (selectedIntents != null) { | 254 | if (selectedIntents != null) { |
252 | selectedIntents.prev(); | 255 | selectedIntents.prev(); |
253 | sendSelectedIntents(); | 256 | sendSelectedIntents(); |
257 | + if (mode == SELECTED_INTENT) { | ||
258 | + mode = RELATED_INTENTS; | ||
259 | + } | ||
254 | } | 260 | } |
255 | } | 261 | } |
256 | 262 | ||
... | @@ -300,7 +306,6 @@ public class TrafficMonitor { | ... | @@ -300,7 +306,6 @@ public class TrafficMonitor { |
300 | trafficTask = new TrafficUpdateTask(); | 306 | trafficTask = new TrafficUpdateTask(); |
301 | timer.schedule(trafficTask, trafficPeriod, trafficPeriod); | 307 | timer.schedule(trafficTask, trafficPeriod, trafficPeriod); |
302 | } else { | 308 | } else { |
303 | - // TEMPORARY until we are sure this is working correctly | ||
304 | log.debug("(traffic task already running)"); | 309 | log.debug("(traffic task already running)"); |
305 | } | 310 | } |
306 | } | 311 | } |
... | @@ -314,12 +319,12 @@ public class TrafficMonitor { | ... | @@ -314,12 +319,12 @@ public class TrafficMonitor { |
314 | 319 | ||
315 | private void sendAllFlowTraffic() { | 320 | private void sendAllFlowTraffic() { |
316 | log.debug("sendAllFlowTraffic"); | 321 | log.debug("sendAllFlowTraffic"); |
317 | - msgHandler.sendHighlights(trafficSummary(TrafficLink.StatsType.FLOW_STATS)); | 322 | + msgHandler.sendHighlights(trafficSummary(StatsType.FLOW_STATS)); |
318 | } | 323 | } |
319 | 324 | ||
320 | private void sendAllPortTraffic() { | 325 | private void sendAllPortTraffic() { |
321 | log.debug("sendAllPortTraffic"); | 326 | log.debug("sendAllPortTraffic"); |
322 | - msgHandler.sendHighlights(trafficSummary(TrafficLink.StatsType.PORT_STATS)); | 327 | + msgHandler.sendHighlights(trafficSummary(StatsType.PORT_STATS)); |
323 | } | 328 | } |
324 | 329 | ||
325 | private void sendDeviceLinkFlows() { | 330 | private void sendDeviceLinkFlows() { |
... | @@ -345,7 +350,7 @@ public class TrafficMonitor { | ... | @@ -345,7 +350,7 @@ public class TrafficMonitor { |
345 | // ======================================================================= | 350 | // ======================================================================= |
346 | // === Generate messages in JSON object node format | 351 | // === Generate messages in JSON object node format |
347 | 352 | ||
348 | - private Highlights trafficSummary(TrafficLink.StatsType type) { | 353 | + private Highlights trafficSummary(StatsType type) { |
349 | Highlights highlights = new Highlights(); | 354 | Highlights highlights = new Highlights(); |
350 | 355 | ||
351 | TrafficLinkMap linkMap = new TrafficLinkMap(); | 356 | TrafficLinkMap linkMap = new TrafficLinkMap(); |
... | @@ -353,9 +358,9 @@ public class TrafficMonitor { | ... | @@ -353,9 +358,9 @@ public class TrafficMonitor { |
353 | addEdgeLinks(linkMap); | 358 | addEdgeLinks(linkMap); |
354 | 359 | ||
355 | for (TrafficLink tlink : linkMap.biLinks()) { | 360 | for (TrafficLink tlink : linkMap.biLinks()) { |
356 | - if (type == TrafficLink.StatsType.FLOW_STATS) { | 361 | + if (type == StatsType.FLOW_STATS) { |
357 | attachFlowLoad(tlink); | 362 | attachFlowLoad(tlink); |
358 | - } else if (type == TrafficLink.StatsType.PORT_STATS) { | 363 | + } else if (type == StatsType.PORT_STATS) { |
359 | attachPortLoad(tlink); | 364 | attachPortLoad(tlink); |
360 | } | 365 | } |
361 | 366 | ||
... | @@ -385,7 +390,7 @@ public class TrafficMonitor { | ... | @@ -385,7 +390,7 @@ public class TrafficMonitor { |
385 | 390 | ||
386 | // now report on our collated links | 391 | // now report on our collated links |
387 | for (TrafficLink tlink : linkMap.biLinks()) { | 392 | for (TrafficLink tlink : linkMap.biLinks()) { |
388 | - highlights.add(tlink.highlight(TrafficLink.StatsType.FLOW_COUNT)); | 393 | + highlights.add(tlink.highlight(StatsType.FLOW_COUNT)); |
389 | } | 394 | } |
390 | 395 | ||
391 | } | 396 | } |
... | @@ -420,10 +425,8 @@ public class TrafficMonitor { | ... | @@ -420,10 +425,8 @@ public class TrafficMonitor { |
420 | log.debug("Highlight intent: {} ([{}] of {})", | 425 | log.debug("Highlight intent: {} ([{}] of {})", |
421 | current.id(), selectedIntents.index(), count); | 426 | current.id(), selectedIntents.index(), count); |
422 | } | 427 | } |
423 | - TrafficClass tc1 = new TrafficClass(PRIMARY_HIGHLIGHT, primary); | 428 | + |
424 | - TrafficClass tc2 = new TrafficClass(SECONDARY_HIGHLIGHT, secondary); | 429 | + highlightIntentLinks(highlights, primary, secondary); |
425 | - // classify primary links after secondary (last man wins) | ||
426 | - highlightIntents(highlights, tc2, tc1); | ||
427 | } | 430 | } |
428 | return highlights; | 431 | return highlights; |
429 | } | 432 | } |
... | @@ -437,8 +440,8 @@ public class TrafficMonitor { | ... | @@ -437,8 +440,8 @@ public class TrafficMonitor { |
437 | primary.add(current); | 440 | primary.add(current); |
438 | log.debug("Highlight traffic for intent: {} ([{}] of {})", | 441 | log.debug("Highlight traffic for intent: {} ([{}] of {})", |
439 | current.id(), selectedIntents.index(), selectedIntents.size()); | 442 | current.id(), selectedIntents.index(), selectedIntents.size()); |
440 | - TrafficClass tc1 = new TrafficClass(PRIMARY_HIGHLIGHT, primary, true); | 443 | + |
441 | - highlightIntents(highlights, tc1); | 444 | + highlightIntentLinksWithTraffic(highlights, primary); |
442 | } | 445 | } |
443 | return highlights; | 446 | return highlights; |
444 | } | 447 | } |
... | @@ -532,27 +535,29 @@ public class TrafficMonitor { | ... | @@ -532,27 +535,29 @@ public class TrafficMonitor { |
532 | return count; | 535 | return count; |
533 | } | 536 | } |
534 | 537 | ||
535 | - private void highlightIntents(Highlights highlights, | 538 | + private void highlightIntentLinks(Highlights highlights, |
536 | - TrafficClass... trafficClasses) { | 539 | + Set<Intent> primary, Set<Intent> secondary) { |
537 | TrafficLinkMap linkMap = new TrafficLinkMap(); | 540 | TrafficLinkMap linkMap = new TrafficLinkMap(); |
541 | + // NOTE: highlight secondary first, then primary, so that links shared | ||
542 | + // by intents are colored correctly ("last man wins") | ||
543 | + createTrafficLinks(linkMap, secondary, Flavor.SECONDARY_HIGHLIGHT, false); | ||
544 | + createTrafficLinks(linkMap, primary, Flavor.PRIMARY_HIGHLIGHT, false); | ||
545 | + colorLinks(highlights, linkMap); | ||
546 | + } | ||
538 | 547 | ||
539 | - for (TrafficClass trafficClass : trafficClasses) { | 548 | + private void highlightIntentLinksWithTraffic(Highlights highlights, |
540 | - classifyLinkTraffic(linkMap, trafficClass); | 549 | + Set<Intent> primary) { |
541 | - } | 550 | + TrafficLinkMap linkMap = new TrafficLinkMap(); |
542 | - | 551 | + createTrafficLinks(linkMap, primary, Flavor.PRIMARY_HIGHLIGHT, true); |
543 | - for (TrafficLink tlink : linkMap.biLinks()) { | 552 | + colorLinks(highlights, linkMap); |
544 | - highlights.add(tlink.highlight(TrafficLink.StatsType.TAGGED)); | ||
545 | - } | ||
546 | } | 553 | } |
547 | 554 | ||
548 | - private void classifyLinkTraffic(TrafficLinkMap linkMap, | 555 | + private void createTrafficLinks(TrafficLinkMap linkMap, Set<Intent> intents, |
549 | - TrafficClass trafficClass) { | 556 | + Flavor flavor, boolean showTraffic) { |
550 | - for (Intent intent : trafficClass.intents()) { | 557 | + for (Intent intent : intents) { |
551 | - boolean isOptical = intent instanceof OpticalConnectivityIntent; | ||
552 | List<Intent> installables = servicesBundle.intentService() | 558 | List<Intent> installables = servicesBundle.intentService() |
553 | .getInstallableIntents(intent.key()); | 559 | .getInstallableIntents(intent.key()); |
554 | Iterable<Link> links = null; | 560 | Iterable<Link> links = null; |
555 | - | ||
556 | if (installables != null) { | 561 | if (installables != null) { |
557 | for (Intent installable : installables) { | 562 | for (Intent installable : installables) { |
558 | 563 | ||
... | @@ -566,34 +571,41 @@ public class TrafficMonitor { | ... | @@ -566,34 +571,41 @@ public class TrafficMonitor { |
566 | links = ((OpticalPathIntent) installable).path().links(); | 571 | links = ((OpticalPathIntent) installable).path().links(); |
567 | } | 572 | } |
568 | 573 | ||
569 | - classifyLinks(trafficClass, isOptical, linkMap, links); | 574 | + boolean isOptical = intent instanceof OpticalConnectivityIntent; |
575 | + processLinks(linkMap, links, flavor, isOptical, showTraffic); | ||
570 | } | 576 | } |
571 | } | 577 | } |
572 | } | 578 | } |
573 | } | 579 | } |
574 | 580 | ||
575 | - private void classifyLinks(TrafficClass trafficClass, boolean isOptical, | 581 | + // Extracts links from the specified flow rule intent resources |
576 | - TrafficLinkMap linkMap, | 582 | + private Collection<Link> linkResources(Intent installable) { |
577 | - Iterable<Link> links) { | 583 | + ImmutableList.Builder<Link> builder = ImmutableList.builder(); |
584 | + installable.resources().stream().filter(r -> r instanceof Link) | ||
585 | + .forEach(r -> builder.add((Link) r)); | ||
586 | + return builder.build(); | ||
587 | + } | ||
588 | + | ||
589 | + private void processLinks(TrafficLinkMap linkMap, Iterable<Link> links, | ||
590 | + Flavor flavor, boolean isOptical, | ||
591 | + boolean showTraffic) { | ||
578 | if (links != null) { | 592 | if (links != null) { |
579 | for (Link link : links) { | 593 | for (Link link : links) { |
580 | TrafficLink tlink = linkMap.add(link); | 594 | TrafficLink tlink = linkMap.add(link); |
581 | - if (trafficClass.showTraffic()) { | 595 | + tlink.tagFlavor(flavor); |
596 | + tlink.optical(isOptical); | ||
597 | + if (showTraffic) { | ||
582 | tlink.addLoad(getLinkFlowLoad(link)); | 598 | tlink.addLoad(getLinkFlowLoad(link)); |
583 | tlink.antMarch(true); | 599 | tlink.antMarch(true); |
584 | } | 600 | } |
585 | - tlink.optical(isOptical); | ||
586 | - tlink.tagFlavor(trafficClass.flavor()); | ||
587 | } | 601 | } |
588 | } | 602 | } |
589 | } | 603 | } |
590 | 604 | ||
591 | - // Extracts links from the specified flow rule intent resources | 605 | + private void colorLinks(Highlights highlights, TrafficLinkMap linkMap) { |
592 | - private Collection<Link> linkResources(Intent installable) { | 606 | + for (TrafficLink tlink : linkMap.biLinks()) { |
593 | - ImmutableList.Builder<Link> builder = ImmutableList.builder(); | 607 | + highlights.add(tlink.highlight(StatsType.TAGGED)); |
594 | - installable.resources().stream().filter(r -> r instanceof Link) | 608 | + } |
595 | - .forEach(r -> builder.add((Link) r)); | ||
596 | - return builder.build(); | ||
597 | } | 609 | } |
598 | 610 | ||
599 | // ======================================================================= | 611 | // ======================================================================= | ... | ... |
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 | - */ | ||
17 | - | ||
18 | -package org.onosproject.ui.impl.topo; | ||
19 | - | ||
20 | -import org.onosproject.net.intent.Intent; | ||
21 | -import org.onosproject.ui.topo.LinkHighlight; | ||
22 | - | ||
23 | -/** | ||
24 | - * Auxiliary data carrier for assigning a highlight class to a set of | ||
25 | - * intents, for visualization in the topology view. | ||
26 | - */ | ||
27 | -@Deprecated | ||
28 | -public class TrafficClass { | ||
29 | - | ||
30 | - private final LinkHighlight.Flavor flavor; | ||
31 | - private final Iterable<Intent> intents; | ||
32 | - private final boolean showTraffic; | ||
33 | - | ||
34 | - public TrafficClass(LinkHighlight.Flavor flavor, Iterable<Intent> intents) { | ||
35 | - this(flavor, intents, false); | ||
36 | - } | ||
37 | - | ||
38 | - public TrafficClass(LinkHighlight.Flavor flavor, Iterable<Intent> intents, | ||
39 | - boolean showTraffic) { | ||
40 | - this.flavor = flavor; | ||
41 | - this.intents = intents; | ||
42 | - this.showTraffic = showTraffic; | ||
43 | - } | ||
44 | - | ||
45 | - public LinkHighlight.Flavor flavor() { | ||
46 | - return flavor; | ||
47 | - } | ||
48 | - | ||
49 | - public Iterable<Intent> intents() { | ||
50 | - return intents; | ||
51 | - } | ||
52 | - | ||
53 | - public boolean showTraffic() { | ||
54 | - return showTraffic; | ||
55 | - } | ||
56 | -} |
... | @@ -119,7 +119,7 @@ | ... | @@ -119,7 +119,7 @@ |
119 | // hook for handling escape key | 119 | // hook for handling escape key |
120 | escape: function () { | 120 | escape: function () { |
121 | // Must return true to consume ESC, false otherwise. | 121 | // Must return true to consume ESC, false otherwise. |
122 | - return tts.cancelTraffic(); | 122 | + return tts.cancelTraffic(true); |
123 | }, | 123 | }, |
124 | 124 | ||
125 | // hooks for when the selection changes... | 125 | // hooks for when the selection changes... | ... | ... |
-
Please register or login to post a comment