GUI - Topologies - refactoring of ServicesBundle.
Jira: ONOS-6259
- also fixed bug where edge links were being omitted.
Change-Id: I19ac83d09ce7930de7a927fb2754e0c5004705f2
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 8a6ec8b..6b72e89 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.topo.util.ServicesBundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,13 +43,25 @@
// === Outbound event identifiers
private static final String HIGHLIGHTS = "topo2Highlights";
+
+ private static final long TRAFFIC_PERIOD = 5000;
+
// private UiTopoSession topoSession;
// private Topo2Jsonifier t2json;
+ protected ServicesBundle services;
+ private String version;
+
+
+ private Traffic2Monitor traffic;
+
+
@Override
public void init(UiConnection connection, ServiceDirectory directory) {
super.init(connection, directory);
+ services = new ServicesBundle(directory);
+
// get the topo session from the UiWebSocket
// topoSession = ((UiWebSocket) connection).topoSession();
// t2json = new Topo2Jsonifier(directory, connection.userName());
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
new file mode 100644
index 0000000..7aedc48
--- /dev/null
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/Traffic2Monitor.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2017-present 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.onosproject.ui.impl.topo;
+
+import org.onosproject.ui.impl.TrafficMonitorBase;
+import org.onosproject.ui.impl.topo.util.ServicesBundle;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Encapsulates the behavior of monitoring specific traffic patterns in the
+ * Topology-2 view.
+ */
+public class Traffic2Monitor extends TrafficMonitorBase {
+
+ private static final Logger log =
+ LoggerFactory.getLogger(Traffic2Monitor.class);
+
+ /**
+ * Constructs a traffic monitor.
+ *
+ * @param trafficPeriod traffic task period in ms
+ * @param servicesBundle bundle of services
+ */
+ public Traffic2Monitor(long trafficPeriod, ServicesBundle servicesBundle) {
+ super(trafficPeriod, servicesBundle);
+ }
+
+ @Override
+ protected void sendAllFlowTraffic() {
+ // TODO
+ }
+
+ @Override
+ protected void sendAllPortTrafficBits() {
+ // TODO
+ }
+
+ @Override
+ protected void 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() {
+ // TODO
+ }
+
+ @Override
+ protected void clearSelection() {
+ // NOTE: currently this monitor holds no state - nothing to do
+ }
+}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/ServicesBundle.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/ServicesBundle.java
index 13bf1c2..aa20990 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/ServicesBundle.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/ServicesBundle.java
@@ -16,63 +16,83 @@
package org.onosproject.ui.impl.topo.util;
+import org.onlab.osgi.ServiceDirectory;
+import org.onosproject.cluster.ClusterService;
import org.onosproject.incubator.net.PortStatisticsService;
+import org.onosproject.incubator.net.tunnel.TunnelService;
+import org.onosproject.mastership.MastershipAdminService;
+import org.onosproject.mastership.MastershipService;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.flow.FlowRuleService;
import org.onosproject.net.host.HostService;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.link.LinkService;
import org.onosproject.net.statistic.StatisticService;
+import org.onosproject.net.topology.TopologyService;
import static com.google.common.base.Preconditions.checkNotNull;
/**
- * A bundle of services that the topology view requires to get its job done.
+ * A bundle of services that the topology view(s) require to get the job done.
*/
public class ServicesBundle {
- private final IntentService intentService;
- private final DeviceService deviceService;
- private final HostService hostService;
- private final LinkService linkService;
- private final FlowRuleService flowService;
- private final StatisticService flowStatsService;
- private final PortStatisticsService portStatsService;
+ private ClusterService clusterService;
+
+ private TopologyService topologyService;
+ private DeviceService deviceService;
+ private HostService hostService;
+ private LinkService linkService;
+ private TunnelService tunnelService;
+
+ private MastershipService mastershipService;
+ private MastershipAdminService mastershipAdminService;
+ private IntentService intentService;
+ private FlowRuleService flowService;
+ private StatisticService flowStatsService;
+ private PortStatisticsService portStatsService;
+
/**
- * Creates the services bundle.
+ * Creates the services bundle, from the given directly.
*
- * @param intentService intent service reference
- * @param deviceService device service reference
- * @param hostService host service reference
- * @param linkService link service reference
- * @param flowService flow service reference
- * @param flowStatsService flow statistics service reference
- * @param portStatsService port statistics service reference
+ * @param directory service directory
*/
- public ServicesBundle(IntentService intentService,
- DeviceService deviceService,
- HostService hostService,
- LinkService linkService,
- FlowRuleService flowService,
- StatisticService flowStatsService,
- PortStatisticsService portStatsService) {
- this.intentService = checkNotNull(intentService);
- this.deviceService = checkNotNull(deviceService);
- this.hostService = checkNotNull(hostService);
- this.linkService = checkNotNull(linkService);
- this.flowService = checkNotNull(flowService);
- this.flowStatsService = checkNotNull(flowStatsService);
- this.portStatsService = checkNotNull(portStatsService);
+ public ServicesBundle(ServiceDirectory directory) {
+ checkNotNull(directory, "Directory cannot be null");
+
+ clusterService = directory.get(ClusterService.class);
+
+ topologyService = directory.get(TopologyService.class);
+ deviceService = directory.get(DeviceService.class);
+ hostService = directory.get(HostService.class);
+ linkService = directory.get(LinkService.class);
+ tunnelService = directory.get(TunnelService.class);
+
+ mastershipService = directory.get(MastershipService.class);
+ mastershipAdminService = directory.get(MastershipAdminService.class);
+ intentService = directory.get(IntentService.class);
+ flowService = directory.get(FlowRuleService.class);
+ flowStatsService = directory.get(StatisticService.class);
+ portStatsService = directory.get(PortStatisticsService.class);
}
/**
- * Returns a reference to the intent service.
+ * Returns a reference to the cluster service.
*
- * @return intent service reference
+ * @return cluster service reference
*/
- public IntentService intentService() {
- return intentService;
+ public ClusterService cluster() {
+ return clusterService;
+ }
+
+ /**
+ * Returns a reference to the topology service.
+ *
+ * @return topology service reference
+ */
+ public TopologyService topology() {
+ return topologyService;
}
/**
@@ -80,7 +100,7 @@
*
* @return device service reference
*/
- public DeviceService deviceService() {
+ public DeviceService device() {
return deviceService;
}
@@ -89,7 +109,7 @@
*
* @return host service reference
*/
- public HostService hostService() {
+ public HostService host() {
return hostService;
}
@@ -98,16 +118,52 @@
*
* @return link service reference
*/
- public LinkService linkService() {
+ public LinkService link() {
return linkService;
}
/**
+ * Returns a reference to the tunnel service.
+ *
+ * @return tunnel service reference
+ */
+ public TunnelService tunnel() {
+ return tunnelService;
+ }
+
+ /**
+ * Returns a reference to the mastership service.
+ *
+ * @return mastership service reference
+ */
+ public MastershipService mastership() {
+ return mastershipService;
+ }
+
+ /**
+ * Returns a reference to the mastership admin service.
+ *
+ * @return mastership admin service reference
+ */
+ public MastershipAdminService mastershipAdmin() {
+ return mastershipAdminService;
+ }
+
+ /**
+ * Returns a reference to the intent service.
+ *
+ * @return intent service reference
+ */
+ public IntentService intent() {
+ return intentService;
+ }
+
+ /**
* Returns a reference to the flow rule service.
*
* @return flow service reference
*/
- public FlowRuleService flowService() {
+ public FlowRuleService flow() {
return flowService;
}
@@ -116,7 +172,7 @@
*
* @return flow statistics service reference
*/
- public StatisticService flowStatsService() {
+ public StatisticService flowStats() {
return flowStatsService;
}
@@ -125,7 +181,7 @@
*
* @return port statistics service reference
*/
- public PortStatisticsService portStatsService() {
+ public PortStatisticsService portStats() {
return portStatsService;
}
}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TopoIntentFilter.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TopoIntentFilter.java
index e43fbf2..1dbe8f3 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TopoIntentFilter.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/TopoIntentFilter.java
@@ -21,9 +21,7 @@
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
import org.onosproject.net.Link;
-import org.onosproject.net.device.DeviceService;
import org.onosproject.net.flow.FlowRule;
-import org.onosproject.net.host.HostService;
import org.onosproject.net.intent.FlowObjectiveIntent;
import org.onosproject.net.intent.FlowRuleIntent;
import org.onosproject.net.intent.HostToHostIntent;
@@ -52,8 +50,6 @@
public class TopoIntentFilter {
private final IntentService intentService;
- private final DeviceService deviceService;
- private final HostService hostService;
private final LinkService linkService;
/**
@@ -62,19 +58,17 @@
* @param services service references bundle
*/
public TopoIntentFilter(ServicesBundle services) {
- this.intentService = services.intentService();
- this.deviceService = services.deviceService();
- this.hostService = services.hostService();
- this.linkService = services.linkService();
+ this.intentService = services.intent();
+ this.linkService = services.link();
}
/**
* Finds all path (host-to-host or point-to-point) intents that pertain
* to the given hosts and devices.
*
- * @param hosts set of hosts to query by
- * @param devices set of devices to query by
- * @param links set of links to query by
+ * @param hosts set of hosts to query by
+ * @param devices set of devices to query by
+ * @param links set of links to query by
* @return set of intents that 'match' all hosts, devices and links given
*/
public List<Intent> findPathIntents(Set<Host> hosts,