public abstract class PersistentJobRunnerImpl extends java.lang.Object implements PersistentJobRunner
PersistentJobRunner.CheckpointLock
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
serializeCheckpoints |
Constructor and Description |
---|
PersistentJobRunnerImpl(Executor executor,
Ticker ticker,
long interval) |
Modifier and Type | Method and Description |
---|---|
void |
checkpointOffThread() |
void |
delayedCheckpoint() |
void |
disableWrite() |
protected ClientContext |
getClientContext() |
void |
handleCompletion(boolean ret,
int threadPriority) |
boolean |
hasLoaded()
Has the queue started yet?
|
protected abstract void |
innerCheckpoint(boolean shutdown) |
boolean |
isKilledOrNotLoaded() |
void |
killAndWaitForNotRunning() |
protected void |
killAndWaitForNotWriting()
Set the killed flag and wait until we are not writing
|
PersistentJobRunner.CheckpointLock |
lock()
Obtain a lock which will prevent checkpointing until it is unlocked.
|
protected void |
onLoading() |
protected void |
onStarted(boolean noWrite) |
void |
queue(PersistentJob job,
int threadPriority)
Start a job immediately unless we are about to write a checkpoint.
|
void |
queueInternal(PersistentJob job)
Start an "internal" job.
|
void |
queueInternal(PersistentJob job,
int threadPriority)
Start an "internal" job.
|
void |
queueNormalOrDrop(PersistentJob job)
Queue the job at low thread priority or drop it if persistence is disabled.
|
void |
setCheckpointASAP()
Commit ASAP.
|
void |
shutdown() |
boolean |
shuttingDown()
If true, the node is shutting down
|
void |
start(ClientContext context) |
protected void |
updateLastCheckpointed() |
void |
waitAndCheckpoint()
Wait until a checkpoint has been completed, or if the job runner becomes idle, do it here.
|
void |
waitForIdleAndCheckpoint()
Typically called after shutdown() to wait for current jobs to complete.
|
void |
waitForNotWriting() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
newSalt
public void start(ClientContext context)
public void queue(PersistentJob job, int threadPriority) throws PersistenceDisabledException
PersistentJobRunner
queue
in interface PersistentJobRunner
job
- The job to run now or after the checkpoint.threadPriority
- The priority of the job.PersistenceDisabledException
- If persistence is disabled.public void queueInternal(PersistentJob job, int threadPriority) throws PersistenceDisabledException
PersistentJobRunner
queueInternal
in interface PersistentJobRunner
PersistenceDisabledException
public void queueInternal(PersistentJob job)
PersistentJobRunner
queueInternal
in interface PersistentJobRunner
public void queueNormalOrDrop(PersistentJob job)
PersistentJobRunner
queueNormalOrDrop
in interface PersistentJobRunner
public void handleCompletion(boolean ret, int threadPriority)
public void delayedCheckpoint()
public void checkpointOffThread()
public void setCheckpointASAP()
PersistentJobRunner
setCheckpointASAP
in interface PersistentJobRunner
protected void updateLastCheckpointed()
protected abstract void innerCheckpoint(boolean shutdown)
protected void onLoading()
protected void onStarted(boolean noWrite)
public void shutdown()
public boolean shuttingDown()
PersistentJobRunner
shuttingDown
in interface PersistentJobRunner
public void waitForIdleAndCheckpoint()
public void waitAndCheckpoint() throws PersistenceDisabledException
PersistenceDisabledException
protected void killAndWaitForNotWriting()
public void waitForNotWriting()
public void killAndWaitForNotRunning()
public boolean isKilledOrNotLoaded()
public boolean hasLoaded()
PersistentJobRunner
hasLoaded
in interface PersistentJobRunner
protected ClientContext getClientContext()
public PersistentJobRunner.CheckpointLock lock() throws PersistenceDisabledException
PersistentJobRunner
lock
in interface PersistentJobRunner
PersistenceDisabledException
- If we are unable to lock because the system is shutting
down.public void disableWrite()