alshabib | e1248b6 | 2015-08-20 17:21:55 -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 | e1248b6 | 2015-08-20 17:21:55 -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 | */ |
| 16 | package org.onosproject.net.meter; |
| 17 | |
| 18 | import org.onosproject.core.ApplicationId; |
| 19 | import org.onosproject.net.DeviceId; |
| 20 | |
| 21 | import java.util.Collection; |
| 22 | import java.util.Optional; |
| 23 | |
| 24 | /** |
| 25 | * Represents a generalized meter request to be deployed on a device. |
| 26 | */ |
| 27 | public interface MeterRequest { |
| 28 | |
| 29 | enum Type { |
| 30 | ADD, |
| 31 | MODIFY, |
| 32 | REMOVE |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * The target device for this meter. |
| 37 | * |
| 38 | * @return a device id |
| 39 | */ |
| 40 | DeviceId deviceId(); |
| 41 | |
| 42 | /** |
| 43 | * The id of the application which created this meter. |
| 44 | * |
| 45 | * @return an application id |
| 46 | */ |
| 47 | ApplicationId appId(); |
| 48 | |
| 49 | /** |
| 50 | * The unit used within this meter. |
| 51 | * |
| 52 | * @return the unit |
| 53 | */ |
| 54 | Meter.Unit unit(); |
| 55 | |
| 56 | /** |
| 57 | * Signals whether this meter applies to bursts only. |
| 58 | * |
| 59 | * @return a boolean |
| 60 | */ |
| 61 | boolean isBurst(); |
| 62 | |
| 63 | /** |
| 64 | * The collection of bands to apply on the dataplane. |
| 65 | * |
| 66 | * @return a collection of bands. |
| 67 | */ |
| 68 | Collection<Band> bands(); |
| 69 | |
| 70 | /** |
| 71 | * Returns the callback context for this meter. |
| 72 | * |
| 73 | * @return an optional meter context |
| 74 | */ |
| 75 | Optional<MeterContext> context(); |
| 76 | |
| 77 | /** |
| 78 | * A meter builder. |
| 79 | */ |
| 80 | interface Builder { |
| 81 | |
| 82 | /** |
| 83 | * Assigns the target device for this meter. |
| 84 | * |
| 85 | * @param deviceId a device id |
| 86 | * @return this |
| 87 | */ |
| 88 | Builder forDevice(DeviceId deviceId); |
| 89 | |
| 90 | /** |
| 91 | * Assigns the application that built this meter. |
| 92 | * |
| 93 | * @param appId an application id |
| 94 | * @return this |
| 95 | */ |
| 96 | Builder fromApp(ApplicationId appId); |
| 97 | |
| 98 | /** |
| 99 | * Assigns the @See Unit to use for this meter. |
| 100 | * Defaults to kb/s |
| 101 | * |
| 102 | * @param unit a unit |
| 103 | * @return this |
| 104 | */ |
| 105 | Builder withUnit(Meter.Unit unit); |
| 106 | |
| 107 | /** |
| 108 | * Sets this meter as applicable to burst traffic only. |
| 109 | * Defaults to false. |
| 110 | * |
| 111 | * @return this |
| 112 | */ |
| 113 | Builder burst(); |
| 114 | |
| 115 | /** |
| 116 | * Assigns bands to this meter. There must be at least one band. |
| 117 | * |
| 118 | * @param bands a collection of bands |
| 119 | * @return this |
| 120 | */ |
| 121 | Builder withBands(Collection<Band> bands); |
| 122 | |
| 123 | /** |
| 124 | * Assigns an execution context for this meter request. |
| 125 | * |
| 126 | * @param context a meter context |
| 127 | * @return this |
| 128 | */ |
| 129 | Builder withContext(MeterContext context); |
| 130 | |
| 131 | /** |
| 132 | * Requests the addition of a meter. |
| 133 | * |
| 134 | * @return a meter request |
| 135 | */ |
| 136 | MeterRequest add(); |
| 137 | |
| 138 | /** |
| 139 | * Requests the removal of a meter. |
| 140 | * |
| 141 | * @return a meter request |
| 142 | */ |
| 143 | MeterRequest remove(); |
alshabib | e1248b6 | 2015-08-20 17:21:55 -0700 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | } |