public abstract class GridWorker extends Object implements Runnable, WorkProgressDispatcher
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
isCancelled
Whether or not this runnable is cancelled.
|
protected IgniteLogger |
log
Ignite logger.
|
| Modifier | Constructor and Description |
|---|---|
protected |
GridWorker(@Nullable String igniteInstanceName,
String name,
IgniteLogger log)
Creates new grid worker with given parameters.
|
protected |
GridWorker(String igniteInstanceName,
String name,
IgniteLogger log,
@Nullable GridWorkerListener lsnr)
Creates new grid worker with given parameters.
|
| Modifier and Type | Method and Description |
|---|---|
void |
blockingSectionBegin()
Protects the worker from timeout penalties if subsequent instructions in the calling thread does not update
heartbeat timestamp timely, e.g. due to blocking operations, up to the nearest
WorkProgressDispatcher.blockingSectionEnd()
call. |
void |
blockingSectionEnd()
Closes the protection section previously opened by
WorkProgressDispatcher.blockingSectionBegin(). |
protected abstract void |
body()
The implementation should provide the execution body for this runnable.
|
void |
cancel()
Cancels this runnable interrupting actual runner.
|
protected void |
cleanup()
Optional method that will be called after runnable is finished.
|
long |
heartbeatTs()
Last heatbeat timestamp.
|
String |
igniteInstanceName()
Gets name of the Ignite instance this runnable belongs to.
|
boolean |
isCancelled()
Tests whether or not this runnable is cancelled.
|
boolean |
isDone()
Tests whether or not this runnable is finished.
|
void |
join()
Joins this runnable.
|
String |
name()
Gets this runnable name.
|
protected void |
onIdle()
Can be called from
runner() thread to perform idleness handling. |
void |
run() |
Thread |
runner() |
String |
toString() |
void |
updateHeartbeat()
Notifying dispatcher that work is in progress and thread didn't freeze.
|
protected final IgniteLogger log
protected volatile boolean isCancelled
protected GridWorker(String igniteInstanceName, String name, IgniteLogger log, @Nullable @Nullable GridWorkerListener lsnr)
igniteInstanceName - Name of the Ignite instance this runnable is used in.name - Worker name. Note that in general thread name and worker (runnable) name are two different things.
The same worker can be executed by multiple threads and therefore for logging and debugging purposes we separate
the two.log - Grid logger to be used.lsnr - Listener for life-cycle events.protected GridWorker(@Nullable
@Nullable String igniteInstanceName,
String name,
IgniteLogger log)
igniteInstanceName - Name of the Ignite instance this runnable is used in.name - Worker name. Note that in general thread name and worker (runnable) name are two different things.
The same worker can be executed by multiple threads and therefore for logging and debugging purposes we separate
the two.log - Grid logger to be used.protected abstract void body()
throws InterruptedException,
IgniteInterruptedCheckedException
InterruptedException - Thrown in case of interruption.IgniteInterruptedCheckedException - If interrupted.protected void cleanup()
public Thread runner()
public String igniteInstanceName()
public String name()
public void cancel()
public void join()
throws InterruptedException
InterruptedException - Thrown in case of interruption.public boolean isCancelled()
true if this runnable is cancelled - false otherwise.Future.isCancelled()public boolean isDone()
true if this runnable is finished - false otherwise.public long heartbeatTs()
heartbeatTs in interface WorkProgressDispatcherpublic void updateHeartbeat()
updateHeartbeat in interface WorkProgressDispatcherpublic void blockingSectionBegin()
WorkProgressDispatcher.blockingSectionEnd()
call. Nested calls are not supported.blockingSectionBegin in interface WorkProgressDispatcherpublic void blockingSectionEnd()
WorkProgressDispatcher.blockingSectionBegin().blockingSectionEnd in interface WorkProgressDispatcherprotected void onIdle()
runner() thread to perform idleness handling.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.11.1 Release Date : December 20 2021