Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 18 | package org.onosproject.ui.impl.topo; |
| 19 | |
| 20 | import org.onosproject.ui.impl.TrafficMonitorBase; |
| 21 | import org.onosproject.ui.impl.topo.util.ServicesBundle; |
Simon Hunt | a7aea84 | 2017-05-03 19:42:50 -0700 | [diff] [blame] | 22 | import org.onosproject.ui.impl.topo.util.TrafficLink; |
| 23 | import org.onosproject.ui.topo.Highlights; |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 24 | import org.slf4j.Logger; |
| 25 | import org.slf4j.LoggerFactory; |
| 26 | |
Simon Hunt | a7aea84 | 2017-05-03 19:42:50 -0700 | [diff] [blame] | 27 | import java.util.Set; |
| 28 | |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 29 | /** |
| 30 | * Encapsulates the behavior of monitoring specific traffic patterns in the |
| 31 | * Topology-2 view. |
| 32 | */ |
| 33 | public class Traffic2Monitor extends TrafficMonitorBase { |
| 34 | |
| 35 | private static final Logger log = |
| 36 | LoggerFactory.getLogger(Traffic2Monitor.class); |
| 37 | |
Simon Hunt | a7aea84 | 2017-05-03 19:42:50 -0700 | [diff] [blame] | 38 | // link back to our message handler (for outbound messages) |
Simon Hunt | 9e2413e | 2017-05-03 14:25:40 -0700 | [diff] [blame] | 39 | private final Topo2TrafficMessageHandler msgHandler; |
| 40 | |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 41 | /** |
| 42 | * Constructs a traffic monitor. |
| 43 | * |
Simon Hunt | 9e2413e | 2017-05-03 14:25:40 -0700 | [diff] [blame] | 44 | * @param trafficPeriod traffic task period in ms |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 45 | * @param servicesBundle bundle of services |
Simon Hunt | 9e2413e | 2017-05-03 14:25:40 -0700 | [diff] [blame] | 46 | * @param msgHandler our message handler |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 47 | */ |
Simon Hunt | 9e2413e | 2017-05-03 14:25:40 -0700 | [diff] [blame] | 48 | public Traffic2Monitor(long trafficPeriod, ServicesBundle servicesBundle, |
| 49 | Topo2TrafficMessageHandler msgHandler) { |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 50 | super(trafficPeriod, servicesBundle); |
Simon Hunt | 9e2413e | 2017-05-03 14:25:40 -0700 | [diff] [blame] | 51 | this.msgHandler = msgHandler; |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | @Override |
| 55 | protected void sendAllFlowTraffic() { |
Simon Hunt | 9e2413e | 2017-05-03 14:25:40 -0700 | [diff] [blame] | 56 | log.debug("TOPO-2-TRAFFIC: sendAllFlowTraffic"); |
Simon Hunt | 8e25811 | 2017-05-05 13:19:04 -0700 | [diff] [blame^] | 57 | msgHandler.sendHighlights(trafficSummary(TrafficLink.StatsType.FLOW_STATS)); |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | @Override |
| 61 | protected void sendAllPortTrafficBits() { |
Simon Hunt | 9e2413e | 2017-05-03 14:25:40 -0700 | [diff] [blame] | 62 | log.debug("TOPO-2-TRAFFIC: sendAllPortTrafficBits"); |
Simon Hunt | 8e25811 | 2017-05-05 13:19:04 -0700 | [diff] [blame^] | 63 | msgHandler.sendHighlights(trafficSummary(TrafficLink.StatsType.PORT_STATS)); |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | @Override |
| 67 | protected void sendAllPortTrafficPackets() { |
Simon Hunt | 9e2413e | 2017-05-03 14:25:40 -0700 | [diff] [blame] | 68 | log.debug("TOPO-2-TRAFFIC: sendAllPortTrafficPackets"); |
Simon Hunt | 8e25811 | 2017-05-05 13:19:04 -0700 | [diff] [blame^] | 69 | msgHandler.sendHighlights(trafficSummary(TrafficLink.StatsType.PORT_PACKET_STATS)); |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | @Override |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 73 | protected void sendClearHighlights() { |
Simon Hunt | 9e2413e | 2017-05-03 14:25:40 -0700 | [diff] [blame] | 74 | log.debug("TOPO-2-TRAFFIC: sendClearHighlights"); |
Simon Hunt | 8e25811 | 2017-05-05 13:19:04 -0700 | [diff] [blame^] | 75 | msgHandler.sendHighlights(new Highlights()); |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Simon Hunt | 9e2413e | 2017-05-03 14:25:40 -0700 | [diff] [blame] | 78 | |
| 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 Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 88 | @Override |
| 89 | protected void clearSelection() { |
Simon Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 90 | } |
Simon Hunt | a7aea84 | 2017-05-03 19:42:50 -0700 | [diff] [blame] | 91 | |
| 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 Hunt | 1911fe4 | 2017-05-02 18:25:58 -0700 | [diff] [blame] | 103 | } |