blob: 37c11055d60462bf94f4e8b5992830b5a4009889 [file] [log] [blame]
alshabib1d2bc402015-07-31 17:04:11 -07001/*
2 * Copyright 2015 Open Networking Laboratory
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 */
16package org.onosproject.incubator.net.meter;
17
18import org.onosproject.core.ApplicationId;
19import org.onosproject.net.DeviceId;
20
21import java.util.Collection;
alshabib1d2bc402015-07-31 17:04:11 -070022
23/**
24 * Represents a generalized meter to be deployed on a device.
25 */
26public interface Meter {
27
28 enum Unit {
29 /**
30 * Packets per second.
31 */
32 PKTS_PER_SEC,
33
34 /**
35 * Kilo bits per second.
36 */
37 KB_PER_SEC
38 }
39
40 /**
41 * The target device for this meter.
42 *
43 * @return a device id
44 */
45 DeviceId deviceId();
46
47 /**
48 * This meters id.
49 *
50 * @return a meter id
51 */
52 MeterId id();
53
54 /**
55 * The id of the application which created this meter.
56 *
57 * @return an application id
58 */
59 ApplicationId appId();
60
61 /**
62 * The unit used within this meter.
63 *
Ray Milkeydbbd87b2015-08-03 15:56:22 -070064 * @return the unit
alshabib1d2bc402015-07-31 17:04:11 -070065 */
66 Unit unit();
67
68 /**
69 * Signals whether this meter applies to bursts only.
70 *
71 * @return a boolean
72 */
73 boolean isBurst();
74
75 /**
76 * The collection of bands to apply on the dataplane.
77 *
78 * @return a collection of bands.
79 */
80 Collection<Band> bands();
81
82 /**
alshabib7bb05012015-08-05 10:15:09 -070083 * Fetches the state of this meter.
84 *
85 * @return a meter state
86 */
87 MeterState state();
88
89 /**
90 * The lifetime in seconds of this meter.
91 *
92 * @return number of seconds
93 */
94 long life();
95
96 /**
97 * The number of flows pointing to this meter.
98 *
99 * @return a reference count
100 */
101 long referenceCount();
102
103 /**
104 * Number of packets processed by this meter.
105 *
106 * @return a packet count
107 */
108 long packetsSeen();
109
110 /**
111 * Number of bytes processed by this meter.
112 *
113 * @return a byte count
114 */
115 long bytesSeen();
116
117 /**
alshabib1d2bc402015-07-31 17:04:11 -0700118 * A meter builder.
119 */
120 interface Builder {
121
122 /**
123 * Assigns the target device for this meter.
124 *
125 * @param deviceId a device id
126 * @return this
127 */
128 Builder forDevice(DeviceId deviceId);
129
130 /**
131 * Assigns the id to this meter.
132 *
alshabib7bb05012015-08-05 10:15:09 -0700133 * @param id a long
alshabib1d2bc402015-07-31 17:04:11 -0700134 * @return this
135 */
alshabib7bb05012015-08-05 10:15:09 -0700136 Builder withId(long id);
alshabib1d2bc402015-07-31 17:04:11 -0700137
138 /**
139 * Assigns the application that built this meter.
140 *
141 * @param appId an application id
142 * @return this
143 */
144 Builder fromApp(ApplicationId appId);
145
146 /**
147 * Assigns the @See Unit to use for this meter.
148 * Defaults to kb/s
149 *
150 * @param unit a unit
151 * @return this
152 */
153 Builder withUnit(Unit unit);
154
155 /**
156 * Sets this meter as applicable to burst traffic only.
157 * Defaults to false.
158 *
159 * @return this
160 */
161 Builder burst();
162
163 /**
164 * Assigns bands to this meter. There must be at least one band.
165 *
166 * @param bands a collection of bands
167 * @return this
168 */
169 Builder withBands(Collection<Band> bands);
170
alshabib1d2bc402015-07-31 17:04:11 -0700171 /**
172 * Builds the meter based on the specified parameters.
173 *
174 * @return a meter
175 */
176 Meter build();
177 }
178
179}