blob: e156fd4a61d7f16eb4296f93c60301761626ea78 [file] [log] [blame]
alshabibe1248b62015-08-20 17:21:55 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
alshabibe1248b62015-08-20 17:21:55 -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 */
16package org.onosproject.net.meter;
17
18import org.onosproject.core.ApplicationId;
Andrea Campanella5bdbe432021-05-03 15:59:19 +020019import org.onosproject.net.Annotated;
20import org.onosproject.net.Annotations;
alshabibe1248b62015-08-20 17:21:55 -070021import org.onosproject.net.DeviceId;
22
23import java.util.Collection;
24import java.util.Optional;
25
26/**
27 * Represents a generalized meter request to be deployed on a device.
28 */
Andrea Campanella5bdbe432021-05-03 15:59:19 +020029public interface MeterRequest extends Annotated {
alshabibe1248b62015-08-20 17:21:55 -070030
31 enum Type {
32 ADD,
33 MODIFY,
34 REMOVE
35 }
36
37 /**
38 * The target device for this meter.
39 *
40 * @return a device id
41 */
42 DeviceId deviceId();
43
44 /**
45 * The id of the application which created this meter.
46 *
47 * @return an application id
48 */
49 ApplicationId appId();
50
51 /**
52 * The unit used within this meter.
53 *
54 * @return the unit
55 */
56 Meter.Unit unit();
57
58 /**
59 * Signals whether this meter applies to bursts only.
60 *
61 * @return a boolean
62 */
63 boolean isBurst();
64
65 /**
66 * The collection of bands to apply on the dataplane.
67 *
68 * @return a collection of bands.
69 */
70 Collection<Band> bands();
71
72 /**
73 * Returns the callback context for this meter.
74 *
75 * @return an optional meter context
76 */
77 Optional<MeterContext> context();
78
79 /**
Wailok Shum79919522021-08-22 19:35:34 +080080 * Returns the scope of this meter request.
81 *
82 * @return a meter scope
83 */
84 MeterScope scope();
85
86 /**
87 * Returns the desired meter index of this meter request.
88 *
89 * @return an optional long index
90 */
91 Optional<Long> index();
92
93 /**
alshabibe1248b62015-08-20 17:21:55 -070094 * A meter builder.
95 */
96 interface Builder {
97
98 /**
99 * Assigns the target device for this meter.
100 *
101 * @param deviceId a device id
102 * @return this
103 */
104 Builder forDevice(DeviceId deviceId);
105
106 /**
107 * Assigns the application that built this meter.
108 *
109 * @param appId an application id
110 * @return this
111 */
112 Builder fromApp(ApplicationId appId);
113
114 /**
115 * Assigns the @See Unit to use for this meter.
116 * Defaults to kb/s
117 *
118 * @param unit a unit
119 * @return this
120 */
121 Builder withUnit(Meter.Unit unit);
122
123 /**
124 * Sets this meter as applicable to burst traffic only.
125 * Defaults to false.
126 *
127 * @return this
128 */
129 Builder burst();
130
131 /**
132 * Assigns bands to this meter. There must be at least one band.
133 *
134 * @param bands a collection of bands
135 * @return this
136 */
137 Builder withBands(Collection<Band> bands);
138
139 /**
140 * Assigns an execution context for this meter request.
141 *
142 * @param context a meter context
143 * @return this
144 */
145 Builder withContext(MeterContext context);
146
147 /**
Andrea Campanella5bdbe432021-05-03 15:59:19 +0200148 * Sets the annotations.
149 *
150 * @param annotations annotations
151 * @return builder object
152 */
153 Builder withAnnotations(Annotations annotations);
154
155 /**
Wailok Shum79919522021-08-22 19:35:34 +0800156 * Sets the scope.
157 *
158 * @param scope a meter scope
159 * @return this
160 */
161 Builder withScope(MeterScope scope);
162
163 /**
164 * Sets the index.
165 *
166 * @param index an optional index
167 * @return this
168 */
169 Builder withIndex(Long index);
170
171 /**
alshabibe1248b62015-08-20 17:21:55 -0700172 * Requests the addition of a meter.
173 *
174 * @return a meter request
175 */
176 MeterRequest add();
177
178 /**
179 * Requests the removal of a meter.
180 *
181 * @return a meter request
182 */
183 MeterRequest remove();
alshabibe1248b62015-08-20 17:21:55 -0700184 }
185
186}