org.apache.hadoop.hbase
Class Chore
java.lang.Object
java.lang.Thread
org.apache.hadoop.hbase.Chore
- All Implemented Interfaces:
- Runnable
- Direct Known Subclasses:
- LogFlusher
public abstract class Chore
- extends Thread
Chore is a task performed on a period in hbase. The chore is run in its own
thread. This base abstract class provides while loop and sleeping facility.
If an unhandled exception, the threads exit is logged.
Implementers just need to add checking if there is work to be done and if
so, do it. Its the base of most of the chore threads in hbase.
Don't subclass Chore if the task relies on being woken up for something to
do, such as an entry being added to a queue, etc.
Method Summary |
protected abstract void |
chore()
Look for chores. |
protected boolean |
initialChore()
Override to run a task before we start looping. |
void |
run()
|
protected void |
sleep()
Sleep for period. |
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 |
stop
protected volatile AtomicBoolean stop
Chore
public Chore(int p,
AtomicBoolean s)
- Parameters:
p
- Period at which we should run. Will be adjusted appropriately
should we find work and it takes time to complete.s
- When this flag is set to true, this thread will cleanup and exit
cleanly.
run
public void run()
- Specified by:
run
in interface Runnable
- Overrides:
run
in class Thread
initialChore
protected boolean initialChore()
- Override to run a task before we start looping.
- Returns:
- true if initial chore was successful
chore
protected abstract void chore()
- Look for chores. If any found, do them else just return.
sleep
protected void sleep()
- Sleep for period.
Copyright © 2008 The Apache Software Foundation