blob: 6339101ae475355e8810af504c050e5b5fc9576b [file] [log] [blame]
alshabib1d2bc402015-07-31 17:04:11 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
alshabib1d2bc402015-07-31 17:04:11 -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 */
alshabib10c810b2015-08-18 16:59:04 -070016package org.onosproject.net.meter;
alshabib1d2bc402015-07-31 17:04:11 -070017
Daniele Moro43ac2892021-07-15 17:02:59 +020018import org.onosproject.core.ApplicationId;
alshabib1d2bc402015-07-31 17:04:11 -070019import org.onosproject.event.ListenerService;
alshabib70aaa1b2015-09-25 14:30:59 -070020import org.onosproject.net.DeviceId;
alshabib1d2bc402015-07-31 17:04:11 -070021
alshabib58fe6dc2015-08-19 17:16:13 -070022import java.util.Collection;
23
alshabib1d2bc402015-07-31 17:04:11 -070024/**
25 * Service for add/updating and removing meters. Meters are
26 * are assigned to flow to rate limit them and provide a certain
27 * quality of service.
28 */
29public interface MeterService
30 extends ListenerService<MeterEvent, MeterListener> {
31
32 /**
33 * Adds a meter to the system and performs it installation.
34 *
alshabibe1248b62015-08-20 17:21:55 -070035 * @param meter a meter
36 * @return a meter (with a meter id)
alshabib1d2bc402015-07-31 17:04:11 -070037 */
alshabibe1248b62015-08-20 17:21:55 -070038 Meter submit(MeterRequest meter);
alshabib1d2bc402015-07-31 17:04:11 -070039
40 /**
41 * Remove a meter from the system and the dataplane.
42 *
43 * @param meter a meter to remove
alshabibe1248b62015-08-20 17:21:55 -070044 * @param meterId the meter id of the meter to remove.
alshabib1d2bc402015-07-31 17:04:11 -070045 */
alshabibe1248b62015-08-20 17:21:55 -070046 void withdraw(MeterRequest meter, MeterId meterId);
alshabib1d2bc402015-07-31 17:04:11 -070047
48 /**
49 * Fetch the meter by the meter id.
50 *
alshabib70aaa1b2015-09-25 14:30:59 -070051 * @param deviceId a device id
alshabib1d2bc402015-07-31 17:04:11 -070052 * @param id a meter id
53 * @return a meter
54 */
alshabib70aaa1b2015-09-25 14:30:59 -070055 Meter getMeter(DeviceId deviceId, MeterId id);
alshabib1d2bc402015-07-31 17:04:11 -070056
57 /**
alshabib58fe6dc2015-08-19 17:16:13 -070058 * Fetches all the meters.
59 *
60 * @return a collection of meters
61 */
62 Collection<Meter> getAllMeters();
63
Jian Li1932b932016-01-03 00:35:40 -080064 /**
65 * Fetches the meters by the device id.
66 *
67 * @param deviceId a device id
68 * @return a collection of meters
69 */
70 Collection<Meter> getMeters(DeviceId deviceId);
Pier Luigibdcd9672017-10-13 13:54:48 +020071
72 /**
73 * Allocates a new meter id in the system.
74 *
75 * @param deviceId the device id
76 * @return the allocated meter id, null if there is an internal error
77 * or there are no meter ids available
Wailok Shumf013a782021-07-26 16:51:01 +080078 * @deprecated in onos-2.5
Pier Luigibdcd9672017-10-13 13:54:48 +020079 */
Wailok Shumf013a782021-07-26 16:51:01 +080080 @Deprecated
Pier Luigibdcd9672017-10-13 13:54:48 +020081 MeterId allocateMeterId(DeviceId deviceId);
82
83 /**
84 * Frees the given meter id.
85 *
86 * @param deviceId the device id
87 * @param meterId the id to be freed
Wailok Shumf013a782021-07-26 16:51:01 +080088 * @deprecated in onos-2.5
Pier Luigibdcd9672017-10-13 13:54:48 +020089 */
Wailok Shumf013a782021-07-26 16:51:01 +080090 @Deprecated
Pier Luigibdcd9672017-10-13 13:54:48 +020091 void freeMeterId(DeviceId deviceId, MeterId meterId);
Andrea Campanella23250502020-05-13 15:36:57 +020092
93 /**
94 * Purges all the meters on the specified device.
95 * @param deviceId device identifier
96 */
Daniele Moro43ac2892021-07-15 17:02:59 +020097 default void purgeMeters(DeviceId deviceId) {
Andrea Campanella23250502020-05-13 15:36:57 +020098 //Default implementation does nothing
99 }
100
Daniele Moro43ac2892021-07-15 17:02:59 +0200101 /**
102 * Purges all the meters on the given device and for the given application.
103 *
104 * @param deviceId device identifier
105 * @param appId application identifier
106 */
107 default void purgeMeters(DeviceId deviceId, ApplicationId appId) {
108 throw new UnsupportedOperationException("purgeMeter not implemented");
109 }
110
alshabib1d2bc402015-07-31 17:04:11 -0700111}