blob: 3d7544e404ae50748bb7ccc459b69655452108e2 [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;
19import org.onosproject.net.DeviceId;
Frank Wangd7e3b4b2017-09-24 13:37:54 +090020import org.onosproject.net.pi.service.PiTranslatable;
alshabib1d2bc402015-07-31 17:04:11 -070021
22import java.util.Collection;
alshabib1d2bc402015-07-31 17:04:11 -070023
24/**
Frank Wangd7e3b4b2017-09-24 13:37:54 +090025 * Represents a generalized meter cell configuration to be deployed on a device.
alshabib1d2bc402015-07-31 17:04:11 -070026 */
Frank Wangd7e3b4b2017-09-24 13:37:54 +090027public interface Meter extends PiTranslatable {
alshabib1d2bc402015-07-31 17:04:11 -070028
29 enum Unit {
30 /**
31 * Packets per second.
32 */
33 PKTS_PER_SEC,
34
35 /**
36 * Kilo bits per second.
37 */
38 KB_PER_SEC
39 }
40
41 /**
42 * The target device for this meter.
43 *
44 * @return a device id
45 */
46 DeviceId deviceId();
47
48 /**
49 * This meters id.
50 *
51 * @return a meter id
Frank Wangd7e3b4b2017-09-24 13:37:54 +090052 * @deprecated in Nightingale release (version 1.13.0). Use {@link #meterCellId()} instead.
alshabib1d2bc402015-07-31 17:04:11 -070053 */
Frank Wangd7e3b4b2017-09-24 13:37:54 +090054 @Deprecated
alshabib1d2bc402015-07-31 17:04:11 -070055 MeterId id();
56
57 /**
Frank Wangd7e3b4b2017-09-24 13:37:54 +090058 * Returns the meter cell identifier of this meter.
59 *
60 * @return a meter identifier
61 */
62 MeterCellId meterCellId();
63
64 /**
alshabib1d2bc402015-07-31 17:04:11 -070065 * The id of the application which created this meter.
66 *
67 * @return an application id
68 */
69 ApplicationId appId();
70
71 /**
72 * The unit used within this meter.
73 *
Ray Milkeydbbd87b2015-08-03 15:56:22 -070074 * @return the unit
alshabib1d2bc402015-07-31 17:04:11 -070075 */
76 Unit unit();
77
78 /**
79 * Signals whether this meter applies to bursts only.
80 *
81 * @return a boolean
82 */
83 boolean isBurst();
84
85 /**
86 * The collection of bands to apply on the dataplane.
87 *
88 * @return a collection of bands.
89 */
90 Collection<Band> bands();
91
92 /**
alshabib7bb05012015-08-05 10:15:09 -070093 * Fetches the state of this meter.
94 *
95 * @return a meter state
96 */
97 MeterState state();
98
99 /**
100 * The lifetime in seconds of this meter.
101 *
102 * @return number of seconds
103 */
104 long life();
105
106 /**
107 * The number of flows pointing to this meter.
108 *
109 * @return a reference count
110 */
111 long referenceCount();
112
113 /**
114 * Number of packets processed by this meter.
115 *
116 * @return a packet count
117 */
118 long packetsSeen();
119
120 /**
121 * Number of bytes processed by this meter.
122 *
123 * @return a byte count
124 */
125 long bytesSeen();
126
127 /**
alshabib1d2bc402015-07-31 17:04:11 -0700128 * A meter builder.
129 */
130 interface Builder {
131
132 /**
133 * Assigns the target device for this meter.
134 *
135 * @param deviceId a device id
136 * @return this
137 */
138 Builder forDevice(DeviceId deviceId);
139
140 /**
141 * Assigns the id to this meter.
142 *
alshabibe1248b62015-08-20 17:21:55 -0700143 * @param id a e
alshabib1d2bc402015-07-31 17:04:11 -0700144 * @return this
Frank Wangd7e3b4b2017-09-24 13:37:54 +0900145 * @deprecated in Nightingale release (version 1.13.0). Use {@link
146 * #withCellId(MeterCellId)} instead.
alshabib1d2bc402015-07-31 17:04:11 -0700147 */
Frank Wangd7e3b4b2017-09-24 13:37:54 +0900148 @Deprecated
alshabib58fe6dc2015-08-19 17:16:13 -0700149 Builder withId(MeterId id);
alshabib1d2bc402015-07-31 17:04:11 -0700150
151 /**
Frank Wangd7e3b4b2017-09-24 13:37:54 +0900152 * Assigns the id to this meter cell.
153 *
154 * @param meterId a meter cell identifier
155 * @return this
156 */
157 Builder withCellId(MeterCellId meterId);
158
159 /**
alshabib1d2bc402015-07-31 17:04:11 -0700160 * Assigns the application that built this meter.
161 *
162 * @param appId an application id
163 * @return this
164 */
165 Builder fromApp(ApplicationId appId);
166
167 /**
168 * Assigns the @See Unit to use for this meter.
169 * Defaults to kb/s
170 *
171 * @param unit a unit
172 * @return this
173 */
174 Builder withUnit(Unit unit);
175
176 /**
177 * Sets this meter as applicable to burst traffic only.
178 * Defaults to false.
179 *
180 * @return this
181 */
182 Builder burst();
183
184 /**
185 * Assigns bands to this meter. There must be at least one band.
186 *
187 * @param bands a collection of bands
188 * @return this
189 */
190 Builder withBands(Collection<Band> bands);
191
alshabib1d2bc402015-07-31 17:04:11 -0700192 /**
193 * Builds the meter based on the specified parameters.
194 *
195 * @return a meter
196 */
197 Meter build();
198 }
199
200}