|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.util.HasThread
org.apache.hadoop.hbase.Chore
@InterfaceAudience.Private public abstract class Chore
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.
Field Summary | |
---|---|
protected Stoppable |
stopper
|
Constructor Summary | |
---|---|
protected |
Chore()
This constructor is for test only. |
|
Chore(String name,
int p,
Stoppable stopper)
|
Method Summary | |
---|---|
protected abstract void |
chore()
Look for chores. |
void |
choreForTesting()
|
protected void |
cleanup()
Called when the chore has completed, allowing subclasses to cleanup any extra overhead |
protected boolean |
initialChore()
Override to run a task before we start looping. |
void |
run()
|
protected void |
sleep()
Sleep for period. |
void |
triggerNow()
If the thread is currently sleeping, trigger the core to happen immediately. |
Methods inherited from class org.apache.hadoop.hbase.util.HasThread |
---|
getName, getThread, interrupt, isAlive, isInterrupted, join, join, join, setDaemon, setName, setPriority, setUncaughtExceptionHandler, start |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Stoppable stopper
Constructor Detail |
---|
public Chore(String name, int p, Stoppable stopper)
p
- Period at which we should run. Will be adjusted appropriately
should we find work and it takes time to complete.stopper
- When Stoppable.isStopped()
is true, this thread will
cleanup and exit cleanly.protected Chore()
Method Detail |
---|
public void run()
run
in interface Runnable
run
in class HasThread
Thread.run()
public void triggerNow()
public void choreForTesting()
protected boolean initialChore()
protected abstract void chore()
protected void sleep()
protected void cleanup()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |