blob: 3d007071b8f0f1a3071badb58656ea10506ad694 [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 /**
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 /**
Jordi Ortiz9287b632017-06-22 11:01:37 +020094 * Returns all meters stored in the store for a
95 * precise device.
96 *
97 * @param deviceId the device to get the meter list from
98 * @return a collection of meters
99 */
100 Collection<Meter> getAllMeters(DeviceId deviceId);
101
102 /**
alshabib7bb05012015-08-05 10:15:09 -0700103 * Update the store by deleting the failed meter.
104 * Notifies the delegate that the meter failed to allow it
105 * to nofity the app.
106 *
107 * @param op a failed meter operation
108 * @param reason a failure reason
109 */
110 void failedMeter(MeterOperation op, MeterFailReason reason);
alshabib5eb79392015-08-19 18:09:55 -0700111
112 /**
113 * Delete this meter immediately.
114 * @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 /**
127 * Returns the first available MeterId from previously removed meter.
128 * This method allows allocating MeterIds below the actual meterIdCounter
129 * value.
130 *
131 * @param deviceId the device id
132 * @return the meter Id or null if none exist
133 */
134 MeterId firstReusableMeterId(DeviceId deviceId);
135
alshabib7bb05012015-08-05 10:15:09 -0700136}