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 | */ |
alshabib | 10c810b | 2015-08-18 16:59:04 -0700 | [diff] [blame] | 16 | package org.onosproject.net.meter; |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 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 | /** |
alshabib | 70aaa1b | 2015-09-25 14:30:59 -0700 | [diff] [blame] | 60 | * Obtains a meter matching the given meter key. |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 61 | * |
alshabib | 70aaa1b | 2015-09-25 14:30:59 -0700 | [diff] [blame] | 62 | * @param key a meter key |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 63 | * @return a meter |
| 64 | */ |
alshabib | 70aaa1b | 2015-09-25 14:30:59 -0700 | [diff] [blame] | 65 | Meter getMeter(MeterKey key); |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 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); |
alshabib | 5eb7939 | 2015-08-19 18:09:55 -0700 | [diff] [blame] | 83 | |
| 84 | /** |
| 85 | * Delete this meter immediately. |
| 86 | * @param m a meter |
| 87 | */ |
| 88 | void deleteMeterNow(Meter m); |
| 89 | |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 90 | } |