blob: 8f056fa464a8ea28152a55e2299e51a902752044 [file] [log] [blame]
Simon Hunt1911fe42017-05-02 18:25:58 -07001/*
2 * Copyright 2017-present 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
18package org.onosproject.ui.impl.topo;
19
20import org.onosproject.ui.impl.TrafficMonitorBase;
21import org.onosproject.ui.impl.topo.util.ServicesBundle;
Simon Hunta7aea842017-05-03 19:42:50 -070022import org.onosproject.ui.impl.topo.util.TrafficLink;
23import org.onosproject.ui.topo.Highlights;
Simon Hunt1911fe42017-05-02 18:25:58 -070024import org.slf4j.Logger;
25import org.slf4j.LoggerFactory;
26
Simon Hunta7aea842017-05-03 19:42:50 -070027import java.util.Set;
28
Simon Hunt1911fe42017-05-02 18:25:58 -070029/**
30 * Encapsulates the behavior of monitoring specific traffic patterns in the
31 * Topology-2 view.
32 */
33public class Traffic2Monitor extends TrafficMonitorBase {
34
35 private static final Logger log =
36 LoggerFactory.getLogger(Traffic2Monitor.class);
37
Simon Hunta7aea842017-05-03 19:42:50 -070038 // link back to our message handler (for outbound messages)
Simon Hunt9e2413e2017-05-03 14:25:40 -070039 private final Topo2TrafficMessageHandler msgHandler;
40
Simon Hunt1911fe42017-05-02 18:25:58 -070041 /**
42 * Constructs a traffic monitor.
43 *
Simon Hunt9e2413e2017-05-03 14:25:40 -070044 * @param trafficPeriod traffic task period in ms
Simon Hunt1911fe42017-05-02 18:25:58 -070045 * @param servicesBundle bundle of services
Simon Hunt9e2413e2017-05-03 14:25:40 -070046 * @param msgHandler our message handler
Simon Hunt1911fe42017-05-02 18:25:58 -070047 */
Simon Hunt9e2413e2017-05-03 14:25:40 -070048 public Traffic2Monitor(long trafficPeriod, ServicesBundle servicesBundle,
49 Topo2TrafficMessageHandler msgHandler) {
Simon Hunt1911fe42017-05-02 18:25:58 -070050 super(trafficPeriod, servicesBundle);
Simon Hunt9e2413e2017-05-03 14:25:40 -070051 this.msgHandler = msgHandler;
Simon Hunt1911fe42017-05-02 18:25:58 -070052 }
53
54 @Override
55 protected void sendAllFlowTraffic() {
Simon Hunt9e2413e2017-05-03 14:25:40 -070056 log.debug("TOPO-2-TRAFFIC: sendAllFlowTraffic");
Simon Hunt8e258112017-05-05 13:19:04 -070057 msgHandler.sendHighlights(trafficSummary(TrafficLink.StatsType.FLOW_STATS));
Simon Hunt1911fe42017-05-02 18:25:58 -070058 }
59
60 @Override
61 protected void sendAllPortTrafficBits() {
Simon Hunt9e2413e2017-05-03 14:25:40 -070062 log.debug("TOPO-2-TRAFFIC: sendAllPortTrafficBits");
Simon Hunt8e258112017-05-05 13:19:04 -070063 msgHandler.sendHighlights(trafficSummary(TrafficLink.StatsType.PORT_STATS));
Simon Hunt1911fe42017-05-02 18:25:58 -070064 }
65
66 @Override
67 protected void sendAllPortTrafficPackets() {
Simon Hunt9e2413e2017-05-03 14:25:40 -070068 log.debug("TOPO-2-TRAFFIC: sendAllPortTrafficPackets");
Simon Hunt8e258112017-05-05 13:19:04 -070069 msgHandler.sendHighlights(trafficSummary(TrafficLink.StatsType.PORT_PACKET_STATS));
Simon Hunt1911fe42017-05-02 18:25:58 -070070 }
71
72 @Override
Simon Hunt1911fe42017-05-02 18:25:58 -070073 protected void sendClearHighlights() {
Simon Hunt9e2413e2017-05-03 14:25:40 -070074 log.debug("TOPO-2-TRAFFIC: sendClearHighlights");
Simon Hunt8e258112017-05-05 13:19:04 -070075 msgHandler.sendHighlights(new Highlights());
Simon Hunt1911fe42017-05-02 18:25:58 -070076 }
77
Simon Hunt9e2413e2017-05-03 14:25:40 -070078
79 // NOTE: currently this monitor holds no state - nothing to do for these...
80 @Override
81 protected void sendDeviceLinkFlows() {
82 }
83
84 @Override
85 protected void sendSelectedIntentTraffic() {
86 }
87
Simon Hunt1911fe42017-05-02 18:25:58 -070088 @Override
89 protected void clearSelection() {
Simon Hunt1911fe42017-05-02 18:25:58 -070090 }
Simon Hunta7aea842017-05-03 19:42:50 -070091
92 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
93 // -- link aggregation
94
95
96 @Override
97 protected Set<TrafficLink> doAggregation(Set<TrafficLink> linksWithTraffic) {
98 // TODO: figure out how to aggregate the link data...
99 log.debug("Need to aggregate {} links", linksWithTraffic.size());
100
101 return linksWithTraffic;
102 }
Simon Hunt1911fe42017-05-02 18:25:58 -0700103}