alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 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 | */ |
alshabib | 10c810b | 2015-08-18 16:59:04 -0700 | [diff] [blame] | 16 | package org.onosproject.net.meter; |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 17 | |
Daniele Moro | 43ac289 | 2021-07-15 17:02:59 +0200 | [diff] [blame] | 18 | import org.onosproject.core.ApplicationId; |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 19 | import org.onosproject.event.ListenerService; |
alshabib | 70aaa1b | 2015-09-25 14:30:59 -0700 | [diff] [blame] | 20 | import org.onosproject.net.DeviceId; |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 21 | |
alshabib | 58fe6dc | 2015-08-19 17:16:13 -0700 | [diff] [blame] | 22 | import java.util.Collection; |
| 23 | |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 24 | /** |
| 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 | */ |
| 29 | public interface MeterService |
| 30 | extends ListenerService<MeterEvent, MeterListener> { |
| 31 | |
| 32 | /** |
| 33 | * Adds a meter to the system and performs it installation. |
| 34 | * |
alshabib | e1248b6 | 2015-08-20 17:21:55 -0700 | [diff] [blame] | 35 | * @param meter a meter |
| 36 | * @return a meter (with a meter id) |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 37 | */ |
alshabib | e1248b6 | 2015-08-20 17:21:55 -0700 | [diff] [blame] | 38 | Meter submit(MeterRequest meter); |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * Remove a meter from the system and the dataplane. |
| 42 | * |
| 43 | * @param meter a meter to remove |
alshabib | e1248b6 | 2015-08-20 17:21:55 -0700 | [diff] [blame] | 44 | * @param meterId the meter id of the meter to remove. |
Wailok Shum | 7991952 | 2021-08-22 19:35:34 +0800 | [diff] [blame] | 45 | * @deprecated in onos-2.5, replace MeterId with MeterCellId |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 46 | */ |
Wailok Shum | 7991952 | 2021-08-22 19:35:34 +0800 | [diff] [blame] | 47 | @Deprecated |
alshabib | e1248b6 | 2015-08-20 17:21:55 -0700 | [diff] [blame] | 48 | void withdraw(MeterRequest meter, MeterId meterId); |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 49 | |
| 50 | /** |
Wailok Shum | 7991952 | 2021-08-22 19:35:34 +0800 | [diff] [blame] | 51 | * Remove a meter from the system and the dataplane. |
| 52 | * |
| 53 | * @param meter a meter to remove |
| 54 | * @param meterCellId the meter cell id of the meter to remove. |
| 55 | */ |
| 56 | void withdraw(MeterRequest meter, MeterCellId meterCellId); |
| 57 | |
| 58 | /** |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 59 | * Fetch the meter by the meter id. |
| 60 | * |
alshabib | 70aaa1b | 2015-09-25 14:30:59 -0700 | [diff] [blame] | 61 | * @param deviceId a device id |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 62 | * @param id a meter id |
| 63 | * @return a meter |
Wailok Shum | 7991952 | 2021-08-22 19:35:34 +0800 | [diff] [blame] | 64 | * @deprecated in onos-2.5, Replace MeterId with MeterCellId |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 65 | */ |
Wailok Shum | 7991952 | 2021-08-22 19:35:34 +0800 | [diff] [blame] | 66 | @Deprecated |
alshabib | 70aaa1b | 2015-09-25 14:30:59 -0700 | [diff] [blame] | 67 | Meter getMeter(DeviceId deviceId, MeterId id); |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 68 | |
| 69 | /** |
Wailok Shum | 7991952 | 2021-08-22 19:35:34 +0800 | [diff] [blame] | 70 | * Fetch the meter by the meter id. |
| 71 | * |
| 72 | * @param deviceId a device id |
| 73 | * @param id a meter cell id |
| 74 | * @return a meter |
| 75 | */ |
| 76 | Meter getMeter(DeviceId deviceId, MeterCellId id); |
| 77 | |
| 78 | /** |
alshabib | 58fe6dc | 2015-08-19 17:16:13 -0700 | [diff] [blame] | 79 | * Fetches all the meters. |
| 80 | * |
| 81 | * @return a collection of meters |
| 82 | */ |
| 83 | Collection<Meter> getAllMeters(); |
| 84 | |
Jian Li | 1932b93 | 2016-01-03 00:35:40 -0800 | [diff] [blame] | 85 | /** |
| 86 | * Fetches the meters by the device id. |
| 87 | * |
| 88 | * @param deviceId a device id |
| 89 | * @return a collection of meters |
| 90 | */ |
| 91 | Collection<Meter> getMeters(DeviceId deviceId); |
Pier Luigi | bdcd967 | 2017-10-13 13:54:48 +0200 | [diff] [blame] | 92 | |
| 93 | /** |
pierventre | c0914ec | 2021-08-27 15:25:02 +0200 | [diff] [blame] | 94 | * Fetches the meters by the device id and scope. |
| 95 | * |
| 96 | * @param deviceId a device id |
| 97 | * @param scope meters scope |
| 98 | * @return a collection of meters |
| 99 | */ |
| 100 | Collection<Meter> getMeters(DeviceId deviceId, MeterScope scope); |
| 101 | |
| 102 | /** |
Pier Luigi | bdcd967 | 2017-10-13 13:54:48 +0200 | [diff] [blame] | 103 | * Allocates a new meter id in the system. |
| 104 | * |
| 105 | * @param deviceId the device id |
| 106 | * @return the allocated meter id, null if there is an internal error |
| 107 | * or there are no meter ids available |
Wailok Shum | f013a78 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 108 | * @deprecated in onos-2.5 |
Pier Luigi | bdcd967 | 2017-10-13 13:54:48 +0200 | [diff] [blame] | 109 | */ |
Wailok Shum | f013a78 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 110 | @Deprecated |
Pier Luigi | bdcd967 | 2017-10-13 13:54:48 +0200 | [diff] [blame] | 111 | MeterId allocateMeterId(DeviceId deviceId); |
| 112 | |
| 113 | /** |
| 114 | * Frees the given meter id. |
| 115 | * |
| 116 | * @param deviceId the device id |
| 117 | * @param meterId the id to be freed |
Wailok Shum | f013a78 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 118 | * @deprecated in onos-2.5 |
Pier Luigi | bdcd967 | 2017-10-13 13:54:48 +0200 | [diff] [blame] | 119 | */ |
Wailok Shum | f013a78 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 120 | @Deprecated |
Pier Luigi | bdcd967 | 2017-10-13 13:54:48 +0200 | [diff] [blame] | 121 | void freeMeterId(DeviceId deviceId, MeterId meterId); |
Andrea Campanella | 2325050 | 2020-05-13 15:36:57 +0200 | [diff] [blame] | 122 | |
| 123 | /** |
| 124 | * Purges all the meters on the specified device. |
| 125 | * @param deviceId device identifier |
| 126 | */ |
Daniele Moro | 43ac289 | 2021-07-15 17:02:59 +0200 | [diff] [blame] | 127 | default void purgeMeters(DeviceId deviceId) { |
pierventre | 26ac151 | 2021-09-10 09:37:29 +0200 | [diff] [blame] | 128 | throw new UnsupportedOperationException("purgeMeters not implemented"); |
Andrea Campanella | 2325050 | 2020-05-13 15:36:57 +0200 | [diff] [blame] | 129 | } |
| 130 | |
Daniele Moro | 43ac289 | 2021-07-15 17:02:59 +0200 | [diff] [blame] | 131 | /** |
| 132 | * Purges all the meters on the given device and for the given application. |
| 133 | * |
| 134 | * @param deviceId device identifier |
| 135 | * @param appId application identifier |
| 136 | */ |
| 137 | default void purgeMeters(DeviceId deviceId, ApplicationId appId) { |
| 138 | throw new UnsupportedOperationException("purgeMeter not implemented"); |
| 139 | } |
| 140 | |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 141 | } |