alshabib | 7bb0501 | 2015-08-05 10:15:09 -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 | 7bb0501 | 2015-08-05 10:15:09 -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 | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 17 | |
Jordi Ortiz | aa8de49 | 2016-12-01 00:21:36 +0100 | [diff] [blame] | 18 | import org.onosproject.net.DeviceId; |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 19 | import org.onosproject.store.Store; |
| 20 | |
| 21 | import java.util.Collection; |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 22 | import java.util.concurrent.CompletableFuture; |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Entity that stores and distributed meter objects. |
| 26 | */ |
| 27 | public interface MeterStore extends Store<MeterEvent, MeterStoreDelegate> { |
| 28 | |
| 29 | /** |
Wailok Shum | 48da0e1 | 2021-07-29 00:02:56 +0800 | [diff] [blame^] | 30 | * Adds a meter to the store or updates a meter in the store. |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 31 | * |
| 32 | * @param meter a meter |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 33 | * @return a future indicating the result of the store operation |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 34 | */ |
Wailok Shum | 48da0e1 | 2021-07-29 00:02:56 +0800 | [diff] [blame^] | 35 | CompletableFuture<MeterStoreResult> addOrUpdateMeter(Meter meter); |
| 36 | |
| 37 | /** |
| 38 | * Adds a meter to the store. |
| 39 | * |
| 40 | * @param meter a meter |
| 41 | * @return a future indicating the result of the store operation |
| 42 | * @deprecated in onos-2.5 replaced by {@link #addOrUpdateMeter(Meter)} |
| 43 | */ |
| 44 | @Deprecated |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 45 | CompletableFuture<MeterStoreResult> storeMeter(Meter meter); |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 46 | |
| 47 | /** |
| 48 | * Deletes a meter from the store. |
| 49 | * |
| 50 | * @param meter a meter |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 51 | * @return a future indicating the result of the store operation |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 52 | */ |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 53 | CompletableFuture<MeterStoreResult> deleteMeter(Meter meter); |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 54 | |
Jordi Ortiz | aa8de49 | 2016-12-01 00:21:36 +0100 | [diff] [blame] | 55 | /** |
| 56 | * Adds the meter features to the store. |
| 57 | * |
| 58 | * @param meterfeatures the meter features |
| 59 | * @return the result of the store operation |
| 60 | */ |
| 61 | MeterStoreResult storeMeterFeatures(MeterFeatures meterfeatures); |
| 62 | |
| 63 | /** |
Wailok Shum | 48da0e1 | 2021-07-29 00:02:56 +0800 | [diff] [blame^] | 64 | * Adds a collection of meter features to the store. |
| 65 | * |
| 66 | * @param meterfeatures the collection of meter features |
| 67 | * @return the result of the store operation |
| 68 | */ |
| 69 | MeterStoreResult storeMeterFeatures(Collection<MeterFeatures> meterfeatures); |
| 70 | |
| 71 | /** |
Jordi Ortiz | aa8de49 | 2016-12-01 00:21:36 +0100 | [diff] [blame] | 72 | * Deletes the meter features from the store. |
| 73 | * |
| 74 | * @param deviceId the device id |
| 75 | * @return a future indicating the result of the store operation |
| 76 | */ |
| 77 | MeterStoreResult deleteMeterFeatures(DeviceId deviceId); |
| 78 | |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 79 | /** |
Wailok Shum | 48da0e1 | 2021-07-29 00:02:56 +0800 | [diff] [blame^] | 80 | * Deletes a collection of meter features from the store. |
| 81 | * |
| 82 | * @param meterfeatures a collection of meter features |
| 83 | * @return a future indicating the result of the store operation |
| 84 | */ |
| 85 | MeterStoreResult deleteMeterFeatures(Collection<MeterFeatures> meterfeatures); |
| 86 | |
| 87 | /** |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 88 | * Updates a meter whose meter id is the same as the passed meter. |
| 89 | * |
| 90 | * @param meter a new meter |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 91 | * @return a future indicating the result of the store operation |
Wailok Shum | 48da0e1 | 2021-07-29 00:02:56 +0800 | [diff] [blame^] | 92 | * @deprecated in onos-2.5 replaced by {@link #addOrUpdateMeter(Meter)} |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 93 | */ |
Wailok Shum | 48da0e1 | 2021-07-29 00:02:56 +0800 | [diff] [blame^] | 94 | @Deprecated |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 95 | CompletableFuture<MeterStoreResult> updateMeter(Meter meter); |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 96 | |
| 97 | /** |
| 98 | * Updates a given meter's state with the provided state. |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 99 | * |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 100 | * @param meter a meter |
pierventre | 4422005 | 2020-09-22 12:51:06 +0200 | [diff] [blame] | 101 | * @return the updated meter |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 102 | */ |
pierventre | 4422005 | 2020-09-22 12:51:06 +0200 | [diff] [blame] | 103 | Meter updateMeterState(Meter meter); |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 104 | |
| 105 | /** |
alshabib | 70aaa1b | 2015-09-25 14:30:59 -0700 | [diff] [blame] | 106 | * Obtains a meter matching the given meter key. |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 107 | * |
alshabib | 70aaa1b | 2015-09-25 14:30:59 -0700 | [diff] [blame] | 108 | * @param key a meter key |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 109 | * @return a meter |
| 110 | */ |
alshabib | 70aaa1b | 2015-09-25 14:30:59 -0700 | [diff] [blame] | 111 | Meter getMeter(MeterKey key); |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * Returns all meters stored in the store. |
| 115 | * |
pierventre | 4422005 | 2020-09-22 12:51:06 +0200 | [diff] [blame] | 116 | * @return an immutable copy of all meters |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 117 | */ |
| 118 | Collection<Meter> getAllMeters(); |
| 119 | |
| 120 | /** |
Jordi Ortiz | 9287b63 | 2017-06-22 11:01:37 +0200 | [diff] [blame] | 121 | * Returns all meters stored in the store for a |
| 122 | * precise device. |
| 123 | * |
| 124 | * @param deviceId the device to get the meter list from |
pierventre | 4422005 | 2020-09-22 12:51:06 +0200 | [diff] [blame] | 125 | * @return an immutable copy of the meters stored for a given device |
Jordi Ortiz | 9287b63 | 2017-06-22 11:01:37 +0200 | [diff] [blame] | 126 | */ |
| 127 | Collection<Meter> getAllMeters(DeviceId deviceId); |
| 128 | |
| 129 | /** |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 130 | * Update the store by deleting the failed meter. |
| 131 | * Notifies the delegate that the meter failed to allow it |
| 132 | * to nofity the app. |
| 133 | * |
Gamze Abaka | f57ef60 | 2019-03-11 06:52:48 +0000 | [diff] [blame] | 134 | * @param op a failed meter operation |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 135 | * @param reason a failure reason |
| 136 | */ |
| 137 | void failedMeter(MeterOperation op, MeterFailReason reason); |
alshabib | 5eb7939 | 2015-08-19 18:09:55 -0700 | [diff] [blame] | 138 | |
| 139 | /** |
| 140 | * Delete this meter immediately. |
Gamze Abaka | f57ef60 | 2019-03-11 06:52:48 +0000 | [diff] [blame] | 141 | * |
alshabib | 5eb7939 | 2015-08-19 18:09:55 -0700 | [diff] [blame] | 142 | * @param m a meter |
Wailok Shum | be89723 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 143 | * @deprecated in onos-2.5 renamed {@link #purgeMeter(Meter)} |
alshabib | 5eb7939 | 2015-08-19 18:09:55 -0700 | [diff] [blame] | 144 | */ |
Wailok Shum | be89723 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 145 | @Deprecated |
alshabib | 5eb7939 | 2015-08-19 18:09:55 -0700 | [diff] [blame] | 146 | void deleteMeterNow(Meter m); |
| 147 | |
Jordi Ortiz | aa8de49 | 2016-12-01 00:21:36 +0100 | [diff] [blame] | 148 | /** |
Wailok Shum | be89723 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 149 | * Delete this meter immediately. |
| 150 | * |
| 151 | * @param m a meter |
| 152 | */ |
| 153 | void purgeMeter(Meter m); |
| 154 | |
| 155 | /** |
Jordi Ortiz | aa8de49 | 2016-12-01 00:21:36 +0100 | [diff] [blame] | 156 | * Retrieve maximum meters available for the device. |
| 157 | * |
| 158 | * @param key the meter features key |
| 159 | * @return the maximum number of meters supported by the device |
Wailok Shum | be89723 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 160 | * @deprecated in onos-2.5, Max meters is replaced by start and end index |
Jordi Ortiz | aa8de49 | 2016-12-01 00:21:36 +0100 | [diff] [blame] | 161 | */ |
Wailok Shum | be89723 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 162 | @Deprecated |
Jordi Ortiz | aa8de49 | 2016-12-01 00:21:36 +0100 | [diff] [blame] | 163 | long getMaxMeters(MeterFeaturesKey key); |
| 164 | |
Jordi Ortiz | 6c84776 | 2017-01-30 17:13:05 +0100 | [diff] [blame] | 165 | /** |
Pier Luigi | f094c61 | 2017-10-14 12:15:02 +0200 | [diff] [blame] | 166 | * Allocates the first available MeterId. |
Jordi Ortiz | 6c84776 | 2017-01-30 17:13:05 +0100 | [diff] [blame] | 167 | * |
| 168 | * @param deviceId the device id |
Pier Luigi | f094c61 | 2017-10-14 12:15:02 +0200 | [diff] [blame] | 169 | * @return the meter Id or null if it was not possible |
| 170 | * to allocate a meter id |
Wailok Shum | be89723 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 171 | * @deprecated in onos-2.5 replaced by {@link #allocateMeterId(DeviceId, MeterScope)} |
Jordi Ortiz | 6c84776 | 2017-01-30 17:13:05 +0100 | [diff] [blame] | 172 | */ |
Wailok Shum | be89723 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 173 | @Deprecated |
Pier Luigi | f094c61 | 2017-10-14 12:15:02 +0200 | [diff] [blame] | 174 | MeterId allocateMeterId(DeviceId deviceId); |
| 175 | |
| 176 | /** |
Wailok Shum | be89723 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 177 | * Allocates the first available MeterId. |
| 178 | * |
| 179 | * @param deviceId the device id |
| 180 | * @param meterScope the meter scope |
| 181 | * @return the meter Id or null if it was not possible |
| 182 | * to allocate a meter id |
| 183 | */ |
| 184 | MeterCellId allocateMeterId(DeviceId deviceId, MeterScope meterScope); |
| 185 | |
| 186 | /** |
Pier Luigi | f094c61 | 2017-10-14 12:15:02 +0200 | [diff] [blame] | 187 | * Frees the given meter id. |
| 188 | * |
| 189 | * @param deviceId the device id |
Gamze Abaka | f57ef60 | 2019-03-11 06:52:48 +0000 | [diff] [blame] | 190 | * @param meterId the id to be freed |
Wailok Shum | be89723 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 191 | * @deprecated in onos-2.5, freeing an ID is closely related to removal of a meter |
| 192 | * so, this function is no longer exposed on interface |
Pier Luigi | f094c61 | 2017-10-14 12:15:02 +0200 | [diff] [blame] | 193 | */ |
Wailok Shum | be89723 | 2021-07-26 16:51:01 +0800 | [diff] [blame] | 194 | @Deprecated |
Pier Luigi | f094c61 | 2017-10-14 12:15:02 +0200 | [diff] [blame] | 195 | void freeMeterId(DeviceId deviceId, MeterId meterId); |
Jordi Ortiz | 6c84776 | 2017-01-30 17:13:05 +0100 | [diff] [blame] | 196 | |
Gamze Abaka | f57ef60 | 2019-03-11 06:52:48 +0000 | [diff] [blame] | 197 | /** |
| 198 | * Removes all meters of given device from store. |
| 199 | * |
| 200 | * @param deviceId the device id |
| 201 | */ |
| 202 | void purgeMeter(DeviceId deviceId); |
| 203 | |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 204 | } |