Thomas Vachuska
Committed by Gerrit Code Review

Fixed a few more defects and usability issues in GUI traffic monitoring.

Change-Id: Ifd6daabafcd996bd855de9ac836606e138901f9d
...@@ -213,7 +213,7 @@ public class TopologyViewWebSocket ...@@ -213,7 +213,7 @@ public class TopologyViewWebSocket
213 processMessage((ObjectNode) mapper.reader().readTree(data)); 213 processMessage((ObjectNode) mapper.reader().readTree(data));
214 } catch (Exception e) { 214 } catch (Exception e) {
215 log.warn("Unable to parse GUI request {} due to {}", data, e); 215 log.warn("Unable to parse GUI request {} due to {}", data, e);
216 - log.warn("Boom!!!", e); 216 + log.debug("Boom!!!", e);
217 } 217 }
218 } 218 }
219 219
...@@ -231,11 +231,18 @@ public class TopologyViewWebSocket ...@@ -231,11 +231,18 @@ public class TopologyViewWebSocket
231 createMultiSourceIntent(event); 231 createMultiSourceIntent(event);
232 232
233 } else if (type.equals("requestRelatedIntents")) { 233 } else if (type.equals("requestRelatedIntents")) {
234 + stopTrafficMonitoring();
234 requestRelatedIntents(event); 235 requestRelatedIntents(event);
236 +
235 } else if (type.equals("requestNextRelatedIntent")) { 237 } else if (type.equals("requestNextRelatedIntent")) {
236 - requestNextRelatedIntent(event); 238 + stopTrafficMonitoring();
239 + requestAnotherRelatedIntent(event, +1);
240 + } else if (type.equals("requestPrevRelatedIntent")) {
241 + stopTrafficMonitoring();
242 + requestAnotherRelatedIntent(event, -1);
237 } else if (type.equals("requestSelectedIntentTraffic")) { 243 } else if (type.equals("requestSelectedIntentTraffic")) {
238 requestSelectedIntentTraffic(event); 244 requestSelectedIntentTraffic(event);
245 + startTrafficMonitoring(event);
239 246
240 } else if (type.equals("requestAllTraffic")) { 247 } else if (type.equals("requestAllTraffic")) {
241 requestAllTraffic(event); 248 requestAllTraffic(event);
...@@ -267,6 +274,7 @@ public class TopologyViewWebSocket ...@@ -267,6 +274,7 @@ public class TopologyViewWebSocket
267 } 274 }
268 } catch (IOException e) { 275 } catch (IOException e) {
269 log.warn("Unable to send message {} to GUI due to {}", data, e); 276 log.warn("Unable to send message {} to GUI due to {}", data, e);
277 + log.debug("Boom!!!", e);
270 } 278 }
271 } 279 }
272 280
...@@ -380,7 +388,7 @@ public class TopologyViewWebSocket ...@@ -380,7 +388,7 @@ public class TopologyViewWebSocket
380 selectedIntents = new ArrayList<>(); 388 selectedIntents = new ArrayList<>();
381 selectedIntents.add(intent); 389 selectedIntents.add(intent);
382 currentIntentIndex = -1; 390 currentIntentIndex = -1;
383 - requestNextRelatedIntent(event); 391 + requestAnotherRelatedIntent(event, +1);
384 requestSelectedIntentTraffic(event); 392 requestSelectedIntentTraffic(event);
385 } 393 }
386 394
...@@ -467,27 +475,31 @@ public class TopologyViewWebSocket ...@@ -467,27 +475,31 @@ public class TopologyViewWebSocket
467 intentService.getIntents()); 475 intentService.getIntents());
468 currentIntentIndex = -1; 476 currentIntentIndex = -1;
469 477
470 - String hover = string(payload, "hover");
471 if (haveSelectedIntents()) { 478 if (haveSelectedIntents()) {
472 // Send a message to highlight all links of all monitored intents. 479 // Send a message to highlight all links of all monitored intents.
473 sendMessage(trafficMessage(sid, new TrafficClass("primary", selectedIntents))); 480 sendMessage(trafficMessage(sid, new TrafficClass("primary", selectedIntents)));
474 - } else if (!isNullOrEmpty(hover)) {
475 - // If there is a hover node, include it in the selection and find intents.
476 - processExtendedSelection(sid, hover);
477 } 481 }
482 +
483 + // FIXME: Re-introduce one the client click vs hover gesture stuff is sorted out.
484 +// String hover = string(payload, "hover");
485 +// if (!isNullOrEmpty(hover)) {
486 +// // If there is a hover node, include it in the selection and find intents.
487 +// processHoverExtendedSelection(sid, hover);
488 +// }
478 } 489 }
479 490
480 private boolean haveSelectedIntents() { 491 private boolean haveSelectedIntents() {
481 return selectedIntents != null && !selectedIntents.isEmpty(); 492 return selectedIntents != null && !selectedIntents.isEmpty();
482 } 493 }
483 494
484 - private void processExtendedSelection(long sid, String hover) { 495 + // Processes the selection extended with hovered item to segregate items
485 - if (haveSelectedIntents()) { 496 + // into primary (those including the hover) vs secondary highlights.
497 + private void processHoverExtendedSelection(long sid, String hover) {
486 Set<Host> hoverSelHosts = new HashSet<>(selectedHosts); 498 Set<Host> hoverSelHosts = new HashSet<>(selectedHosts);
487 Set<Device> hoverSelDevices = new HashSet<>(selectedDevices); 499 Set<Device> hoverSelDevices = new HashSet<>(selectedDevices);
488 addHover(hoverSelHosts, hoverSelDevices, hover); 500 addHover(hoverSelHosts, hoverSelDevices, hover);
489 501
490 - List<Intent> primary = 502 + List<Intent> primary = selectedIntents == null ? new ArrayList<>() :
491 intentFilter.findPathIntents(hoverSelHosts, hoverSelDevices, 503 intentFilter.findPathIntents(hoverSelHosts, hoverSelDevices,
492 selectedIntents); 504 selectedIntents);
493 Set<Intent> secondary = new HashSet<>(selectedIntents); 505 Set<Intent> secondary = new HashSet<>(selectedIntents);
...@@ -497,12 +509,23 @@ public class TopologyViewWebSocket ...@@ -497,12 +509,23 @@ public class TopologyViewWebSocket
497 sendMessage(trafficMessage(sid, new TrafficClass("primary", primary), 509 sendMessage(trafficMessage(sid, new TrafficClass("primary", primary),
498 new TrafficClass("secondary", secondary))); 510 new TrafficClass("secondary", secondary)));
499 } 511 }
500 - }
501 512
502 - // Requests next of the related intents. 513 + // Requests next or previous related intent.
503 - private void requestNextRelatedIntent(ObjectNode event) { 514 + private void requestAnotherRelatedIntent(ObjectNode event, int offset) {
504 if (haveSelectedIntents()) { 515 if (haveSelectedIntents()) {
505 - currentIntentIndex = (currentIntentIndex + 1) % selectedIntents.size(); 516 + currentIntentIndex = currentIntentIndex + offset;
517 + if (currentIntentIndex < 0) {
518 + currentIntentIndex = selectedIntents.size() - 1;
519 + } else if (currentIntentIndex >= selectedIntents.size()) {
520 + currentIntentIndex = 0;
521 + }
522 + sendSelectedIntent(event);
523 + }
524 + }
525 +
526 + // Sends traffic information on the related intents with the currently
527 + // selected intent highlighted.
528 + private void sendSelectedIntent(ObjectNode event) {
506 Intent selectedIntent = selectedIntents.get(currentIntentIndex); 529 Intent selectedIntent = selectedIntents.get(currentIntentIndex);
507 log.info("Requested next intent {}", selectedIntent.id()); 530 log.info("Requested next intent {}", selectedIntent.id());
508 531
...@@ -517,7 +540,6 @@ public class TopologyViewWebSocket ...@@ -517,7 +540,6 @@ public class TopologyViewWebSocket
517 new TrafficClass("primary", primary), 540 new TrafficClass("primary", primary),
518 new TrafficClass("secondary", secondary))); 541 new TrafficClass("secondary", secondary)));
519 } 542 }
520 - }
521 543
522 // Requests monitoring of traffic for the selected intent. 544 // Requests monitoring of traffic for the selected intent.
523 private void requestSelectedIntentTraffic(ObjectNode event) { 545 private void requestSelectedIntentTraffic(ObjectNode event) {
...@@ -679,7 +701,7 @@ public class TopologyViewWebSocket ...@@ -679,7 +701,7 @@ public class TopologyViewWebSocket
679 } 701 }
680 } catch (Exception e) { 702 } catch (Exception e) {
681 log.warn("Unable to handle traffic request due to {}", e.getMessage()); 703 log.warn("Unable to handle traffic request due to {}", e.getMessage());
682 - log.warn("Boom!", e); 704 + log.debug("Boom!", e);
683 } 705 }
684 } 706 }
685 } 707 }
...@@ -694,6 +716,7 @@ public class TopologyViewWebSocket ...@@ -694,6 +716,7 @@ public class TopologyViewWebSocket
694 } 716 }
695 } catch (Exception e) { 717 } catch (Exception e) {
696 log.warn("Unable to handle summary request due to {}", e.getMessage()); 718 log.warn("Unable to handle summary request due to {}", e.getMessage());
719 + log.debug("Boom!", e);
697 } 720 }
698 } 721 }
699 } 722 }
...@@ -712,8 +735,8 @@ public class TopologyViewWebSocket ...@@ -712,8 +735,8 @@ public class TopologyViewWebSocket
712 } 735 }
713 } catch (Exception e) { 736 } catch (Exception e) {
714 log.warn("Unable to handle summary request due to {}", e.getMessage()); 737 log.warn("Unable to handle summary request due to {}", e.getMessage());
738 + log.debug("Boom!", e);
715 } 739 }
716 -
717 } 740 }
718 } 741 }
719 } 742 }
......
...@@ -146,7 +146,8 @@ ...@@ -146,7 +146,8 @@
146 U: [unpin, 'Unpin node (hover mouse over)'], 146 U: [unpin, 'Unpin node (hover mouse over)'],
147 R: [resetPanZoom, 'Reset pan / zoom'], 147 R: [resetPanZoom, 'Reset pan / zoom'],
148 V: [showRelatedIntentsAction, 'Show all related intents'], 148 V: [showRelatedIntentsAction, 'Show all related intents'],
149 - N: [showNextIntentAction, 'Show next related intent'], 149 + rightArrow: [showNextIntentAction, 'Show next related intent'],
150 + leftArrow: [showPrevIntentAction, 'Show previous related intent'],
150 W: [showSelectedIntentTrafficAction, 'Monitor traffic of selected intent'], 151 W: [showSelectedIntentTrafficAction, 'Monitor traffic of selected intent'],
151 A: [showAllTrafficAction, 'Monitor all traffic'], 152 A: [showAllTrafficAction, 'Monitor all traffic'],
152 F: [showDeviceLinkFlowsAction, 'Show device link flows'], 153 F: [showDeviceLinkFlowsAction, 'Show device link flows'],
...@@ -1232,7 +1233,7 @@ ...@@ -1232,7 +1233,7 @@
1232 function showRelatedIntentsAction() { 1233 function showRelatedIntentsAction() {
1233 hoverMode = hoverModeIntents; 1234 hoverMode = hoverModeIntents;
1234 requestRelatedIntents(); 1235 requestRelatedIntents();
1235 - flash('Related intents'); 1236 + flash('Related Paths');
1236 } 1237 }
1237 1238
1238 function requestRelatedIntents() { 1239 function requestRelatedIntents() {
...@@ -1252,14 +1253,20 @@ ...@@ -1252,14 +1253,20 @@
1252 1253
1253 function showNextIntentAction() { 1254 function showNextIntentAction() {
1254 hoverMode = hoverModeNone; 1255 hoverMode = hoverModeNone;
1255 - sendMessage('requestNextRelatedIntent', {}); 1256 + sendMessage('requestNextRelatedIntent');
1256 - flash('Next related intent'); 1257 + flash('>');
1258 + }
1259 +
1260 + function showPrevIntentAction() {
1261 + hoverMode = hoverModeNone;
1262 + sendMessage('requestPrevRelatedIntent');
1263 + flash('<');
1257 } 1264 }
1258 1265
1259 function showSelectedIntentTrafficAction() { 1266 function showSelectedIntentTrafficAction() {
1260 hoverMode = hoverModeNone; 1267 hoverMode = hoverModeNone;
1261 - sendMessage('requestSelectedIntentTraffic', {}); 1268 + sendMessage('requestSelectedIntentTraffic');
1262 - flash('Monitoring selected intent'); 1269 + flash('Traffic on Selected Path');
1263 } 1270 }
1264 1271
1265 function showDeviceLinkFlowsAction() { 1272 function showDeviceLinkFlowsAction() {
...@@ -3018,7 +3025,8 @@ ...@@ -3018,7 +3025,8 @@
3018 } 3025 }
3019 3026
3020 function startAntTimer() { 3027 function startAntTimer() {
3021 - if (!antTimer) { 3028 + // Note: disabled until traffic can be allotted to intents properly
3029 + if (false && !antTimer) {
3022 var pulses = [5, 3, 1.2, 3], 3030 var pulses = [5, 3, 1.2, 3],
3023 pulse = 0; 3031 pulse = 0;
3024 antTimer = setInterval(function () { 3032 antTimer = setInterval(function () {
......