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; |
| 19 | import org.onosproject.net.DeviceId; |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 20 | import org.onosproject.net.pi.service.PiTranslatable; |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 21 | |
| 22 | import java.util.Collection; |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 25 | * Represents a generalized meter cell configuration to be deployed on a device. |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 26 | */ |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 27 | public interface Meter extends PiTranslatable { |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 28 | |
| 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 Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 52 | * @deprecated in Nightingale release (version 1.13.0). Use {@link #meterCellId()} instead. |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 53 | */ |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 54 | @Deprecated |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 55 | MeterId id(); |
| 56 | |
| 57 | /** |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 58 | * Returns the meter cell identifier of this meter. |
| 59 | * |
| 60 | * @return a meter identifier |
| 61 | */ |
| 62 | MeterCellId meterCellId(); |
| 63 | |
| 64 | /** |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 65 | * 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 Milkey | dbbd87b | 2015-08-03 15:56:22 -0700 | [diff] [blame] | 74 | * @return the unit |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 75 | */ |
| 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 | /** |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 93 | * 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 | /** |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 128 | * 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 | * |
alshabib | e1248b6 | 2015-08-20 17:21:55 -0700 | [diff] [blame] | 143 | * @param id a e |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 144 | * @return this |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 145 | * @deprecated in Nightingale release (version 1.13.0). Use {@link |
| 146 | * #withCellId(MeterCellId)} instead. |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 147 | */ |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 148 | @Deprecated |
alshabib | 58fe6dc | 2015-08-19 17:16:13 -0700 | [diff] [blame] | 149 | Builder withId(MeterId id); |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 150 | |
| 151 | /** |
Frank Wang | d7e3b4b | 2017-09-24 13:37:54 +0900 | [diff] [blame] | 152 | * 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 | /** |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 160 | * 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 | |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 192 | /** |
| 193 | * Builds the meter based on the specified parameters. |
| 194 | * |
| 195 | * @return a meter |
| 196 | */ |
| 197 | Meter build(); |
| 198 | } |
| 199 | |
| 200 | } |