Package com.tangosol.net
Class GuardSupport.Context
java.lang.Object
com.tangosol.net.GuardSupport.Context
- All Implemented Interfaces:
Guardian.GuardContext
- Enclosing class:
GuardSupport
Base implementation for GuardContext's used by GuardSupport.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Guardable
The Guardable represented by this GuardContextprotected 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 recoveryprotected 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 Guardableprotected 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
-
Method Summary
Modifier and TypeMethodDescriptionReturn 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
getState()
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()
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.toString()
Return a human-readable description.
-
Field Details
-
m_nState
protected volatile int m_nStateThe current state of the Context. -
m_ldtTimeout
protected long m_ldtTimeoutThe next timeout for the Guardable. This property is only used by the guardian thread. -
m_cRecoveryMillis
protected volatile long m_cRecoveryMillisThe amount of time to allow for recovery -
m_ldtSoftTimeout
protected volatile long m_ldtSoftTimeoutThe next soft-timeout for the Guardable -
f_guardable
The Guardable represented by this GuardContext -
m_cDefaultTimeoutMillis
protected long m_cDefaultTimeoutMillisThe default timeout interval to use for the represented Guardable. -
m_cTimeoutMillis
protected long m_cTimeoutMillisThe timeout interval to use for the represented Guardable. -
m_cDefaultSoftTimeoutMillis
protected long m_cDefaultSoftTimeoutMillisThe default soft-timeout interval to use for the represented Guardable. -
m_ldtLastMissedSoftTimeout
protected long m_ldtLastMissedSoftTimeoutThe soft-timeout stamp that was violated, resulting in a recovery attempt. -
m_flPctRecover
protected float m_flPctRecoverPercentage of the timeout after which to attempt recovery of the Guardable.
-
-
Constructor Details
-
Context
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 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
Return a human-readable description. -
getGuardian
Return the Guardian for this context.- Specified by:
getGuardian
in interfaceGuardian.GuardContext
- Returns:
- the Guardian for this context
-
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.
-