blob: d5247c44151772e20c04e25850b2831b75169eff [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
18import org.onosproject.store.Store;
19
20import java.util.Collection;
alshabibeadfc8e2015-08-18 15:40:46 -070021import java.util.concurrent.CompletableFuture;
alshabib7bb05012015-08-05 10:15:09 -070022
23/**
24 * Entity that stores and distributed meter objects.
25 */
26public interface MeterStore extends Store<MeterEvent, MeterStoreDelegate> {
27
28 /**
29 * Adds a meter to the store.
30 *
31 * @param meter a meter
alshabibeadfc8e2015-08-18 15:40:46 -070032 * @return a future indicating the result of the store operation
alshabib7bb05012015-08-05 10:15:09 -070033 */
alshabibeadfc8e2015-08-18 15:40:46 -070034 CompletableFuture<MeterStoreResult> storeMeter(Meter meter);
alshabib7bb05012015-08-05 10:15:09 -070035
36 /**
37 * Deletes a meter from the store.
38 *
39 * @param meter a meter
alshabibeadfc8e2015-08-18 15:40:46 -070040 * @return a future indicating the result of the store operation
alshabib7bb05012015-08-05 10:15:09 -070041 */
alshabibeadfc8e2015-08-18 15:40:46 -070042 CompletableFuture<MeterStoreResult> deleteMeter(Meter meter);
alshabib7bb05012015-08-05 10:15:09 -070043
44 /**
45 * Updates a meter whose meter id is the same as the passed meter.
46 *
47 * @param meter a new meter
alshabibeadfc8e2015-08-18 15:40:46 -070048 * @return a future indicating the result of the store operation
alshabib7bb05012015-08-05 10:15:09 -070049 */
alshabibeadfc8e2015-08-18 15:40:46 -070050 CompletableFuture<MeterStoreResult> updateMeter(Meter meter);
alshabib7bb05012015-08-05 10:15:09 -070051
52 /**
53 * Updates a given meter's state with the provided state.
alshabibeadfc8e2015-08-18 15:40:46 -070054 *
alshabib7bb05012015-08-05 10:15:09 -070055 * @param meter a meter
56 */
57 void updateMeterState(Meter meter);
58
59 /**
alshabib70aaa1b2015-09-25 14:30:59 -070060 * Obtains a meter matching the given meter key.
alshabib7bb05012015-08-05 10:15:09 -070061 *
alshabib70aaa1b2015-09-25 14:30:59 -070062 * @param key a meter key
alshabib7bb05012015-08-05 10:15:09 -070063 * @return a meter
64 */
alshabib70aaa1b2015-09-25 14:30:59 -070065 Meter getMeter(MeterKey key);
alshabib7bb05012015-08-05 10:15:09 -070066
67 /**
68 * Returns all meters stored in the store.
69 *
70 * @return a collection of meters
71 */
72 Collection<Meter> getAllMeters();
73
74 /**
75 * Update the store by deleting the failed meter.
76 * Notifies the delegate that the meter failed to allow it
77 * to nofity the app.
78 *
79 * @param op a failed meter operation
80 * @param reason a failure reason
81 */
82 void failedMeter(MeterOperation op, MeterFailReason reason);
alshabib5eb79392015-08-19 18:09:55 -070083
84 /**
85 * Delete this meter immediately.
86 * @param m a meter
87 */
88 void deleteMeterNow(Meter m);
89
alshabib7bb05012015-08-05 10:15:09 -070090}