|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
org.activemath.util.checks.Checker
public abstract class Checker
Abstract class that performs one single check. (e.G. Maple, Omega, ...) It extends java.lang.Thread and performs its check regularily. It stores a Date object indicating when the last check was completed successfully.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
Thread.State, Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
protected boolean |
aborted
inheriting class must leave their run() method if this variable is set true. |
static int |
BAD_STATE
value of getState() if last check was not successfully
completed |
static int |
BLOCKING_STATE
value of getState() if checked thread is blocking
unreasonably long |
protected boolean |
blockingPrepared
true iff the checker is currently in a state that
might block |
protected Date |
lastBlockingDate
the last Date when the prepareForBlocking() method was
called |
protected String |
lastBlockingDescription
String indicating what operation the checking thread was about to perform before it blocked |
protected Date |
lastFailureDate
the last Date when a check failed. |
protected String |
lastFailureDescription
String indicating what went wrong when the tested failed the last time. |
protected Date |
lastSuccessDate
the last Date when a check was successfull. |
protected long |
retryInterval
number of seconds between two tests. |
static int |
SANE_STATE
value of getState() if last check was successfully completed |
protected Date |
shuttingDownSince
stores the date when shutting down was initiated for the first time |
static int |
UNEXPECTED_BLOCKING_STATE
value of getState() if checked thread is unexcpectedly
blocking unreasonably long. |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
Checker(Subconfiguration config)
initializes the check. |
|
| Method Summary | |
|---|---|
protected boolean |
computeBlocking(long secondsExpected)
Computes the default way to test blocking with the number of seconds of the expected duration. |
int |
getCheckerState()
returns the current state of the check whereas SANESTATE means that the last check was
completed successfully
BADSTATE means that the last check has
failed
BLOCKINGSTATE means that the checker thread
was not updating for a unreasonably long time. |
Date |
getLastFailureDate()
returns the time when the last test has failed |
String |
getLastFailureDescription()
returns a verbose description of the last failure |
Date |
getLastSuccessDate()
returns the time when the last test was successfully completed |
boolean |
isBlocking()
returns true if the calling thread is blocking
for a unreasonable long time. |
protected void |
prepareForBlocking(String desc)
should be called before a check is about to call an (external) method which might block; in case it blocks, the given description will be part of a detailed failure description. |
abstract void |
run()
runs the checks. |
protected void |
testComplete()
handles things common to failing and successed test: unpreparation of blocking methods, later mightbe time measurements |
protected void |
testFails(String description)
handles a failing test, i.E. stores the actual date as date of last failure and stores the given description as failure description |
protected void |
testSucceeds()
handles a successing test, i.E. stores the actual date as date of last success, and calls testComplete |
protected void |
unprepareForBlocking()
signals that the danger of blocking is over for now |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int SANE_STATE
getState() if last check was successfully completed
public static final int BAD_STATE
getState() if last check was not successfully
completed
public static final int BLOCKING_STATE
getState() if checked thread is blocking
unreasonably long
public static final int UNEXPECTED_BLOCKING_STATE
getState() if checked thread is unexcpectedly
blocking unreasonably long. Unexcpectedly in this context means that
the thread is blocking, although there was no call to
prepareForBlocking()
protected Date lastSuccessDate
protected Date lastFailureDate
protected Date lastBlockingDate
prepareForBlocking() method was
called
protected String lastBlockingDescription
protected String lastFailureDescription
protected boolean blockingPrepared
true iff the checker is currently in a state that
might block
protected long retryInterval
long,
because it will be used as multiplicator to get the value in
ms, and then it's useful to have values greater than 26 days...
protected boolean aborted
protected Date shuttingDownSince
| Constructor Detail |
|---|
public Checker(Subconfiguration config)
config - configuration to be used by subobjects| Method Detail |
|---|
protected void testComplete()
protected void testSucceeds()
testComplete
protected void prepareForBlocking(String desc)
desc - String containing a short description of the
blocking operationprotected void unprepareForBlocking()
protected void testFails(String description)
description - String containing a description of the failurepublic Date getLastSuccessDate()
public Date getLastFailureDate()
public String getLastFailureDescription()
public boolean isBlocking()
true if the calling thread is blocking
for a unreasonable long time. This implementation assumes that
blocking for longer than twice the retryInterval is unreasonable.
protected boolean computeBlocking(long secondsExpected)
public int getCheckerState()
SANESTATE means that the last check was
completed successfully BADSTATE means that the last check has
failed BLOCKINGSTATE means that the checker thread
was not updating for a unreasonably long time. This
standard implementation assumes that a time twice as long
as the retryInterval is unreasonable
public abstract void run()
retryInterval seconds. Implementing methods must
update either lastFailureDate or lastSuccessDate
after every check
run in interface Runnablerun in class Thread
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||