Package com.tangosol.net
Class GuardSupport
java.lang.Object
com.tangosol.util.Base
com.tangosol.net.GuardSupport
A concrete implementation of Guardian/Guardable interactions. GuardSupport
is used by a Guardian to manage its responsibilities.
- Since:
- Coherence 3.5
- Author:
- rhl
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
Base implementation for GuardContext's used by GuardSupport.Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
Default guardian log thread dump interval as a time duration.protected static final long
The threshold before which than which a guardian considers itself early in checking its guardables.protected static final long
The threshold past which a guardian considers itself late in checking its guardables.static final long
The maximum interval at which the Guardian thread should call check() to verify its guardables.protected static final long
The minimum interval at which the Guardian should log thread dumps in milliseconds.protected GuardSupport.Context[]
Array of GuardContexts for the registered Guardables.protected int
The number of registered Guardables.protected Guardian
The Guardian that is managing this GuardSupport.protected long
The next time at which the Guardables should be checked.protected static ThreadLocal
ThreadLocal containing the GuardContext associated with the current thread.protected static final String
protected static final long
Max interval in milliseconds at which the Guardian log thread dump interval can be configured.protected static final String
Property for configuring minimum Guardian log thread dump interval as a time duration.protected static AtomicLong
Atomic counter containing the last log time stamp. -
Constructor Summary
ConstructorsConstructorDescriptionGuardSupport
(Guardian guardian) Construct a GuardSupport for the specified Guardian. -
Method Summary
Modifier and TypeMethodDescriptionAdd the specified guardable to the set of Guardables managed by this manager, subject to the specified service parameters.long
check()
Check the registered Guardable objects for timeout, taking appropriate action and calculate the timestamp when the next check should be performed.int
Return the number of Guardables that are registered with this GuardSupport.protected GuardSupport.Context[]
Return the array of GuardContext objects for the Guardables managed by this GuardSupport.protected Guardian
Return the Guardian that manages this GuardSupport.protected static long
Configure guardian log thread dump interval using propertyPROP_LOG_THREADDUMP_INTERVAL
set to a time duration, i.e.long
Return the next time at which the Guardables should be checked.static Guardian.GuardContext
Obtain the GuardContext associated with the current thread.static String
Get the full thread dump.static void
Issue a heartbeat on the GuardContext associated with the current thread.static void
heartbeat
(long cMillis) Issue a heartbeat of the specified duration on the GuardContext associated with the current thread.protected GuardSupport.Context
instantiateContext
(Guardable guardable, long cMillis, float flPctRecover) static void
Collect stack traces and synchronization information for all running threads and write them to the error log.void
release()
Release the Guardables managed by this GuardSupport.void
Remove the specified Guardable from the set of Guardables managed by this manager.static void
reset()
Issue a reset on the GuardContext associated with the current thread.protected void
setGuardableCount
(int cGuardable) Set the number of Guardables that are registered with this GuardSupport.protected void
setGuardContexts
(GuardSupport.Context[] aGuardContext) Set the array of GuardContext objects for the Guardables that are managed by this GuardSupport.protected void
setNextCheckTime
(long ldtNextCheck) Set the next time at which the Guardables should be checked.static void
setThreadContext
(Guardian.GuardContext context) Associate the specified GuardContext with the current thread.Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, newHashMap, newHashMap, newHashSet, newHashSet, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
Field Details
-
GUARDIAN_MAX_CHECK_INTERVAL
public static final long GUARDIAN_MAX_CHECK_INTERVALThe maximum interval at which the Guardian thread should call check() to verify its guardables.- See Also:
-
GUARDIAN_LATE_THRESHOLD
protected static final long GUARDIAN_LATE_THRESHOLDThe threshold past which a guardian considers itself late in checking its guardables.- See Also:
-
GUARDIAN_EARLY_THRESHOLD
protected static final long GUARDIAN_EARLY_THRESHOLDThe threshold before which than which a guardian considers itself early in checking its guardables.- See Also:
-
PROP_LOG_THREADDUMP_INTERVAL
Property for configuring minimum Guardian log thread dump interval as a time duration. Configure this property to reduce the number of Guardian log thread dumps in logs when too many are occurring over a short duration of time. Format is documented asString
parameter ofDuration(String)
.- Since:
- 25.03
- See Also:
-
DEFAULT_LOG_THREADDUMP_INTERVAL
Default guardian log thread dump interval as a time duration.- Since:
- 25.03
- See Also:
-
MAX_LOG_THREADDUMP_INTERVAL
- See Also:
-
MAX_LOG_THREADDUMP_INTERVAL_MS
protected static final long MAX_LOG_THREADDUMP_INTERVAL_MSMax interval in milliseconds at which the Guardian log thread dump interval can be configured.- Since:
- 25.03
-
LOG_THREADDUMP_INTERVAL_MS
protected static final long LOG_THREADDUMP_INTERVAL_MSThe minimum interval at which the Guardian should log thread dumps in milliseconds. Override defaultDEFAULT_LOG_THREADDUMP_INTERVAL
by setting propertyPROP_LOG_THREADDUMP_INTERVAL
to a time duration.- Since:
- 25.03
- See Also:
-
m_aGuardContext
Array of GuardContexts for the registered Guardables. May contain nulls. -
m_cGuardable
protected int m_cGuardableThe number of registered Guardables. -
m_guardian
The Guardian that is managing this GuardSupport. -
m_ldtNextCheck
protected long m_ldtNextCheckThe next time at which the Guardables should be checked. -
m_tlContext
ThreadLocal containing the GuardContext associated with the current thread. -
s_atomicLogTime
Atomic counter containing the last log time stamp.
-
-
Constructor Details
-
GuardSupport
Construct a GuardSupport for the specified Guardian.- Parameters:
guardian
- the guardian managing this GuardSupport
-
-
Method Details
-
getGuardContexts
Return the array of GuardContext objects for the Guardables managed by this GuardSupport.- Returns:
- the array of managed GuardContext objects
-
setGuardContexts
Set the array of GuardContext objects for the Guardables that are managed by this GuardSupport.- Parameters:
aGuardContext
- the array of managed GuardContext objects
-
getGuardian
Return the Guardian that manages this GuardSupport.- Returns:
- the Guardian that manages this GuardSupport
-
getNextCheckTime
public long getNextCheckTime()Return the next time at which the Guardables should be checked.- Returns:
- the next time at which the Guardables should be checked
-
setNextCheckTime
protected void setNextCheckTime(long ldtNextCheck) Set the next time at which the Guardables should be checked.- Parameters:
ldtNextCheck
- the next time at which the Guardables should be checked
-
add
Add the specified guardable to the set of Guardables managed by this manager, subject to the specified service parameters. If the specified guardable is already guarded by this manager, adjust the service parameters.- Parameters:
guardable
- the Guardable object to be managedcMillis
- the timeout for the specified GuardableflPctRecover
- the percentage of the timeout after which to attempt recovery of the Guardable; 0 < flPctRecover <= 1.0- Returns:
- the GuardContext for the specified Guardable
-
remove
Remove the specified Guardable from the set of Guardables managed by this manager.- Parameters:
guardable
- the guardable to remove
-
getGuardableCount
public int getGuardableCount()Return the number of Guardables that are registered with this GuardSupport.- Returns:
- the number of registered Guardable objects
-
setGuardableCount
protected void setGuardableCount(int cGuardable) Set the number of Guardables that are registered with this GuardSupport.- Parameters:
cGuardable
- the number of registered Guardable objects
-
check
public long check()Check the registered Guardable objects for timeout, taking appropriate action and calculate the timestamp when the next check should be performed. The next check time can later be retrieved by thegetNextCheckTime()
method.- Returns:
- the number of milliseconds past the time when the guardables should have been checked, or 0 if the check was performed on time
-
release
public void release()Release the Guardables managed by this GuardSupport. Releasing a Guardable causes it to no longer be guarded. -
instantiateContext
protected GuardSupport.Context instantiateContext(Guardable guardable, long cMillis, float flPctRecover) - Parameters:
guardable
- the Guardable object to be managedcMillis
- the timeout for the specified GuardableflPctRecover
- the percentage of the timeout after which to attempt recovery of the Guardable; 0 < flPctRecover <= 1.0- Returns:
- a Context for the specified guardable and SLA parameters
-
getThreadContext
Obtain the GuardContext associated with the current thread.- Returns:
- the GuardContext or null if it has not been set
-
setThreadContext
Associate the specified GuardContext with the current thread.- Parameters:
context
- the GuardContext to associate with the current thread
-
heartbeat
public static void heartbeat()Issue a heartbeat on the GuardContext associated with the current thread. -
heartbeat
public static void heartbeat(long cMillis) Issue a heartbeat of the specified duration on the GuardContext associated with the current thread.- Parameters:
cMillis
- the number of milliseconds to heartbeat for
-
reset
public static void reset()Issue a reset on the GuardContext associated with the current thread. -
logStackTraces
public static void logStackTraces()Collect stack traces and synchronization information for all running threads and write them to the error log. -
getThreadDump
Get the full thread dump.- Returns:
- a string containing the thread dump
-
getLogThreaddumpIntervalMs
protected static long getLogThreaddumpIntervalMs()Configure guardian log thread dump interval using propertyPROP_LOG_THREADDUMP_INTERVAL
set to a time duration, i.e.15m
or2h
. The maximum allowed duration isMAX_LOG_THREADDUMP_INTERVAL
, any value provided above this value is treated as the max allowed log thread dump interval. Default duration ofDEFAULT_LOG_THREADDUMP_INTERVAL
is used when property is not or set to an invalid time duration.- Returns:
- the computed guardian log thread dump interval in milliseconds.
- Since:
- 25.03
-