Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 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.opencord.igmpproxy.impl.store.machine; |
| 17 | |
| 18 | import org.opencord.igmpproxy.statemachine.StateMachine; |
| 19 | import org.opencord.igmpproxy.statemachine.StateMachineId; |
| 20 | |
| 21 | import java.util.Collection; |
| 22 | |
| 23 | /** |
| 24 | * State Machine Store. |
| 25 | */ |
| 26 | public interface StateMachineStore { |
| 27 | /** |
| 28 | * Increases counter state-machine. |
| 29 | * |
| 30 | * @param stateMachineId identification of machine |
| 31 | * @return counter |
| 32 | */ |
| 33 | long increaseAndGetCounter(StateMachineId stateMachineId); |
| 34 | |
| 35 | /** |
| 36 | * Decreases counter of state-machine. |
| 37 | * |
| 38 | * @param stateMachineId identification of machine |
| 39 | * @return if counter greater than zero, decreases counter and return counter |
| 40 | */ |
| 41 | long decreaseAndGetCounter(StateMachineId stateMachineId); |
| 42 | |
| 43 | /** |
| 44 | * Removes counter from counter-map. |
| 45 | * |
| 46 | * @param stateMachineId identification of machine |
| 47 | * @return true |
| 48 | */ |
| 49 | boolean removeCounter(StateMachineId stateMachineId); |
| 50 | |
| 51 | /** |
| 52 | * Get counter using state-machine id. |
| 53 | * |
| 54 | * @param stateMachineId identification of machine |
| 55 | * @return counter of member that use this id |
| 56 | */ |
| 57 | long getCounter(StateMachineId stateMachineId); |
| 58 | |
| 59 | /** |
| 60 | * Add new machine to store. |
| 61 | * |
| 62 | * @param stateMachine given machine |
| 63 | * @return added informations |
| 64 | */ |
| 65 | StateMachine putStateMachine(StateMachine stateMachine); |
| 66 | |
| 67 | /** |
| 68 | * Update information in store. |
| 69 | * |
| 70 | * @param stateMachine given machine |
| 71 | * @return updated info |
| 72 | */ |
| 73 | StateMachine updateStateMachine(StateMachine stateMachine); |
| 74 | |
| 75 | /** |
| 76 | * Get information from store. |
| 77 | * |
| 78 | * @param id given identification of machine |
| 79 | * @return information of machine |
| 80 | */ |
| 81 | StateMachine getStateMachine(StateMachineId id); |
| 82 | |
| 83 | /** |
| 84 | * Remove machine from store. |
| 85 | * |
| 86 | * @param id given identification of machine |
| 87 | * @return removed info |
| 88 | */ |
| 89 | StateMachine removeStateMachine(StateMachineId id); |
| 90 | |
| 91 | /** |
| 92 | * Get informations of all machine. |
| 93 | * |
| 94 | * @return machine informations |
| 95 | */ |
| 96 | Collection<StateMachine> getAllStateMachines(); |
| 97 | |
| 98 | /** |
| 99 | * clear information map. |
| 100 | */ |
| 101 | void clearAllStateMachines(); |
| 102 | |
| 103 | /** |
| 104 | * Decreases timeout of timer. |
| 105 | * |
| 106 | * @param machineId given machine id |
| 107 | */ |
| 108 | void decreaseTimeout(StateMachineId machineId); |
| 109 | |
| 110 | /** |
| 111 | * Increases timeout of timer. |
| 112 | * |
| 113 | * @param machineId given machine id |
| 114 | */ |
| 115 | void increaseTimeout(StateMachineId machineId); |
| 116 | } |