blob: a63d2729bf862b3a4f59969a27663cae7993ea20 [file] [log] [blame]
alshabib7bb05012015-08-05 10:15:09 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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 /**
47 * Adds the meter features to the store.
48 *
49 * @param meterfeatures the meter features
50 * @return the result of the store operation
51 */
52 MeterStoreResult storeMeterFeatures(MeterFeatures meterfeatures);
53
54 /**
55 * Deletes the meter features from the store.
56 *
57 * @param deviceId the device id
58 * @return a future indicating the result of the store operation
59 */
60 MeterStoreResult deleteMeterFeatures(DeviceId deviceId);
61
62
alshabib7bb05012015-08-05 10:15:09 -070063 /**
64 * Updates a meter whose meter id is the same as the passed meter.
65 *
66 * @param meter a new meter
alshabibeadfc8e2015-08-18 15:40:46 -070067 * @return a future indicating the result of the store operation
alshabib7bb05012015-08-05 10:15:09 -070068 */
alshabibeadfc8e2015-08-18 15:40:46 -070069 CompletableFuture<MeterStoreResult> updateMeter(Meter meter);
alshabib7bb05012015-08-05 10:15:09 -070070
71 /**
72 * Updates a given meter's state with the provided state.
alshabibeadfc8e2015-08-18 15:40:46 -070073 *
alshabib7bb05012015-08-05 10:15:09 -070074 * @param meter a meter
75 */
76 void updateMeterState(Meter meter);
77
78 /**
alshabib70aaa1b2015-09-25 14:30:59 -070079 * Obtains a meter matching the given meter key.
alshabib7bb05012015-08-05 10:15:09 -070080 *
alshabib70aaa1b2015-09-25 14:30:59 -070081 * @param key a meter key
alshabib7bb05012015-08-05 10:15:09 -070082 * @return a meter
83 */
alshabib70aaa1b2015-09-25 14:30:59 -070084 Meter getMeter(MeterKey key);
alshabib7bb05012015-08-05 10:15:09 -070085
86 /**
87 * Returns all meters stored in the store.
88 *
89 * @return a collection of meters
90 */
91 Collection<Meter> getAllMeters();
92
93 /**
94 * Update the store by deleting the failed meter.
95 * Notifies the delegate that the meter failed to allow it
96 * to nofity the app.
97 *
98 * @param op a failed meter operation
99 * @param reason a failure reason
100 */
101 void failedMeter(MeterOperation op, MeterFailReason reason);
alshabib5eb79392015-08-19 18:09:55 -0700102
103 /**
104 * Delete this meter immediately.
105 * @param m a meter
106 */
107 void deleteMeterNow(Meter m);
108
Jordi Ortizaa8de492016-12-01 00:21:36 +0100109 /**
110 * Retrieve maximum meters available for the device.
111 *
112 * @param key the meter features key
113 * @return the maximum number of meters supported by the device
114 */
115 long getMaxMeters(MeterFeaturesKey key);
116
Jordi Ortiz6c847762017-01-30 17:13:05 +0100117 /**
118 * Returns the first available MeterId from previously removed meter.
119 * This method allows allocating MeterIds below the actual meterIdCounter
120 * value.
121 *
122 * @param deviceId the device id
123 * @return the meter Id or null if none exist
124 */
125 MeterId firstReusableMeterId(DeviceId deviceId);
126
alshabib7bb05012015-08-05 10:15:09 -0700127}