blob: 54e565885885fece252f59f55ab1794439127750 [file] [log] [blame]
alshabib7bb05012015-08-05 10:15:09 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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 */
16package org.onosproject.incubator.net.meter;
17
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 /**
60 * Obtains a meter matching the given meter id.
61 *
62 * @param meterId a meter id
63 * @return a meter
64 */
65 Meter getMeter(MeterId meterId);
66
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);
83}