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

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

View file

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