Class GuardSupport.Context

java.lang.Object
com.tangosol.net.GuardSupport.Context
All Implemented Interfaces:
Guardian.GuardContext
Enclosing class:
GuardSupport

protected class GuardSupport.Context extends Object implements Guardian.GuardContext
Base implementation for GuardContext's used by GuardSupport.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Guardable
    The Guardable represented by this GuardContext
    protected long
    The default soft-timeout interval to use for the represented Guardable.
    protected long
    The default timeout interval to use for the represented Guardable.
    protected long
    The amount of time to allow for recovery
    protected long
    The timeout interval to use for the represented Guardable.
    protected float
    Percentage of the timeout after which to attempt recovery of the Guardable.
    protected long
    The soft-timeout stamp that was violated, resulting in a recovery attempt.
    protected long
    The next soft-timeout for the Guardable
    protected long
    The next timeout for the Guardable.
    protected int
    The current state of the Context.

    Fields inherited from interface com.tangosol.net.Guardian.GuardContext

    STATE_HEALTHY, STATE_RECOVERY, STATE_TERMINATING
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Context(Guardable guardable, long cTimeoutMillis, float flPctRecover)
    Construct a Context.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the Guardable for this context.
    Return the Guardian for this context.
    protected long
    Return the last missed soft-timeout for this Guardable (that resulted in a recovery attempt).
    protected long
    Return the recovery interval for this Guardable.
    protected long
    Return the next soft-timeout for this Guardable.
    long
    Return the soft timeout interval for the represented Guardable.
    int
    Return the state of the Guardable.
    protected long
    Return the next timeout for this Guardable.
    long
    Return the hard timeout interval for the represented Guardable.
    void
    Called by the Guardable to signal that it is still alive.
    void
    heartbeat(long cMillis)
    Called by the Guardable to signal that it is still alive, and that it should not be considered timed out for the specified number of milliseconds.
    protected boolean
    isSuspect(long ldtNow)
    Is the Guardable represented by this GuardContext suspect (in danger of timing out soon).
    protected boolean
    isTimedOut(long ldtNow)
    Is the Guardable represented by this GuardContext timed out?
    protected void
    Called when the guardable enters the "RECOVERY" state.
    protected void
    Called when the guardable enters the "TERMINATING" state.
    void
    Release this context, causing the Guardian to discontinue monitoring of the represented Guardable.
    void
    If more than half of the soft-timeout interval has passed, issue a heartbeat and clear the interrupted status if set.
    protected void
    setMissedSoftTimeout(long ldtSoftTimeout)
    Set the missed soft-timeout for this guardable.
    protected void
    setRecoveryMillis(long cRecoveryMillis)
    Set the recovery interval for this Guardable.
    protected void
    setSoftTimeout(long ldtSoftTimeout)
    Set the next soft-timeout for this Guardable.
    protected void
    setState(int nState)
    Set the state of the GuardContext to the specified value.
    protected void
    setTimeout(long ldtTimeout)
    Set the next timeout for this Guardable.
    Return a human-readable description.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • m_nState

      protected volatile int m_nState
      The current state of the Context.
    • m_ldtTimeout

      protected long m_ldtTimeout
      The next timeout for the Guardable. This property is only used by the guardian thread.
    • m_cRecoveryMillis

      protected volatile long m_cRecoveryMillis
      The amount of time to allow for recovery
    • m_ldtSoftTimeout

      protected volatile long m_ldtSoftTimeout
      The next soft-timeout for the Guardable
    • f_guardable

      protected final Guardable f_guardable
      The Guardable represented by this GuardContext
    • m_cDefaultTimeoutMillis

      protected long m_cDefaultTimeoutMillis
      The default timeout interval to use for the represented Guardable.
    • m_cTimeoutMillis

      protected long m_cTimeoutMillis
      The timeout interval to use for the represented Guardable.
    • m_cDefaultSoftTimeoutMillis

      protected long m_cDefaultSoftTimeoutMillis
      The default soft-timeout interval to use for the represented Guardable.
    • m_ldtLastMissedSoftTimeout

      protected long m_ldtLastMissedSoftTimeout
      The soft-timeout stamp that was violated, resulting in a recovery attempt.
    • m_flPctRecover

      protected float m_flPctRecover
      Percentage of the timeout after which to attempt recovery of the Guardable.
  • Constructor Details

    • Context

      protected Context(Guardable guardable, long cTimeoutMillis, float flPctRecover)
      Construct a Context.
      Parameters:
      guardable - the guardable represented by this Context
      cTimeoutMillis - the timeout interval for the specified Guardable
      flPctRecover - the percentage of the timeout after which to attempt recovery of the Guardable; 0 < flPctRecover <= 1.0
  • Method Details

    • setState

      protected void setState(int nState)
      Set the state of the GuardContext to the specified value.
      Parameters:
      nState - the state to set this GuardContext to
    • getTimeout

      protected long getTimeout()
      Return the next timeout for this Guardable.
      Returns:
      the next timestamp, after which this Guardable should be considered timed out
    • setTimeout

      protected void setTimeout(long ldtTimeout)
      Set the next timeout for this Guardable.
      Parameters:
      ldtTimeout - the next timestamp, after which this Guardable should be considered timed out
    • getSoftTimeout

      protected long getSoftTimeout()
      Return the next soft-timeout for this Guardable. The soft-timeout is used to determine when to attempt recovery of the Guardable.
      Returns:
      the next timestamp, after which this Guardable should be considered suspect, and recovery attempted
    • setSoftTimeout

      protected void setSoftTimeout(long ldtSoftTimeout)
      Set the next soft-timeout for this Guardable.
      Parameters:
      ldtSoftTimeout - the next timestamp, after which this Guardable should be considered suspect, and recovery attempted
    • getRecoveryMillis

      protected long getRecoveryMillis()
      Return the recovery interval for this Guardable.
      Returns:
      the recovery interval for this Guardable
    • setRecoveryMillis

      protected void setRecoveryMillis(long cRecoveryMillis)
      Set the recovery interval for this Guardable.
      Parameters:
      cRecoveryMillis - the recovery interval for this Guardable
    • getMissedSoftTimeout

      protected long getMissedSoftTimeout()
      Return the last missed soft-timeout for this Guardable (that resulted in a recovery attempt).
      Returns:
      the last missed soft-timeout for this guardable
    • setMissedSoftTimeout

      protected void setMissedSoftTimeout(long ldtSoftTimeout)
      Set the missed soft-timeout for this guardable.
      Parameters:
      ldtSoftTimeout - the soft-timeout that was missed
    • isTimedOut

      protected boolean isTimedOut(long ldtNow)
      Is the Guardable represented by this GuardContext timed out?
      Parameters:
      ldtNow - the current timestamp
      Returns:
      true iff the represented Guardable is timed out
    • isSuspect

      protected boolean isSuspect(long ldtNow)
      Is the Guardable represented by this GuardContext suspect (in danger of timing out soon).
      Parameters:
      ldtNow - the current timestamp
      Returns:
      true iff the represented Guardable is suspect
    • reset

      public void reset()
      If more than half of the soft-timeout interval has passed, issue a heartbeat and clear the interrupted status if set.
    • toString

      public String toString()
      Return a human-readable description.
      Overrides:
      toString in class Object
      Returns:
      a human-readable description
    • getGuardian

      public Guardian getGuardian()
      Return the Guardian for this context.
      Specified by:
      getGuardian in interface Guardian.GuardContext
      Returns:
      the Guardian for this context
    • getGuardable

      public Guardable getGuardable()
      Return the Guardable for this context.
      Specified by:
      getGuardable in interface Guardian.GuardContext
      Returns:
      the Guardable for this context
    • heartbeat

      public void heartbeat()
      Called by the Guardable to signal that it is still alive.
      Specified by:
      heartbeat in interface Guardian.GuardContext
    • heartbeat

      public void heartbeat(long cMillis)
      Called by the Guardable to signal that it is still alive, and that it should not be considered timed out for the specified number of milliseconds.
      Specified by:
      heartbeat in interface Guardian.GuardContext
      Parameters:
      cMillis - the number of milliseconds for which the guardable should not be considered timed out
    • getState

      public int getState()
      Return the state of the Guardable. Valid values are STATE_* constants.
      Specified by:
      getState in interface Guardian.GuardContext
      Returns:
      the state of the Guardable
    • release

      public void release()
      Release this context, causing the Guardian to discontinue monitoring of the represented Guardable.
      Specified by:
      release in interface Guardian.GuardContext
    • getSoftTimeoutMillis

      public long getSoftTimeoutMillis()
      Return the soft timeout interval for the represented Guardable.

      The soft timeout interval is the amount of time that must pass after the last received heartbeat before a recovery attempt is made.

      Specified by:
      getSoftTimeoutMillis in interface Guardian.GuardContext
      Returns:
      the soft timeout interval for the represented Guardable
    • getTimeoutMillis

      public long getTimeoutMillis()
      Return the hard timeout interval for the represented Guardable.
      Specified by:
      getTimeoutMillis in interface Guardian.GuardContext
      Returns:
      the hard timeout interval for the represented Guardable
    • onRecovery

      protected void onRecovery()
      Called when the guardable enters the "RECOVERY" state.
    • onTerminate

      protected void onTerminate()
      Called when the guardable enters the "TERMINATING" state.