Package com.tangosol.net
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 Guardable
f_guardable
The Guardable represented by this GuardContextprotected long
m_cDefaultSoftTimeoutMillis
The default soft-timeout interval to use for the represented Guardable.protected long
m_cDefaultTimeoutMillis
The default timeout interval to use for the represented Guardable.protected long
m_cRecoveryMillis
The amount of time to allow for recoveryprotected long
m_cTimeoutMillis
The timeout interval to use for the represented Guardable.protected float
m_flPctRecover
Percentage of the timeout after which to attempt recovery of the Guardable.protected long
m_ldtLastMissedSoftTimeout
The soft-timeout stamp that was violated, resulting in a recovery attempt.protected long
m_ldtSoftTimeout
The next soft-timeout for the Guardableprotected long
m_ldtTimeout
The next timeout for the Guardable.protected int
m_nState
The current state of the Context.-
Fields inherited from interface com.tangosol.net.Guardian.GuardContext
STATE_HEALTHY, STATE_RECOVERY, STATE_TERMINATING
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Guardable
getGuardable()
Return the Guardable for this context.Guardian
getGuardian()
Return the Guardian for this context.protected long
getMissedSoftTimeout()
Return the last missed soft-timeout for this Guardable (that resulted in a recovery attempt).protected long
getRecoveryMillis()
Return the recovery interval for this Guardable.protected long
getSoftTimeout()
Return the next soft-timeout for this Guardable.long
getSoftTimeoutMillis()
Return the soft timeout interval for the represented Guardable.int
getState()
Return the state of the Guardable.protected long
getTimeout()
Return the next timeout for this Guardable.long
getTimeoutMillis()
Return the hard timeout interval for the represented Guardable.void
heartbeat()
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
onRecovery()
Called when the guardable enters the "RECOVERY" state.protected void
onTerminate()
Called when the guardable enters the "TERMINATING" state.void
release()
Release this context, causing the Guardian to discontinue monitoring of the represented Guardable.void
reset()
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.String
toString()
Return a human-readable description.
-
-
-
Field Detail
-
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 Detail
-
Context
protected Context(Guardable guardable, long cTimeoutMillis, float flPctRecover)
Construct a Context.- Parameters:
guardable
- the guardable represented by this ContextcTimeoutMillis
- the timeout interval for the specified GuardableflPctRecover
- the percentage of the timeout after which to attempt recovery of the Guardable; 0 < flPctRecover <= 1.0
-
-
Method Detail
-
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.
-
getGuardian
public Guardian getGuardian()
Return the Guardian for this context.- Specified by:
getGuardian
in interfaceGuardian.GuardContext
- Returns:
- the Guardian for this context
-
getGuardable
public Guardable getGuardable()
Return the Guardable for this context.- Specified by:
getGuardable
in interfaceGuardian.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 interfaceGuardian.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 interfaceGuardian.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 interfaceGuardian.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 interfaceGuardian.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 interfaceGuardian.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 interfaceGuardian.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.
-
-