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:
  • 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 vote
      heartbeatTimeout - the timeout for the heartbeat
      writeTimeout - the timeout to write
      crashResponseTimeout - the timeout for the crash response
      electionGlobalTimeout - the timeout for the global election phase
      clientRequestTimeout - the timeout for the client request
      refresh - the refresh ratio
  • Method Details

    • startCountDown

      public void startCountDown(Utils.TimeOutReason reason, akka.actor.Cancellable action, int i)
      Start a count-down for a specific reason.
      Parameters:
      reason - the reason for the count-down
      action - the action to be performed when the count-down reaches 0
      i - the index of the count-down
    • handleCountDown

      public void handleCountDown(Utils.TimeOutReason reason, int i, akka.actor.ActorRef nodeRef)
      Decrease the time left for a specific count-down.
      Parameters:
      reason - the reason for the count-down
      i - the index of the count-down
      nodeRef - the ActorRef of the node that is handling the count-down
    • clientHandleCountDown

      public void clientHandleCountDown(Utils.TimeOutReason reason, int i, Client node)
      Client decrease the time left for a specific count-down.
      Parameters:
      reason - the reason for the count-down
      i - the index of the count-down
      node - the node that is handling the count-down
    • resetCountDown

      public void resetCountDown(Utils.TimeOutReason reason, int i)
      Reset a specific count down.
      Parameters:
      reason - the reason for the count-down
      i - 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

      public String toString()
      Overrides:
      toString in class AbstractMap<Utils.TimeOutReason,ArrayList<akka.japi.Pair<akka.actor.Cancellable,Integer>>>