blob: 21696e44377db3a1a9a91711e8ba6558e486752b [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 /**
30 * Adds a meter to the store.
31 *
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 */
alshabibeadfc8e2015-08-18 15:40:46 -070035 CompletableFuture<MeterStoreResult> storeMeter(Meter meter);
alshabib7bb05012015-08-05 10:15:09 -070036
37 /**
38 * Deletes a meter from the store.
39 *
40 * @param meter a meter
alshabibeadfc8e2015-08-18 15:40:46 -070041 * @return a future indicating the result of the store operation
alshabib7bb05012015-08-05 10:15:09 -070042 */
alshabibeadfc8e2015-08-18 15:40:46 -070043 CompletableFuture<MeterStoreResult> deleteMeter(Meter meter);
alshabib7bb05012015-08-05 10:15:09 -070044
Jordi Ortizaa8de492016-12-01 00:21:36 +010045 /**
46 * Adds the meter features to the store.
47 *
48 * @param meterfeatures the meter features
49 * @return the result of the store operation
50 */
51 MeterStoreResult storeMeterFeatures(MeterFeatures meterfeatures);
52
53 /**
54 * Deletes the meter features from the store.
55 *
56 * @param deviceId the device id
57 * @return a future indicating the result of the store operation
58 */
59 MeterStoreResult deleteMeterFeatures(DeviceId deviceId);
60
alshabib7bb05012015-08-05 10:15:09 -070061 /**
62 * Updates a meter whose meter id is the same as the passed meter.
63 *
64 * @param meter a new meter
alshabibeadfc8e2015-08-18 15:40:46 -070065 * @return a future indicating the result of the store operation
alshabib7bb05012015-08-05 10:15:09 -070066 */
alshabibeadfc8e2015-08-18 15:40:46 -070067 CompletableFuture<MeterStoreResult> updateMeter(Meter meter);
alshabib7bb05012015-08-05 10:15:09 -070068
69 /**
70 * Updates a given meter's state with the provided state.
alshabibeadfc8e2015-08-18 15:40:46 -070071 *
alshabib7bb05012015-08-05 10:15:09 -070072 * @param meter a meter
pierventre44220052020-09-22 12:51:06 +020073 * @return the updated meter
alshabib7bb05012015-08-05 10:15:09 -070074 */
pierventre44220052020-09-22 12:51:06 +020075 Meter updateMeterState(Meter meter);
alshabib7bb05012015-08-05 10:15:09 -070076
77 /**
alshabib70aaa1b2015-09-25 14:30:59 -070078 * Obtains a meter matching the given meter key.
alshabib7bb05012015-08-05 10:15:09 -070079 *
alshabib70aaa1b2015-09-25 14:30:59 -070080 * @param key a meter key
alshabib7bb05012015-08-05 10:15:09 -070081 * @return a meter
82 */
alshabib70aaa1b2015-09-25 14:30:59 -070083 Meter getMeter(MeterKey key);
alshabib7bb05012015-08-05 10:15:09 -070084
85 /**
86 * Returns all meters stored in the store.
87 *
pierventre44220052020-09-22 12:51:06 +020088 * @return an immutable copy of all meters
alshabib7bb05012015-08-05 10:15:09 -070089 */
90 Collection<Meter> getAllMeters();
91
92 /**
Jordi Ortiz9287b632017-06-22 11:01:37 +020093 * Returns all meters stored in the store for a
94 * precise device.
95 *
96 * @param deviceId the device to get the meter list from
pierventre44220052020-09-22 12:51:06 +020097 * @return an immutable copy of the meters stored for a given device
Jordi Ortiz9287b632017-06-22 11:01:37 +020098 */
99 Collection<Meter> getAllMeters(DeviceId deviceId);
100
101 /**
alshabib7bb05012015-08-05 10:15:09 -0700102 * Update the store by deleting the failed meter.
103 * Notifies the delegate that the meter failed to allow it
104 * to nofity the app.
105 *
Gamze Abakaf57ef602019-03-11 06:52:48 +0000106 * @param op a failed meter operation
alshabib7bb05012015-08-05 10:15:09 -0700107 * @param reason a failure reason
108 */
109 void failedMeter(MeterOperation op, MeterFailReason reason);
alshabib5eb79392015-08-19 18:09:55 -0700110
111 /**
112 * Delete this meter immediately.
Gamze Abakaf57ef602019-03-11 06:52:48 +0000113 *
alshabib5eb79392015-08-19 18:09:55 -0700114 * @param m a meter
Wailok Shumf013a782021-07-26 16:51:01 +0800115 * @deprecated in onos-2.5 renamed {@link #purgeMeter(Meter)}
alshabib5eb79392015-08-19 18:09:55 -0700116 */
Wailok Shumf013a782021-07-26 16:51:01 +0800117 @Deprecated
alshabib5eb79392015-08-19 18:09:55 -0700118 void deleteMeterNow(Meter m);
119
Jordi Ortizaa8de492016-12-01 00:21:36 +0100120 /**
Wailok Shumf013a782021-07-26 16:51:01 +0800121 * Delete this meter immediately.
122 *
123 * @param m a meter
124 */
125 void purgeMeter(Meter m);
126
127 /**
Jordi Ortizaa8de492016-12-01 00:21:36 +0100128 * Retrieve maximum meters available for the device.
129 *
130 * @param key the meter features key
131 * @return the maximum number of meters supported by the device
Wailok Shumf013a782021-07-26 16:51:01 +0800132 * @deprecated in onos-2.5, Max meters is replaced by start and end index
Jordi Ortizaa8de492016-12-01 00:21:36 +0100133 */
Wailok Shumf013a782021-07-26 16:51:01 +0800134 @Deprecated
Jordi Ortizaa8de492016-12-01 00:21:36 +0100135 long getMaxMeters(MeterFeaturesKey key);
136
Jordi Ortiz6c847762017-01-30 17:13:05 +0100137 /**
Pier Luigif094c612017-10-14 12:15:02 +0200138 * Allocates the first available MeterId.
Jordi Ortiz6c847762017-01-30 17:13:05 +0100139 *
140 * @param deviceId the device id
Pier Luigif094c612017-10-14 12:15:02 +0200141 * @return the meter Id or null if it was not possible
142 * to allocate a meter id
Wailok Shumf013a782021-07-26 16:51:01 +0800143 * @deprecated in onos-2.5 replaced by {@link #allocateMeterId(DeviceId, MeterScope)}
Jordi Ortiz6c847762017-01-30 17:13:05 +0100144 */
Wailok Shumf013a782021-07-26 16:51:01 +0800145 @Deprecated
Pier Luigif094c612017-10-14 12:15:02 +0200146 MeterId allocateMeterId(DeviceId deviceId);
147
148 /**
Wailok Shumf013a782021-07-26 16:51:01 +0800149 * Allocates the first available MeterId.
150 *
151 * @param deviceId the device id
152 * @param meterScope the meter scope
153 * @return the meter Id or null if it was not possible
154 * to allocate a meter id
155 */
156 MeterCellId allocateMeterId(DeviceId deviceId, MeterScope meterScope);
157
158 /**
Pier Luigif094c612017-10-14 12:15:02 +0200159 * Frees the given meter id.
160 *
161 * @param deviceId the device id
Gamze Abakaf57ef602019-03-11 06:52:48 +0000162 * @param meterId the id to be freed
Wailok Shumf013a782021-07-26 16:51:01 +0800163 * @deprecated in onos-2.5, freeing an ID is closely related to removal of a meter
164 * so, this function is no longer exposed on interface
Pier Luigif094c612017-10-14 12:15:02 +0200165 */
Wailok Shumf013a782021-07-26 16:51:01 +0800166 @Deprecated
Pier Luigif094c612017-10-14 12:15:02 +0200167 void freeMeterId(DeviceId deviceId, MeterId meterId);
Jordi Ortiz6c847762017-01-30 17:13:05 +0100168
Gamze Abakaf57ef602019-03-11 06:52:48 +0000169 /**
170 * Removes all meters of given device from store.
171 *
172 * @param deviceId the device id
173 */
174 void purgeMeter(DeviceId deviceId);
175
alshabib7bb05012015-08-05 10:15:09 -0700176}