Make lastException from initialize() available

During each run of initialize() an exception could be encountered, this makes that exception available via a getter to whatever created the thread to be able to take further action with it.
This commit is contained in:
Chris Collins 2018-03-15 11:16:49 -03:00
parent a53473d536
commit 7206ba14f6

View file

@ -104,6 +104,7 @@ public class Worker implements Runnable {
private volatile boolean shutdown;
private volatile long shutdownStartTimeMillis;
private volatile boolean shutdownComplete = false;
private volatile Exception lastException = null;
// Holds consumers for shards the worker is currently tracking. Key is shard
// info, value is ShardConsumer.
@ -617,7 +618,6 @@ public class Worker implements Runnable {
private void initialize() {
workerStateChangeListener.onWorkerStateChange(WorkerStateChangeListener.WorkerState.INITIALIZING);
boolean isDone = false;
Exception lastException = null;
for (int i = 0; (!isDone) && (i < MAX_INITIALIZATION_ATTEMPTS); i++) {
try {
@ -882,6 +882,14 @@ public class Worker implements Runnable {
return workerStateChangeListener;
}
/**
* The last of any exception encountered during initialize() will be available here
*/
public Exception getLastException()
{
return lastException;
}
/**
* Signals worker to shutdown. Worker will try initiating shutdown of all record processors. Note that if executor
* services were passed to the worker by the user, worker will not attempt to shutdown those resources.