alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 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 | */ |
alshabib | 10c810b | 2015-08-18 16:59:04 -0700 | [diff] [blame] | 16 | package org.onosproject.net.meter; |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 17 | |
| 18 | import org.onosproject.core.ApplicationId; |
Andrea Campanella | 5bdbe43 | 2021-05-03 15:59:19 +0200 | [diff] [blame] | 19 | import org.onosproject.net.Annotated; |
| 20 | import org.onosproject.net.Annotations; |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 21 | import org.onosproject.net.DeviceId; |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 22 | import org.onosproject.net.pi.service.PiTranslatable; |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 23 | |
| 24 | import java.util.Collection; |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 27 | * Represents a generalized meter cell configuration to be deployed on a device. |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 28 | */ |
Andrea Campanella | 5bdbe43 | 2021-05-03 15:59:19 +0200 | [diff] [blame] | 29 | public interface Meter extends PiTranslatable, Annotated { |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 30 | |
| 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 Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 54 | * @deprecated in Nightingale release (version 1.13.0). Use {@link #meterCellId()} instead. |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 55 | */ |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 56 | @Deprecated |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 57 | MeterId id(); |
| 58 | |
| 59 | /** |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 60 | * Returns the meter cell identifier of this meter. |
| 61 | * |
| 62 | * @return a meter identifier |
| 63 | */ |
| 64 | MeterCellId meterCellId(); |
| 65 | |
| 66 | /** |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 67 | * 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 Milkey | dbbd87b | 2015-08-03 15:56:22 -0700 | [diff] [blame] | 76 | * @return the unit |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 77 | */ |
| 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 | /** |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 95 | * 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 | /** |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 130 | * 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 | * |
alshabib | e1248b6 | 2015-08-20 17:21:55 -0700 | [diff] [blame] | 145 | * @param id a e |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 146 | * @return this |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 147 | * @deprecated in Nightingale release (version 1.13.0). Use {@link |
| 148 | * #withCellId(MeterCellId)} instead. |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 149 | */ |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 150 | @Deprecated |
alshabib | 58fe6dc | 2015-08-19 17:16:13 -0700 | [diff] [blame] | 151 | Builder withId(MeterId id); |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 152 | |
| 153 | /** |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 154 | * 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 | /** |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 162 | * 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 | |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 194 | /** |
Andrea Campanella | 5bdbe43 | 2021-05-03 15:59:19 +0200 | [diff] [blame] | 195 | * Sets the annotations. |
| 196 | * |
| 197 | * @param annotations annotations |
| 198 | * @return builder object |
| 199 | */ |
| 200 | Builder withAnnotations(Annotations annotations); |
| 201 | |
| 202 | /** |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 203 | * Builds the meter based on the specified parameters. |
| 204 | * |
| 205 | * @return a meter |
| 206 | */ |
| 207 | Meter build(); |
| 208 | } |
| 209 | |
| 210 | } |