Package it.unitn.disi.ds1.qtop
Class TimeOutManager
java.lang.Object
java.util.AbstractMap<Utils.TimeOutReason,ArrayList<akka.japi.Pair<akka.actor.Cancellable,Integer>>>
java.util.EnumMap<Utils.TimeOutReason,ArrayList<akka.japi.Pair<akka.actor.Cancellable,Integer>>>
it.unitn.disi.ds1.qtop.TimeOutManager
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<Utils.TimeOutReason,
ArrayList<akka.japi.Pair<akka.actor.Cancellable, Integer>>>
public class TimeOutManager
extends EnumMap<Utils.TimeOutReason,ArrayList<akka.japi.Pair<akka.actor.Cancellable,Integer>>>
TimeOutManager class to manage the timeouts of a Node
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
ConstructorDescriptionTimeOutManager
(int voteTimeout, int heartbeatTimeout, int writeTimeout, int crashResponseTimeout, int electionGlobalTimeout, int clientRequestTimeout, int refresh) TimeOutManager constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clientHandleCountDown
(Utils.TimeOutReason reason, int i, Client node) Client decrease the time left for a specific count-down.void
Reset the data structure to start a new post election phase.void
handleCountDown
(Utils.TimeOutReason reason, int i, akka.actor.ActorRef nodeRef) Decrease the time left for a specific count-down.void
resetCountDown
(Utils.TimeOutReason reason, int i) Reset a specific count down.void
startCountDown
(Utils.TimeOutReason reason, akka.actor.Cancellable action, int i) Start a count-down for a specific reason.void
Reset all the count-downs to enter the election state.toString()
Methods inherited from class java.util.EnumMap
clear, clone, containsKey, containsValue, entrySet, equals, get, hashCode, keySet, put, putAll, remove, size, values
Methods inherited from class java.util.AbstractMap
isEmpty
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
TimeOutManager
public TimeOutManager(int voteTimeout, int heartbeatTimeout, int writeTimeout, int crashResponseTimeout, int electionGlobalTimeout, int clientRequestTimeout, int refresh) TimeOutManager constructor.- Parameters:
voteTimeout
- the timeout for the voteheartbeatTimeout
- the timeout for the heartbeatwriteTimeout
- the timeout to writecrashResponseTimeout
- the timeout for the crash responseelectionGlobalTimeout
- the timeout for the global election phaseclientRequestTimeout
- the timeout for the client requestrefresh
- the refresh ratio
-
-
Method Details
-
startCountDown
Start a count-down for a specific reason.- Parameters:
reason
- the reason for the count-downaction
- the action to be performed when the count-down reaches 0i
- the index of the count-down
-
handleCountDown
Decrease the time left for a specific count-down.- Parameters:
reason
- the reason for the count-downi
- the index of the count-downnodeRef
- the ActorRef of the node that is handling the count-down
-
clientHandleCountDown
Client decrease the time left for a specific count-down.- Parameters:
reason
- the reason for the count-downi
- the index of the count-downnode
- the node that is handling the count-down
-
resetCountDown
Reset a specific count down.- Parameters:
reason
- the reason for the count-downi
- the index of the count-down
-
startElectionState
public void startElectionState()Reset all the count-downs to enter the election state. -
endElectionState
public void endElectionState()Reset the data structure to start a new post election phase. -
toString
- Overrides:
toString
in classAbstractMap<Utils.TimeOutReason,
ArrayList<akka.japi.Pair<akka.actor.Cancellable, Integer>>>
-