blob: 675592a317c0ae24b683f0dbdc713087fc1be2fd [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
115 */
116 void deleteMeterNow(Meter m);
117
Jordi Ortizaa8de492016-12-01 00:21:36 +0100118 /**
119 * Retrieve maximum meters available for the device.
120 *
121 * @param key the meter features key
122 * @return the maximum number of meters supported by the device
123 */
124 long getMaxMeters(MeterFeaturesKey key);
125
Jordi Ortiz6c847762017-01-30 17:13:05 +0100126 /**
Pier Luigif094c612017-10-14 12:15:02 +0200127 * Allocates the first available MeterId.
Jordi Ortiz6c847762017-01-30 17:13:05 +0100128 *
129 * @param deviceId the device id
Pier Luigif094c612017-10-14 12:15:02 +0200130 * @return the meter Id or null if it was not possible
131 * to allocate a meter id
Jordi Ortiz6c847762017-01-30 17:13:05 +0100132 */
Pier Luigif094c612017-10-14 12:15:02 +0200133 MeterId allocateMeterId(DeviceId deviceId);
134
135 /**
136 * Frees the given meter id.
137 *
138 * @param deviceId the device id
Gamze Abakaf57ef602019-03-11 06:52:48 +0000139 * @param meterId the id to be freed
Pier Luigif094c612017-10-14 12:15:02 +0200140 */
141 void freeMeterId(DeviceId deviceId, MeterId meterId);
Jordi Ortiz6c847762017-01-30 17:13:05 +0100142
Gamze Abakaf57ef602019-03-11 06:52:48 +0000143 /**
144 * Removes all meters of given device from store.
145 *
146 * @param deviceId the device id
147 */
148 void purgeMeter(DeviceId deviceId);
149
alshabib7bb05012015-08-05 10:15:09 -0700150}