blob: b994f842499c94b0da035878d3210f4c7af04ec6 [file] [log] [blame]
alshabibe1248b62015-08-20 17:21:55 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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;
19import org.onosproject.net.DeviceId;
20
21import java.util.Collection;
22import java.util.Optional;
23
24/**
25 * Represents a generalized meter request to be deployed on a device.
26 */
27public 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();
144
145 }
146
147}