Introduce initialization exception handler in KCL V2 (#369)

Added a new method to the WorkerStateChangeListener that is called once all attempts to initialize the scheduler have failed.
This commit is contained in:
jiaxul 2018-08-31 07:54:52 -07:00 committed by Justin Pfifer
parent 0634a3c836
commit ea49eef19e
2 changed files with 5 additions and 1 deletions

View file

@ -207,8 +207,9 @@ public class Scheduler implements Runnable {
try {
initialize();
log.info("Initialization complete. Starting worker loop.");
} catch (RuntimeException e) {
} catch (RuntimeException e) {
log.error("Unable to initialize after {} attempts. Shutting down.", maxInitializationAttempts, e);
workerStateChangeListener.onAllInitializationAttemptsFailed(e);
shutdown();
}

View file

@ -27,4 +27,7 @@ public interface WorkerStateChangeListener {
}
void onWorkerStateChange(WorkerState newState);
default void onAllInitializationAttemptsFailed(Throwable e) {
}
}