alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.incubator.net.meter; |
| 17 | |
| 18 | import org.onosproject.store.Store; |
| 19 | |
| 20 | import java.util.Collection; |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 21 | import java.util.concurrent.CompletableFuture; |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Entity that stores and distributed meter objects. |
| 25 | */ |
| 26 | public interface MeterStore extends Store<MeterEvent, MeterStoreDelegate> { |
| 27 | |
| 28 | /** |
| 29 | * Adds a meter to the store. |
| 30 | * |
| 31 | * @param meter a meter |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 32 | * @return a future indicating the result of the store operation |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 33 | */ |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 34 | CompletableFuture<MeterStoreResult> storeMeter(Meter meter); |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Deletes a meter from the store. |
| 38 | * |
| 39 | * @param meter a meter |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 40 | * @return a future indicating the result of the store operation |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 41 | */ |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 42 | CompletableFuture<MeterStoreResult> deleteMeter(Meter meter); |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Updates a meter whose meter id is the same as the passed meter. |
| 46 | * |
| 47 | * @param meter a new meter |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 48 | * @return a future indicating the result of the store operation |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 49 | */ |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 50 | CompletableFuture<MeterStoreResult> updateMeter(Meter meter); |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * Updates a given meter's state with the provided state. |
alshabib | eadfc8e | 2015-08-18 15:40:46 -0700 | [diff] [blame] | 54 | * |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 55 | * @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 | } |