blob: 2e632edd69390784a3b3cee568f185db3fdfca8e [file] [log] [blame]
alshabib7bb05012015-08-05 10:15:09 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
alshabib7bb05012015-08-05 10:15:09 -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;
alshabib7bb05012015-08-05 10:15:09 -070017
Jordi Ortizaa8de492016-12-01 00:21:36 +010018import org.onosproject.net.DeviceId;
alshabib7bb05012015-08-05 10:15:09 -070019import org.onosproject.store.Store;
20
21import java.util.Collection;
alshabibeadfc8e2015-08-18 15:40:46 -070022import java.util.concurrent.CompletableFuture;
alshabib7bb05012015-08-05 10:15:09 -070023
24/**
25 * Entity that stores and distributed meter objects.
26 */
27public interface MeterStore extends Store<MeterEvent, MeterStoreDelegate> {
28
29 /**
Wailok Shum6a249352021-07-29 00:02:56 +080030 * Adds a meter to the store or updates a meter in the store.
alshabib7bb05012015-08-05 10:15:09 -070031 *
32 * @param meter a meter
alshabibeadfc8e2015-08-18 15:40:46 -070033 * @return a future indicating the result of the store operation
alshabib7bb05012015-08-05 10:15:09 -070034 */
Wailok Shum6a249352021-07-29 00:02:56 +080035 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
alshabibeadfc8e2015-08-18 15:40:46 -070045 CompletableFuture<MeterStoreResult> storeMeter(Meter meter);
alshabib7bb05012015-08-05 10:15:09 -070046
47 /**
48 * Deletes a meter from the store.
49 *
50 * @param meter a meter
alshabibeadfc8e2015-08-18 15:40:46 -070051 * @return a future indicating the result of the store operation
alshabib7bb05012015-08-05 10:15:09 -070052 */
alshabibeadfc8e2015-08-18 15:40:46 -070053 CompletableFuture<MeterStoreResult> deleteMeter(Meter meter);
alshabib7bb05012015-08-05 10:15:09 -070054
Jordi Ortizaa8de492016-12-01 00:21:36 +010055 /**
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 Shum6a249352021-07-29 00:02:56 +080064 * 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 Ortizaa8de492016-12-01 00:21:36 +010072 * 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
alshabib7bb05012015-08-05 10:15:09 -070079 /**
Wailok Shum6a249352021-07-29 00:02:56 +080080 * 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 /**
alshabib7bb05012015-08-05 10:15:09 -070088 * Updates a meter whose meter id is the same as the passed meter.
89 *
90 * @param meter a new meter
alshabibeadfc8e2015-08-18 15:40:46 -070091 * @return a future indicating the result of the store operation
Wailok Shum6a249352021-07-29 00:02:56 +080092 * @deprecated in onos-2.5 replaced by {@link #addOrUpdateMeter(Meter)}
alshabib7bb05012015-08-05 10:15:09 -070093 */
Wailok Shum6a249352021-07-29 00:02:56 +080094 @Deprecated
alshabibeadfc8e2015-08-18 15:40:46 -070095 CompletableFuture<MeterStoreResult> updateMeter(Meter meter);
alshabib7bb05012015-08-05 10:15:09 -070096
97 /**
98 * Updates a given meter's state with the provided state.
alshabibeadfc8e2015-08-18 15:40:46 -070099 *
alshabib7bb05012015-08-05 10:15:09 -0700100 * @param meter a meter
pierventre44220052020-09-22 12:51:06 +0200101 * @return the updated meter
alshabib7bb05012015-08-05 10:15:09 -0700102 */
pierventre44220052020-09-22 12:51:06 +0200103 Meter updateMeterState(Meter meter);
alshabib7bb05012015-08-05 10:15:09 -0700104
105 /**
alshabib70aaa1b2015-09-25 14:30:59 -0700106 * Obtains a meter matching the given meter key.
alshabib7bb05012015-08-05 10:15:09 -0700107 *
alshabib70aaa1b2015-09-25 14:30:59 -0700108 * @param key a meter key
alshabib7bb05012015-08-05 10:15:09 -0700109 * @return a meter
110 */
alshabib70aaa1b2015-09-25 14:30:59 -0700111 Meter getMeter(MeterKey key);
alshabib7bb05012015-08-05 10:15:09 -0700112
113 /**
114 * Returns all meters stored in the store.
115 *
pierventre44220052020-09-22 12:51:06 +0200116 * @return an immutable copy of all meters
alshabib7bb05012015-08-05 10:15:09 -0700117 */
118 Collection<Meter> getAllMeters();
119
120 /**
Jordi Ortiz9287b632017-06-22 11:01:37 +0200121 * Returns all meters stored in the store for a
122 * precise device.
123 *
124 * @param deviceId the device to get the meter list from
pierventre44220052020-09-22 12:51:06 +0200125 * @return an immutable copy of the meters stored for a given device
Jordi Ortiz9287b632017-06-22 11:01:37 +0200126 */
127 Collection<Meter> getAllMeters(DeviceId deviceId);
128
129 /**
alshabib7bb05012015-08-05 10:15:09 -0700130 * 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 Abakaf57ef602019-03-11 06:52:48 +0000134 * @param op a failed meter operation
alshabib7bb05012015-08-05 10:15:09 -0700135 * @param reason a failure reason
136 */
137 void failedMeter(MeterOperation op, MeterFailReason reason);
alshabib5eb79392015-08-19 18:09:55 -0700138
139 /**
140 * Delete this meter immediately.
Gamze Abakaf57ef602019-03-11 06:52:48 +0000141 *
alshabib5eb79392015-08-19 18:09:55 -0700142 * @param m a meter
Wailok Shumf013a782021-07-26 16:51:01 +0800143 * @deprecated in onos-2.5 renamed {@link #purgeMeter(Meter)}
alshabib5eb79392015-08-19 18:09:55 -0700144 */
Wailok Shumf013a782021-07-26 16:51:01 +0800145 @Deprecated
alshabib5eb79392015-08-19 18:09:55 -0700146 void deleteMeterNow(Meter m);
147
Jordi Ortizaa8de492016-12-01 00:21:36 +0100148 /**
Wailok Shumf013a782021-07-26 16:51:01 +0800149 * Delete this meter immediately.
150 *
151 * @param m a meter
152 */
153 void purgeMeter(Meter m);
154
155 /**
Jordi Ortizaa8de492016-12-01 00:21:36 +0100156 * 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 Shumf013a782021-07-26 16:51:01 +0800160 * @deprecated in onos-2.5, Max meters is replaced by start and end index
Jordi Ortizaa8de492016-12-01 00:21:36 +0100161 */
Wailok Shumf013a782021-07-26 16:51:01 +0800162 @Deprecated
Jordi Ortizaa8de492016-12-01 00:21:36 +0100163 long getMaxMeters(MeterFeaturesKey key);
164
Jordi Ortiz6c847762017-01-30 17:13:05 +0100165 /**
Pier Luigif094c612017-10-14 12:15:02 +0200166 * Allocates the first available MeterId.
Jordi Ortiz6c847762017-01-30 17:13:05 +0100167 *
168 * @param deviceId the device id
Pier Luigif094c612017-10-14 12:15:02 +0200169 * @return the meter Id or null if it was not possible
170 * to allocate a meter id
Wailok Shumf013a782021-07-26 16:51:01 +0800171 * @deprecated in onos-2.5 replaced by {@link #allocateMeterId(DeviceId, MeterScope)}
Jordi Ortiz6c847762017-01-30 17:13:05 +0100172 */
Wailok Shumf013a782021-07-26 16:51:01 +0800173 @Deprecated
Pier Luigif094c612017-10-14 12:15:02 +0200174 MeterId allocateMeterId(DeviceId deviceId);
175
176 /**
Wailok Shumf013a782021-07-26 16:51:01 +0800177 * 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 Luigif094c612017-10-14 12:15:02 +0200187 * Frees the given meter id.
188 *
189 * @param deviceId the device id
Gamze Abakaf57ef602019-03-11 06:52:48 +0000190 * @param meterId the id to be freed
Wailok Shumf013a782021-07-26 16:51:01 +0800191 * @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 Luigif094c612017-10-14 12:15:02 +0200193 */
Wailok Shumf013a782021-07-26 16:51:01 +0800194 @Deprecated
Pier Luigif094c612017-10-14 12:15:02 +0200195 void freeMeterId(DeviceId deviceId, MeterId meterId);
Jordi Ortiz6c847762017-01-30 17:13:05 +0100196
Gamze Abakaf57ef602019-03-11 06:52:48 +0000197 /**
198 * Removes all meters of given device from store.
199 *
200 * @param deviceId the device id
201 */
202 void purgeMeter(DeviceId deviceId);
203
alshabib7bb05012015-08-05 10:15:09 -0700204}