3 * * Copyright 2015 Open Networking Laboratory
5 * * Licensed under the Apache License, Version 2.0 (the "License");
6 * * you may not use this file except in compliance with the License.
7 * * You may obtain a copy of the License at
9 * * http://www.apache.org/licenses/LICENSE-2.0
11 * * Unless required by applicable law or agreed to in writing, software
12 * * distributed under the License is distributed on an "AS IS" BASIS,
13 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * * See the License for the specific language governing permissions and
15 * * limitations under the License.
19 package org.onosproject.incubator.net.tunnel;
21 import java.time.Duration;
22 import java.util.List;
25 * Default implementation of immutable tunnel statistics.
27 public final class DefaultTunnelStatistics implements TunnelStatistics {
28 private final TunnelId tunnelId;
29 private final double bwUtilization;
30 private final double packetLossRatio;
31 private final Duration flowDelay;
32 private final List<String> alarms;
34 private DefaultTunnelStatistics(TunnelId tunnelId,
36 double packetLossRatio,
38 List<String> alarms) {
39 this.tunnelId = tunnelId;
40 this.bwUtilization = bwUtilization;
41 this.packetLossRatio = packetLossRatio;
42 this.flowDelay = flowDelay;
46 private DefaultTunnelStatistics() {
48 this.bwUtilization = 0;
49 this.packetLossRatio = 0;
50 this.flowDelay = null;
56 public TunnelId id() {
61 public double bandwidthUtilization() {
62 return this.bwUtilization;
66 public double packetLossRate() {
67 return this.packetLossRatio;
71 public Duration flowDelay() {
72 return this.flowDelay;
77 public List<String> alarms() {
82 * Builder for tunnelStatistics.
84 public static final class Builder {
87 double packetLossRatio;
98 * @param tunnelId tunnel id
99 * @return builder object
101 public Builder setTunnelId(TunnelId tunnelId) {
102 this.tunnelId = tunnelId;
108 * set bandwidth utilization.
110 * @param bwUtilization bandwidth utilization
111 * @return builder object
113 public Builder setBwUtilization(double bwUtilization) {
114 this.bwUtilization = bwUtilization;
120 * Set packet loss ratio.
122 * @param packetLossRatio packet loss ratio
123 * @return builder object
125 public Builder setPacketLossRatio(double packetLossRatio) {
126 this.packetLossRatio = packetLossRatio;
134 * @param flowDelay flow delay
135 * @return builder object
137 public Builder setFlowDelay(Duration flowDelay) {
138 this.flowDelay = flowDelay;
146 * @param alarms alarms of a tunnel
147 * @return builder object
149 public Builder setAlarms(List<String> alarms) {
150 this.alarms = alarms;
156 * Creates a TunnelStatistics object.
158 * @return DefaultTunnelStatistics
160 public DefaultTunnelStatistics build() {
161 return new DefaultTunnelStatistics(tunnelId,