ONOS-6259: Topo2 - Implement server-side highlighting model
- wiring in Traffic2Monitor calls
- added utility script to dynamically set debug level on Topo2 classes
Change-Id: Ie727de39739729e1c240ca0484ed08f020546dae
diff --git a/web/gui/logger.sh b/web/gui/logger.sh
new file mode 100755
index 0000000..13c5883
--- /dev/null
+++ b/web/gui/logger.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+host=${1:-localhost}
+
+### Set up debug log messages for classes we care about
+onos ${host} <<-EOF
+
+log:set DEBUG org.onosproject.ui.impl.topo.Topo2ViewMessageHandler
+log:set DEBUG org.onosproject.ui.impl.topo.Topo2Jsonifier
+log:set DEBUG org.onosproject.ui.impl.topo.Topo2TrafficMessageHandler
+log:set DEBUG org.onosproject.ui.impl.topo.Traffic2Monitor
+
+#log:set DEBUG org.onosproject.ui.impl.UiWebSocket
+#log:set DEBUG org.onosproject.ui.impl.UiTopoSession
+
+log:list
+
+EOF
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2TrafficMessageHandler.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2TrafficMessageHandler.java
index 6b72e89..2fa3701 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2TrafficMessageHandler.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2TrafficMessageHandler.java
@@ -23,6 +23,7 @@
import org.onosproject.ui.RequestHandler;
import org.onosproject.ui.UiConnection;
import org.onosproject.ui.UiMessageHandler;
+import org.onosproject.ui.impl.TrafficMonitorBase.Mode;
import org.onosproject.ui.impl.topo.util.ServicesBundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,7 +44,13 @@
// === Outbound event identifiers
private static final String HIGHLIGHTS = "topo2Highlights";
+ // field values
+ private static final String TRAFFIC_TYPE = "trafficType";
+ private static final String FLOW_STATS_BYTES = "flowStatsBytes";
+ private static final String PORT_STATS_BIT_SEC = "portStatsBitSec";
+ private static final String PORT_STATS_PKT_SEC = "portStatsPktSec";
+ // configuration parameters
private static final long TRAFFIC_PERIOD = 5000;
// private UiTopoSession topoSession;
@@ -62,6 +69,8 @@
services = new ServicesBundle(directory);
+ traffic = new Traffic2Monitor(TRAFFIC_PERIOD, services, this);
+
// get the topo session from the UiWebSocket
// topoSession = ((UiWebSocket) connection).topoSession();
// t2json = new Topo2Jsonifier(directory, connection.userName());
@@ -79,25 +88,27 @@
// ==================================================================
private final class Topo2AllTraffic extends RequestHandler {
+
private Topo2AllTraffic() {
super(REQUEST_ALL_TRAFFIC);
}
@Override
public void process(ObjectNode payload) {
- String mode = string(payload, "trafficType");
- log.debug("SHOW TRAFFIC: " + mode);
+ String mode = string(payload, TRAFFIC_TYPE);
+ log.debug("SHOW TRAFFIC: {}", mode);
+
switch (mode) {
- case "flowStatsBytes":
- // TODO: invoke traffic monitor for flow stats / bytes
+ case FLOW_STATS_BYTES:
+ traffic.monitor(Mode.ALL_FLOW_TRAFFIC_BYTES);
break;
- case "portStatsBitSec":
- // TODO: invoke traffic monitor for port stats / bps
+ case PORT_STATS_BIT_SEC:
+ traffic.monitor(Mode.ALL_PORT_TRAFFIC_BIT_PS);
break;
- case "portStatsPktSec":
- // TODO: invoke traffic monitor for port stats / pps
+ case PORT_STATS_PKT_SEC:
+ traffic.monitor(Mode.ALL_PORT_TRAFFIC_PKT_PS);
break;
default:
@@ -115,7 +126,7 @@
@Override
public void process(ObjectNode payload) {
log.debug("CANCEL TRAFFIC");
- // TODO: tell traffic monitor to quit monitoring traffic
+ traffic.stopMonitoring();
}
}
}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/Traffic2Monitor.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/Traffic2Monitor.java
index 7aedc48..cb91e0d 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/Traffic2Monitor.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/Traffic2Monitor.java
@@ -31,48 +31,56 @@
private static final Logger log =
LoggerFactory.getLogger(Traffic2Monitor.class);
+ private final Topo2TrafficMessageHandler msgHandler;
+
/**
* Constructs a traffic monitor.
*
- * @param trafficPeriod traffic task period in ms
+ * @param trafficPeriod traffic task period in ms
* @param servicesBundle bundle of services
+ * @param msgHandler our message handler
*/
- public Traffic2Monitor(long trafficPeriod, ServicesBundle servicesBundle) {
+ public Traffic2Monitor(long trafficPeriod, ServicesBundle servicesBundle,
+ Topo2TrafficMessageHandler msgHandler) {
super(trafficPeriod, servicesBundle);
+ this.msgHandler = msgHandler;
}
@Override
protected void sendAllFlowTraffic() {
+ log.debug("TOPO-2-TRAFFIC: sendAllFlowTraffic");
// TODO
}
@Override
protected void sendAllPortTrafficBits() {
+ log.debug("TOPO-2-TRAFFIC: sendAllPortTrafficBits");
// TODO
}
@Override
protected void sendAllPortTrafficPackets() {
+ log.debug("TOPO-2-TRAFFIC: sendAllPortTrafficPackets");
// TODO
}
@Override
- protected void sendDeviceLinkFlows() {
- // NOTE: currently this monitor holds no state - nothing to do
- }
-
- @Override
- protected void sendSelectedIntentTraffic() {
- // NOTE: currently this monitor holds no state - nothing to do
- }
-
- @Override
protected void sendClearHighlights() {
+ log.debug("TOPO-2-TRAFFIC: sendClearHighlights");
// TODO
}
+
+ // NOTE: currently this monitor holds no state - nothing to do for these...
+ @Override
+ protected void sendDeviceLinkFlows() {
+ }
+
+ @Override
+ protected void sendSelectedIntentTraffic() {
+ }
+
@Override
protected void clearSelection() {
- // NOTE: currently this monitor holds no state - nothing to do
}
}