blob: a2be1ceca18d1cf5f193aef0257055991c8bf075 [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 /**
80 * A meter builder.
81 */
82 interface Builder {
83
84 /**
85 * Assigns the target device for this meter.
86 *
87 * @param deviceId a device id
88 * @return this
89 */
90 Builder forDevice(DeviceId deviceId);
91
92 /**
93 * Assigns the application that built this meter.
94 *
95 * @param appId an application id
96 * @return this
97 */
98 Builder fromApp(ApplicationId appId);
99
100 /**
101 * Assigns the @See Unit to use for this meter.
102 * Defaults to kb/s
103 *
104 * @param unit a unit
105 * @return this
106 */
107 Builder withUnit(Meter.Unit unit);
108
109 /**
110 * Sets this meter as applicable to burst traffic only.
111 * Defaults to false.
112 *
113 * @return this
114 */
115 Builder burst();
116
117 /**
118 * Assigns bands to this meter. There must be at least one band.
119 *
120 * @param bands a collection of bands
121 * @return this
122 */
123 Builder withBands(Collection<Band> bands);
124
125 /**
126 * Assigns an execution context for this meter request.
127 *
128 * @param context a meter context
129 * @return this
130 */
131 Builder withContext(MeterContext context);
132
133 /**
Andrea Campanella5bdbe432021-05-03 15:59:19 +0200134 * Sets the annotations.
135 *
136 * @param annotations annotations
137 * @return builder object
138 */
139 Builder withAnnotations(Annotations annotations);
140
141 /**
alshabibe1248b62015-08-20 17:21:55 -0700142 * Requests the addition of a meter.
143 *
144 * @return a meter request
145 */
146 MeterRequest add();
147
148 /**
149 * Requests the removal of a meter.
150 *
151 * @return a meter request
152 */
153 MeterRequest remove();
alshabibe1248b62015-08-20 17:21:55 -0700154 }
155
156}