blob: 3f0efa068f93aafb9cfae8dac3fadf8e88b0d972 [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
73 */
74 void updateMeterState(Meter meter);
75
76 /**
alshabib70aaa1b2015-09-25 14:30:59 -070077 * Obtains a meter matching the given meter key.
alshabib7bb05012015-08-05 10:15:09 -070078 *
alshabib70aaa1b2015-09-25 14:30:59 -070079 * @param key a meter key
alshabib7bb05012015-08-05 10:15:09 -070080 * @return a meter
81 */
alshabib70aaa1b2015-09-25 14:30:59 -070082 Meter getMeter(MeterKey key);
alshabib7bb05012015-08-05 10:15:09 -070083
84 /**
85 * Returns all meters stored in the store.
86 *
87 * @return a collection of meters
88 */
89 Collection<Meter> getAllMeters();
90
91 /**
Jordi Ortiz9287b632017-06-22 11:01:37 +020092 * Returns all meters stored in the store for a
93 * precise device.
94 *
95 * @param deviceId the device to get the meter list from
96 * @return a collection of meters
97 */
98 Collection<Meter> getAllMeters(DeviceId deviceId);
99
100 /**
alshabib7bb05012015-08-05 10:15:09 -0700101 * Update the store by deleting the failed meter.
102 * Notifies the delegate that the meter failed to allow it
103 * to nofity the app.
104 *
Gamze Abakaf57ef602019-03-11 06:52:48 +0000105 * @param op a failed meter operation
alshabib7bb05012015-08-05 10:15:09 -0700106 * @param reason a failure reason
107 */
108 void failedMeter(MeterOperation op, MeterFailReason reason);
alshabib5eb79392015-08-19 18:09:55 -0700109
110 /**
111 * Delete this meter immediately.
Gamze Abakaf57ef602019-03-11 06:52:48 +0000112 *
alshabib5eb79392015-08-19 18:09:55 -0700113 * @param m a meter
114 */
115 void deleteMeterNow(Meter m);
116
Jordi Ortizaa8de492016-12-01 00:21:36 +0100117 /**
118 * Retrieve maximum meters available for the device.
119 *
120 * @param key the meter features key
121 * @return the maximum number of meters supported by the device
122 */
123 long getMaxMeters(MeterFeaturesKey key);
124
Jordi Ortiz6c847762017-01-30 17:13:05 +0100125 /**
Pier Luigif094c612017-10-14 12:15:02 +0200126 * Allocates the first available MeterId.
Jordi Ortiz6c847762017-01-30 17:13:05 +0100127 *
128 * @param deviceId the device id
Pier Luigif094c612017-10-14 12:15:02 +0200129 * @return the meter Id or null if it was not possible
130 * to allocate a meter id
Jordi Ortiz6c847762017-01-30 17:13:05 +0100131 */
Pier Luigif094c612017-10-14 12:15:02 +0200132 MeterId allocateMeterId(DeviceId deviceId);
133
134 /**
135 * Frees the given meter id.
136 *
137 * @param deviceId the device id
Gamze Abakaf57ef602019-03-11 06:52:48 +0000138 * @param meterId the id to be freed
Pier Luigif094c612017-10-14 12:15:02 +0200139 */
140 void freeMeterId(DeviceId deviceId, MeterId meterId);
Jordi Ortiz6c847762017-01-30 17:13:05 +0100141
Gamze Abakaf57ef602019-03-11 06:52:48 +0000142 /**
143 * Removes all meters of given device from store.
144 *
145 * @param deviceId the device id
146 */
147 void purgeMeter(DeviceId deviceId);
148
alshabib7bb05012015-08-05 10:15:09 -0700149}