ONOS-245 Adding more polish and capability to the GUI.
Change-Id: I20cfd48f10de5f053d0c00dc1460d85d5c0d22de
diff --git a/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewIntentFilter.java b/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewIntentFilter.java
new file mode 100644
index 0000000..0f9a29b
--- /dev/null
+++ b/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewIntentFilter.java
@@ -0,0 +1,250 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onlab.onos.gui;
+
+import org.onlab.onos.net.ConnectPoint;
+import org.onlab.onos.net.Device;
+import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.net.Host;
+import org.onlab.onos.net.HostId;
+import org.onlab.onos.net.Link;
+import org.onlab.onos.net.device.DeviceService;
+import org.onlab.onos.net.host.HostService;
+import org.onlab.onos.net.intent.HostToHostIntent;
+import org.onlab.onos.net.intent.Intent;
+import org.onlab.onos.net.intent.IntentService;
+import org.onlab.onos.net.intent.LinkCollectionIntent;
+import org.onlab.onos.net.intent.MultiPointToSinglePointIntent;
+import org.onlab.onos.net.intent.OpticalConnectivityIntent;
+import org.onlab.onos.net.intent.PathIntent;
+import org.onlab.onos.net.intent.PointToPointIntent;
+import org.onlab.onos.net.link.LinkService;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.onlab.onos.net.intent.IntentState.INSTALLED;
+
+/**
+ * Auxiliary facility to query the intent service based on the specified
+ * set of end-station hosts, edge points or infrastructure devices.
+ */
+public class TopologyViewIntentFilter {
+
+ private final IntentService intentService;
+ private final DeviceService deviceService;
+ private final HostService hostService;
+ private final LinkService linkService;
+
+ /**
+ * Crreates an intent filter.
+ *
+ * @param intentService intent service reference
+ * @param deviceService device service reference
+ * @param hostService host service reference
+ * @param linkService link service reference
+ */
+ TopologyViewIntentFilter(IntentService intentService,
+ DeviceService deviceService,
+ HostService hostService, LinkService linkService) {
+ this.intentService = intentService;
+ this.deviceService = deviceService;
+ this.hostService = hostService;
+ this.linkService = linkService;
+ }
+
+ /**
+ * Finds all path (host-to-host or point-to-point) intents that pertains
+ * to the given hosts.
+ *
+ * @param hosts set of hosts to query by
+ * @param devices set of devices to query by
+ * @return set of intents that 'match' all hosts and devices given
+ */
+ Set<Intent> findPathIntents(Set<Host> hosts, Set<Device> devices) {
+ // Derive from this the set of edge connect points.
+ Set<ConnectPoint> edgePoints = getEdgePoints(hosts);
+
+ // Iterate over all intents and produce a set that contains only those
+ // intents that target all selected hosts or derived edge connect points.
+ return getIntents(hosts, devices, edgePoints);
+ }
+
+
+ // Produces a set of edge points from the specified set of hosts.
+ private Set<ConnectPoint> getEdgePoints(Set<Host> hosts) {
+ Set<ConnectPoint> edgePoints = new HashSet<>();
+ for (Host host : hosts) {
+ edgePoints.add(host.location());
+ }
+ return edgePoints;
+ }
+
+ // Produces a set of intents that target all selected hosts, devices or connect points.
+ private Set<Intent> getIntents(Set<Host> hosts, Set<Device> devices,
+ Set<ConnectPoint> edgePoints) {
+ Set<Intent> intents = new HashSet<>();
+ if (hosts.isEmpty() && devices.isEmpty()) {
+ return intents;
+ }
+
+ Set<OpticalConnectivityIntent> opticalIntents = new HashSet<>();
+
+ // Search through all intents and see if they are relevant to our search.
+ for (Intent intent : intentService.getIntents()) {
+ if (intentService.getIntentState(intent.id()) == INSTALLED) {
+ boolean isRelevant = false;
+ if (intent instanceof HostToHostIntent) {
+ isRelevant = isIntentRelevantToHosts((HostToHostIntent) intent, hosts) &&
+ isIntentRelevantToDevices(intent, devices);
+ } else if (intent instanceof PointToPointIntent) {
+ isRelevant = isIntentRelevant((PointToPointIntent) intent, edgePoints) &&
+ isIntentRelevantToDevices(intent, devices);
+ } else if (intent instanceof MultiPointToSinglePointIntent) {
+ isRelevant = isIntentRelevant((MultiPointToSinglePointIntent) intent, edgePoints) &&
+ isIntentRelevantToDevices(intent, devices);
+ } else if (intent instanceof OpticalConnectivityIntent) {
+ opticalIntents.add((OpticalConnectivityIntent) intent);
+ }
+ // TODO: add other intents, e.g. SinglePointToMultiPointIntent
+
+ if (isRelevant) {
+ intents.add(intent);
+ }
+ }
+ }
+
+ // As a second pass, try to link up any optical intents with the
+ // packet-level ones.
+ for (OpticalConnectivityIntent intent : opticalIntents) {
+ if (isIntentRelevant(intent, intents) &&
+ isIntentRelevantToDevices(intent, devices)) {
+ intents.add(intent);
+ }
+ }
+ return intents;
+ }
+
+ // Indicates whether the specified intent involves all of the given hosts.
+ private boolean isIntentRelevantToHosts(HostToHostIntent intent, Set<Host> hosts) {
+ for (Host host : hosts) {
+ HostId id = host.id();
+ // Bail if intent does not involve this host.
+ if (!id.equals(intent.one()) && !id.equals(intent.two())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // Indicates whether the specified intent involves all of the given devices.
+ private boolean isIntentRelevantToDevices(Intent intent, Set<Device> devices) {
+ List<Intent> installables = intentService.getInstallableIntents(intent.id());
+ for (Device device : devices) {
+ if (!isIntentRelevantToDevice(installables, device)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // Indicates whether the specified intent involves the given device.
+ private boolean isIntentRelevantToDevice(List<Intent> installables, Device device) {
+ for (Intent installable : installables) {
+ if (installable instanceof PathIntent) {
+ PathIntent pathIntent = (PathIntent) installable;
+ if (pathContainsDevice(pathIntent.path().links(), device.id())) {
+ return true;
+ }
+ } else if (installable instanceof LinkCollectionIntent) {
+ LinkCollectionIntent linksIntent = (LinkCollectionIntent) installable;
+ if (pathContainsDevice(linksIntent.links(), device.id())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ // Indicates whether the specified intent involves the given device.
+ private boolean pathContainsDevice(Iterable<Link> links, DeviceId id) {
+ for (Link link : links) {
+ if (link.src().elementId().equals(id) || link.dst().elementId().equals(id)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isIntentRelevant(PointToPointIntent intent, Set<ConnectPoint> edgePoints) {
+ for (ConnectPoint point : edgePoints) {
+ // Bail if intent does not involve this edge point.
+ if (!point.equals(intent.egressPoint()) &&
+ !point.equals(intent.ingressPoint())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // Indicates whether the specified intent involves all of the given edge points.
+ private boolean isIntentRelevant(MultiPointToSinglePointIntent intent,
+ Set<ConnectPoint> edgePoints) {
+ for (ConnectPoint point : edgePoints) {
+ // Bail if intent does not involve this edge point.
+ if (!point.equals(intent.egressPoint()) &&
+ !intent.ingressPoints().contains(point)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // Indicates whether the specified intent involves all of the given edge points.
+ private boolean isIntentRelevant(OpticalConnectivityIntent opticalIntent,
+ Set<Intent> intents) {
+ Link ccSrc = getFirstLink(opticalIntent.getSrc(), false);
+ Link ccDst = getFirstLink(opticalIntent.getDst(), true);
+
+ for (Intent intent : intents) {
+ List<Intent> installables = intentService.getInstallableIntents(intent.id());
+ for (Intent installable : installables) {
+ if (installable instanceof PathIntent) {
+ List<Link> links = ((PathIntent) installable).path().links();
+ if (links.size() == 3) {
+ Link tunnel = links.get(1);
+ if (tunnel.src().equals(ccSrc.src()) &&
+ tunnel.dst().equals(ccDst.dst())) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ private Link getFirstLink(ConnectPoint point, boolean ingress) {
+ for (Link link : linkService.getLinks(point)) {
+ if (point.equals(ingress ? link.src() : link.dst())) {
+ return link;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewMessages.java b/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewMessages.java
index e99749e..3084c5f 100644
--- a/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewMessages.java
+++ b/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewMessages.java
@@ -35,7 +35,6 @@
import org.onlab.onos.net.HostId;
import org.onlab.onos.net.HostLocation;
import org.onlab.onos.net.Link;
-import org.onlab.onos.net.Path;
import org.onlab.onos.net.device.DeviceEvent;
import org.onlab.onos.net.device.DeviceService;
import org.onlab.onos.net.host.HostEvent;
@@ -57,6 +56,7 @@
import org.slf4j.LoggerFactory;
import java.text.DecimalFormat;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -68,6 +68,8 @@
import static org.onlab.onos.cluster.ClusterEvent.Type.INSTANCE_ADDED;
import static org.onlab.onos.cluster.ClusterEvent.Type.INSTANCE_REMOVED;
import static org.onlab.onos.cluster.ControllerNode.State.ACTIVE;
+import static org.onlab.onos.net.DeviceId.deviceId;
+import static org.onlab.onos.net.HostId.hostId;
import static org.onlab.onos.net.PortNumber.portNumber;
import static org.onlab.onos.net.device.DeviceEvent.Type.DEVICE_ADDED;
import static org.onlab.onos.net.device.DeviceEvent.Type.DEVICE_REMOVED;
@@ -95,6 +97,8 @@
private static final String KB_UNIT = "KB";
private static final String B_UNIT = "B";
+ private static final String ANIMATED = "animated";
+
protected final ServiceDirectory directory;
protected final ClusterService clusterService;
protected final DeviceService deviceService;
@@ -196,6 +200,64 @@
return event;
}
+ // Produces a set of all hosts listed in the specified JSON array.
+ protected Set<Host> getHosts(ArrayNode array) {
+ Set<Host> hosts = new HashSet<>();
+ if (array != null) {
+ for (JsonNode node : array) {
+ try {
+ addHost(hosts, hostId(node.asText()));
+ } catch (IllegalArgumentException e) {
+ log.debug("Skipping ID {}", node.asText());
+ }
+ }
+ }
+ return hosts;
+ }
+
+ // Adds the specified host to the set of hosts.
+ private void addHost(Set<Host> hosts, HostId hostId) {
+ Host host = hostService.getHost(hostId);
+ if (host != null) {
+ hosts.add(host);
+ }
+ }
+
+
+ // Produces a set of all devices listed in the specified JSON array.
+ protected Set<Device> getDevices(ArrayNode array) {
+ Set<Device> devices = new HashSet<>();
+ if (array != null) {
+ for (JsonNode node : array) {
+ try {
+ addDevice(devices, deviceId(node.asText()));
+ } catch (IllegalArgumentException e) {
+ log.debug("Skipping ID {}", node.asText());
+ }
+ }
+ }
+ return devices;
+ }
+
+ private void addDevice(Set<Device> devices, DeviceId deviceId) {
+ Device device = deviceService.getDevice(deviceId);
+ if (device != null) {
+ devices.add(device);
+ }
+ }
+
+ protected void addHover(Set<Host> hosts, Set<Device> devices, String hover) {
+ try {
+ addHost(hosts, hostId(hover));
+ } catch (IllegalArgumentException e) {
+ try {
+ addDevice(devices, deviceId(hover));
+ } catch (IllegalArgumentException ne) {
+ log.debug("Skipping ID {}", hover);
+ }
+ }
+ }
+
// Produces a cluster instance message to the client.
protected ObjectNode instanceMessage(ClusterEvent event) {
ControllerNode node = event.subject();
@@ -382,16 +444,18 @@
new Prop("Longitude", annot.value("longitude"))));
}
- // Produces a path payload to the client.
- protected ObjectNode pathMessage(Path path, String type) {
- ObjectNode payload = mapper.createObjectNode();
- ArrayNode links = mapper.createArrayNode();
- for (Link link : path.links()) {
- links.add(compactLinkString(link));
- }
- payload.put("type", type).set("links", links);
- return payload;
+ // Produces JSON message to trigger traffic overview visualization
+ protected ObjectNode trafficSummaryMessage(long sid) {
+ ObjectNode payload = mapper.createObjectNode();
+ ArrayNode paths = mapper.createArrayNode();
+ payload.set("paths", paths);
+ for (Link link : linkService.getLinks()) {
+ Set<Link> links = new HashSet<>();
+ links.add(link);
+ addPathTraffic(paths, "plain", "secondary", links);
+ }
+ return envelope("showTraffic", sid, payload);
}
@@ -409,11 +473,14 @@
for (Intent installable : installables) {
String cls = isOptical ? trafficClass.type + " optical" : trafficClass.type;
if (installable instanceof PathIntent) {
- addPathTraffic(paths, cls, ((PathIntent) installable).path().links());
+ addPathTraffic(paths, cls, ANIMATED,
+ ((PathIntent) installable).path().links());
} else if (installable instanceof LinkCollectionIntent) {
- addPathTraffic(paths, cls, ((LinkCollectionIntent) installable).links());
+ addPathTraffic(paths, cls, ANIMATED,
+ ((LinkCollectionIntent) installable).links());
} else if (installable instanceof OpticalPathIntent) {
- addPathTraffic(paths, cls, ((OpticalPathIntent) installable).path().links());
+ addPathTraffic(paths, cls, ANIMATED,
+ ((OpticalPathIntent) installable).path().links());
}
}
@@ -426,7 +493,8 @@
// Adds the link segments (path or tree) associated with the specified
// connectivity intent
- protected void addPathTraffic(ArrayNode paths, String type, Iterable<Link> links) {
+ protected void addPathTraffic(ArrayNode paths, String type, String trafficType,
+ Iterable<Link> links) {
ObjectNode pathNode = mapper.createObjectNode();
ArrayNode linksNode = mapper.createArrayNode();
@@ -445,7 +513,7 @@
labels.add(label);
}
}
- pathNode.put("class", hasTraffic ? type + " animated" : type);
+ pathNode.put("class", hasTraffic ? type + " " + trafficType : type);
pathNode.put("traffic", hasTraffic);
pathNode.set("links", linksNode);
pathNode.set("labels", labels);
diff --git a/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewWebSocket.java b/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewWebSocket.java
index 935ba79..99e9aeb 100644
--- a/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewWebSocket.java
+++ b/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewWebSocket.java
@@ -15,7 +15,6 @@
*/
package org.onlab.onos.gui;
-import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.eclipse.jetty.websocket.WebSocket;
@@ -24,7 +23,6 @@
import org.onlab.onos.cluster.ControllerNode;
import org.onlab.onos.core.ApplicationId;
import org.onlab.onos.core.CoreService;
-import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.Device;
import org.onlab.onos.net.Host;
import org.onlab.onos.net.HostId;
@@ -39,17 +37,11 @@
import org.onlab.onos.net.intent.Intent;
import org.onlab.onos.net.intent.IntentEvent;
import org.onlab.onos.net.intent.IntentListener;
-import org.onlab.onos.net.intent.MultiPointToSinglePointIntent;
-import org.onlab.onos.net.intent.OpticalConnectivityIntent;
-import org.onlab.onos.net.intent.PathIntent;
-import org.onlab.onos.net.intent.PointToPointIntent;
import org.onlab.onos.net.link.LinkEvent;
import org.onlab.onos.net.link.LinkListener;
import org.onlab.osgi.ServiceDirectory;
import java.io.IOException;
-import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
@@ -60,7 +52,6 @@
import static org.onlab.onos.net.HostId.hostId;
import static org.onlab.onos.net.device.DeviceEvent.Type.DEVICE_ADDED;
import static org.onlab.onos.net.host.HostEvent.Type.HOST_ADDED;
-import static org.onlab.onos.net.intent.IntentState.INSTALLED;
import static org.onlab.onos.net.link.LinkEvent.Type.LINK_ADDED;
/**
@@ -99,6 +90,8 @@
private long lastActive = System.currentTimeMillis();
private boolean listenersRemoved = false;
+ private TopologyViewIntentFilter intentFilter;
+
/**
* Creates a new web-socket for serving data to GUI topology view.
*
@@ -106,6 +99,9 @@
*/
public TopologyViewWebSocket(ServiceDirectory directory) {
super(directory);
+
+ intentFilter = new TopologyViewIntentFilter(intentService, deviceService,
+ hostService, linkService);
appId = directory.get(CoreService.class).registerApplication(APP_ID);
}
@@ -168,24 +164,30 @@
public void onMessage(String data) {
lastActive = System.currentTimeMillis();
try {
- ObjectNode event = (ObjectNode) mapper.reader().readTree(data);
- String type = string(event, "event", "unknown");
- if (type.equals("requestDetails")) {
- requestDetails(event);
- } else if (type.equals("updateMeta")) {
- updateMetaUi(event);
- } else if (type.equals("addHostIntent")) {
- createHostIntent(event);
- } else if (type.equals("requestTraffic")) {
- requestTraffic(event);
- } else if (type.equals("cancelTraffic")) {
- cancelTraffic(event);
- }
+ processMessage((ObjectNode) mapper.reader().readTree(data));
} catch (Exception e) {
log.warn("Unable to parse GUI request {} due to {}", data, e);
}
}
+ // Processes the specified event.
+ private void processMessage(ObjectNode event) {
+ String type = string(event, "event", "unknown");
+ if (type.equals("requestDetails")) {
+ requestDetails(event);
+ } else if (type.equals("updateMeta")) {
+ updateMetaUi(event);
+ } else if (type.equals("addHostIntent")) {
+ createHostIntent(event);
+ } else if (type.equals("requestTraffic")) {
+ requestTraffic(event);
+ } else if (type.equals("requestAllTraffic")) {
+ requestAllTraffic(event);
+ } else if (type.equals("cancelTraffic")) {
+ cancelTraffic(event);
+ }
+ }
+
// Sends the specified data to the client.
private synchronized void sendMessage(ObjectNode data) {
try {
@@ -253,22 +255,36 @@
intentService.submit(hostIntent);
}
- // Sends traffic message.
+ // Subscribes for host traffic messages.
+ private synchronized void requestAllTraffic(ObjectNode event) {
+ ObjectNode payload = payload(event);
+ long sid = number(event, "sid");
+ monitorRequest = event;
+ sendMessage(trafficSummaryMessage(sid));
+ }
+
+ // Subscribes for host traffic messages.
private synchronized void requestTraffic(ObjectNode event) {
ObjectNode payload = payload(event);
+ if (!payload.has("ids")) {
+ return;
+ }
+
long sid = number(event, "sid");
monitorRequest = event;
// Get the set of selected hosts and their intents.
- Set<Host> hosts = getHosts((ArrayNode) payload.path("ids"));
- Set<Intent> intents = findPathIntents(hosts);
+ ArrayNode ids = (ArrayNode) payload.path("ids");
+ Set<Host> hosts = getHosts(ids);
+ Set<Device> devices = getDevices(ids);
+ Set<Intent> intents = intentFilter.findPathIntents(hosts, devices);
// If there is a hover node, include it in the hosts and find intents.
String hover = string(payload, "hover");
Set<Intent> hoverIntents;
if (!isNullOrEmpty(hover)) {
- addHost(hosts, hostId(hover));
- hoverIntents = findPathIntents(hosts);
+ addHover(hosts, devices, hover);
+ hoverIntents = intentFilter.findPathIntents(hosts, devices);
intents.removeAll(hoverIntents);
// Send an initial message to highlight all links of all monitored intents.
@@ -288,157 +304,6 @@
monitorRequest = null;
}
- // Finds all path (host-to-host or point-to-point) intents that pertains
- // to the given hosts.
- private Set<Intent> findPathIntents(Set<Host> hosts) {
- // Derive from this the set of edge connect points.
- Set<ConnectPoint> edgePoints = getEdgePoints(hosts);
-
- // Iterate over all intents and produce a set that contains only those
- // intents that target all selected hosts or derived edge connect points.
- return getIntents(hosts, edgePoints);
- }
-
- // Produces a set of intents that target all selected hosts or connect points.
- private Set<Intent> getIntents(Set<Host> hosts, Set<ConnectPoint> edgePoints) {
- Set<Intent> intents = new HashSet<>();
- if (hosts.isEmpty()) {
- return intents;
- }
-
- Set<OpticalConnectivityIntent> opticalIntents = new HashSet<>();
-
- for (Intent intent : intentService.getIntents()) {
- if (intentService.getIntentState(intent.id()) == INSTALLED) {
- boolean isRelevant = false;
- if (intent instanceof HostToHostIntent) {
- isRelevant = isIntentRelevant((HostToHostIntent) intent, hosts);
- } else if (intent instanceof PointToPointIntent) {
- isRelevant = isIntentRelevant((PointToPointIntent) intent, edgePoints);
- } else if (intent instanceof MultiPointToSinglePointIntent) {
- isRelevant = isIntentRelevant((MultiPointToSinglePointIntent) intent, edgePoints);
- } else if (intent instanceof OpticalConnectivityIntent) {
- opticalIntents.add((OpticalConnectivityIntent) intent);
- }
- // TODO: add other intents, e.g. SinglePointToMultiPointIntent
-
- if (isRelevant) {
- intents.add(intent);
- }
- }
- }
-
- for (OpticalConnectivityIntent intent : opticalIntents) {
- if (isIntentRelevant(intent, intents)) {
- intents.add(intent);
- }
- }
- return intents;
- }
-
- // Indicates whether the specified intent involves all of the given hosts.
- private boolean isIntentRelevant(HostToHostIntent intent, Set<Host> hosts) {
- for (Host host : hosts) {
- HostId id = host.id();
- // Bail if intent does not involve this host.
- if (!id.equals(intent.one()) && !id.equals(intent.two())) {
- return false;
- }
- }
- return true;
- }
-
- // Indicates whether the specified intent involves all of the given edge points.
- private boolean isIntentRelevant(PointToPointIntent intent,
- Set<ConnectPoint> edgePoints) {
- for (ConnectPoint point : edgePoints) {
- // Bail if intent does not involve this edge point.
- if (!point.equals(intent.egressPoint()) &&
- !point.equals(intent.ingressPoint())) {
- return false;
- }
- }
- return true;
- }
-
- // Indicates whether the specified intent involves all of the given edge points.
- private boolean isIntentRelevant(MultiPointToSinglePointIntent intent,
- Set<ConnectPoint> edgePoints) {
- for (ConnectPoint point : edgePoints) {
- // Bail if intent does not involve this edge point.
- if (!point.equals(intent.egressPoint()) &&
- !intent.ingressPoints().contains(point)) {
- return false;
- }
- }
- return true;
- }
-
- // Indicates whether the specified intent involves all of the given edge points.
- private boolean isIntentRelevant(OpticalConnectivityIntent opticalIntent,
- Set<Intent> intents) {
- Link ccSrc = getFirstLink(opticalIntent.getSrc(), false);
- Link ccDst = getFirstLink(opticalIntent.getDst(), true);
-
- for (Intent intent : intents) {
- List<Intent> installables = intentService.getInstallableIntents(intent.id());
- for (Intent installable : installables) {
- if (installable instanceof PathIntent) {
- List<Link> links = ((PathIntent) installable).path().links();
- if (links.size() == 3) {
- Link tunnel = links.get(1);
- if (tunnel.src().equals(ccSrc.src()) &&
- tunnel.dst().equals(ccDst.dst())) {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
-
- private Link getFirstLink(ConnectPoint point, boolean ingress) {
- for (Link link : linkService.getLinks(point)) {
- if (point.equals(ingress ? link.src() : link.dst())) {
- return link;
- }
- }
- return null;
- }
-
- // Produces a set of all host ids listed in the specified JSON array.
- private Set<Host> getHosts(ArrayNode array) {
- Set<Host> hosts = new HashSet<>();
- if (array != null) {
- for (JsonNode node : array) {
- try {
- addHost(hosts, hostId(node.asText()));
- } catch (IllegalArgumentException e) {
- log.debug("Skipping ID {}", node.asText());
- }
- }
- }
- return hosts;
- }
-
- private void addHost(Set<Host> hosts, HostId hostId) {
- Host host = hostService.getHost(hostId);
- if (host != null) {
- hosts.add(host);
- }
- }
-
- // Produces a set of edge points from the specified set of hosts.
- private Set<ConnectPoint> getEdgePoints(Set<Host> hosts) {
- Set<ConnectPoint> edgePoints = new HashSet<>();
- for (Host host : hosts) {
- edgePoints.add(host.location());
- }
- return edgePoints;
- }
-
-
// Adds all internal listeners.
private void addListeners() {
clusterService.addListener(clusterListener);
@@ -506,7 +371,12 @@
@Override
public void run() {
if (monitorRequest != null) {
- requestTraffic(monitorRequest);
+ String type = string(monitorRequest, "event", "unknown");
+ if (type.equals("requestAllTraffic")) {
+ requestAllTraffic(monitorRequest);
+ } else {
+ requestTraffic(monitorRequest);
+ }
}
}
}
diff --git a/web/gui/src/main/webapp/topo2.css b/web/gui/src/main/webapp/topo2.css
index 45377b1..0514a6f 100644
--- a/web/gui/src/main/webapp/topo2.css
+++ b/web/gui/src/main/webapp/topo2.css
@@ -135,28 +135,26 @@
stroke-dasharray: 8 4;
}
-#topo svg .link.primary {
- stroke: #ffA300;
- stroke-width: 4px;
-}
#topo svg .link.secondary {
stroke: rgba(0,153,51,0.5);
stroke-width: 3px;
}
+#topo svg .link.primary {
+ stroke: #ffA300;
+ stroke-width: 4px;
+}
#topo svg .link.animated {
stroke: #ffA300;
- Xstroke-width: 6px;
- Xstroke-dasharray: 8 8
}
-#topo svg .link.primary.optical {
- stroke: #74f;
- stroke-width: 6px;
-}
#topo svg .link.secondary.optical {
stroke: rgba(128,64,255,0.5);
stroke-width: 4px;
}
+#topo svg .link.primary.optical {
+ stroke: #74f;
+ stroke-width: 6px;
+}
#topo svg .link.animated.optical {
stroke: #74f;
stroke-width: 10px;
@@ -164,8 +162,6 @@
}
#topo svg .linkLabel rect {
- Xstroke: #ccc;
- Xstroke-width: 2px;
fill: #eee;
stroke: none;
}
diff --git a/web/gui/src/main/webapp/topo2.js b/web/gui/src/main/webapp/topo2.js
index 2a36dfd..e9a8c1e 100644
--- a/web/gui/src/main/webapp/topo2.js
+++ b/web/gui/src/main/webapp/topo2.js
@@ -141,6 +141,8 @@
U: unpin,
R: resetZoomPan,
H: toggleHover,
+ V: showTrafficAction,
+ A: showAllTrafficAction,
esc: handleEscape
};
@@ -832,8 +834,9 @@
}
// NOTE: hover is only populated if "show traffic on hover" is
- // toggled on, and the item hovered is a host...
- var hoverId = (trafficHover() && hovered && hovered.class === 'host')
+ // toggled on, and the item hovered is a host or a device...
+ var hoverId = (trafficHover() && hovered &&
+ (hovered.class === 'host' || hovered.class === 'device'))
? hovered.id : '';
sendMessage('requestTraffic', {
ids: selectOrder,
@@ -841,6 +844,10 @@
});
}
+ function showAllTrafficAction() {
+ sendMessage('requestAllTraffic', {});
+ }
+
// ==============================
// onos instance panel functions
@@ -1367,14 +1374,14 @@
function nodeMouseOver(d) {
hovered = d;
- if (trafficHover() && d.class === 'host') {
+ if (trafficHover() && (d.class === 'host' || d.class === 'device')) {
showTrafficAction();
}
}
function nodeMouseOut(d) {
hovered = null;
- if (trafficHover() && d.class === 'host') {
+ if (trafficHover() && (d.class === 'host' || d.class === 'device')) {
showTrafficAction();
}
}