blob: 63b6db33fd4e5b09fd710c0a247debfe515ab175 [file] [log] [blame]
alshabib1d2bc402015-07-31 17:04:11 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
alshabib1d2bc402015-07-31 17:04:11 -07003 *
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 */
alshabib10c810b2015-08-18 16:59:04 -070016package org.onosproject.net.meter;
alshabib1d2bc402015-07-31 17:04:11 -070017
18import org.onosproject.core.ApplicationId;
Andrea Campanella5bdbe432021-05-03 15:59:19 +020019import org.onosproject.net.Annotated;
20import org.onosproject.net.Annotations;
alshabib1d2bc402015-07-31 17:04:11 -070021import org.onosproject.net.DeviceId;
Frank Wangd7e3b4b2017-09-24 13:37:54 +090022import org.onosproject.net.pi.service.PiTranslatable;
alshabib1d2bc402015-07-31 17:04:11 -070023
24import java.util.Collection;
alshabib1d2bc402015-07-31 17:04:11 -070025
26/**
Frank Wangd7e3b4b2017-09-24 13:37:54 +090027 * Represents a generalized meter cell configuration to be deployed on a device.
alshabib1d2bc402015-07-31 17:04:11 -070028 */
Andrea Campanella5bdbe432021-05-03 15:59:19 +020029public interface Meter extends PiTranslatable, Annotated {
alshabib1d2bc402015-07-31 17:04:11 -070030
31 enum Unit {
32 /**
33 * Packets per second.
34 */
35 PKTS_PER_SEC,
36
37 /**
38 * Kilo bits per second.
39 */
40 KB_PER_SEC
41 }
42
43 /**
44 * The target device for this meter.
45 *
46 * @return a device id
47 */
48 DeviceId deviceId();
49
50 /**
51 * This meters id.
52 *
53 * @return a meter id
Frank Wangd7e3b4b2017-09-24 13:37:54 +090054 * @deprecated in Nightingale release (version 1.13.0). Use {@link #meterCellId()} instead.
alshabib1d2bc402015-07-31 17:04:11 -070055 */
Frank Wangd7e3b4b2017-09-24 13:37:54 +090056 @Deprecated
alshabib1d2bc402015-07-31 17:04:11 -070057 MeterId id();
58
59 /**
Frank Wangd7e3b4b2017-09-24 13:37:54 +090060 * Returns the meter cell identifier of this meter.
61 *
62 * @return a meter identifier
63 */
64 MeterCellId meterCellId();
65
66 /**
alshabib1d2bc402015-07-31 17:04:11 -070067 * The id of the application which created this meter.
68 *
69 * @return an application id
70 */
71 ApplicationId appId();
72
73 /**
74 * The unit used within this meter.
75 *
Ray Milkeydbbd87b2015-08-03 15:56:22 -070076 * @return the unit
alshabib1d2bc402015-07-31 17:04:11 -070077 */
78 Unit unit();
79
80 /**
81 * Signals whether this meter applies to bursts only.
82 *
83 * @return a boolean
84 */
85 boolean isBurst();
86
87 /**
88 * The collection of bands to apply on the dataplane.
89 *
90 * @return a collection of bands.
91 */
92 Collection<Band> bands();
93
94 /**
alshabib7bb05012015-08-05 10:15:09 -070095 * Fetches the state of this meter.
96 *
97 * @return a meter state
98 */
99 MeterState state();
100
101 /**
102 * The lifetime in seconds of this meter.
103 *
104 * @return number of seconds
105 */
106 long life();
107
108 /**
109 * The number of flows pointing to this meter.
110 *
111 * @return a reference count
112 */
113 long referenceCount();
114
115 /**
116 * Number of packets processed by this meter.
117 *
118 * @return a packet count
119 */
120 long packetsSeen();
121
122 /**
123 * Number of bytes processed by this meter.
124 *
125 * @return a byte count
126 */
127 long bytesSeen();
128
129 /**
alshabib1d2bc402015-07-31 17:04:11 -0700130 * A meter builder.
131 */
132 interface Builder {
133
134 /**
135 * Assigns the target device for this meter.
136 *
137 * @param deviceId a device id
138 * @return this
139 */
140 Builder forDevice(DeviceId deviceId);
141
142 /**
143 * Assigns the id to this meter.
144 *
alshabibe1248b62015-08-20 17:21:55 -0700145 * @param id a e
alshabib1d2bc402015-07-31 17:04:11 -0700146 * @return this
Frank Wangd7e3b4b2017-09-24 13:37:54 +0900147 * @deprecated in Nightingale release (version 1.13.0). Use {@link
148 * #withCellId(MeterCellId)} instead.
alshabib1d2bc402015-07-31 17:04:11 -0700149 */
Frank Wangd7e3b4b2017-09-24 13:37:54 +0900150 @Deprecated
alshabib58fe6dc2015-08-19 17:16:13 -0700151 Builder withId(MeterId id);
alshabib1d2bc402015-07-31 17:04:11 -0700152
153 /**
Frank Wangd7e3b4b2017-09-24 13:37:54 +0900154 * Assigns the id to this meter cell.
155 *
156 * @param meterId a meter cell identifier
157 * @return this
158 */
159 Builder withCellId(MeterCellId meterId);
160
161 /**
alshabib1d2bc402015-07-31 17:04:11 -0700162 * Assigns the application that built this meter.
163 *
164 * @param appId an application id
165 * @return this
166 */
167 Builder fromApp(ApplicationId appId);
168
169 /**
170 * Assigns the @See Unit to use for this meter.
171 * Defaults to kb/s
172 *
173 * @param unit a unit
174 * @return this
175 */
176 Builder withUnit(Unit unit);
177
178 /**
179 * Sets this meter as applicable to burst traffic only.
180 * Defaults to false.
181 *
182 * @return this
183 */
184 Builder burst();
185
186 /**
187 * Assigns bands to this meter. There must be at least one band.
188 *
189 * @param bands a collection of bands
190 * @return this
191 */
192 Builder withBands(Collection<Band> bands);
193
alshabib1d2bc402015-07-31 17:04:11 -0700194 /**
Andrea Campanella5bdbe432021-05-03 15:59:19 +0200195 * Sets the annotations.
196 *
197 * @param annotations annotations
198 * @return builder object
199 */
200 Builder withAnnotations(Annotations annotations);
201
202 /**
alshabib1d2bc402015-07-31 17:04:11 -0700203 * Builds the meter based on the specified parameters.
204 *
205 * @return a meter
206 */
207 Meter build();
208 }
209
210}