@Override public synchronized void onControllerChange(NotificationContext changeContext) { ControllerManagerHelper controllerHelper = new ControllerManagerHelper(_manager, _controllerTimerTasks); try { switch (changeContext.getType()) { case INIT: case CALLBACK: acquireLeadership(_manager, controllerHelper); break; case FINALIZE: relinquishLeadership(_manager, controllerHelper); break; default: LOG.info("Ignore controller change event {}. Type {}.", changeContext.getEventName(), changeContext.getType().name()); } } catch (Exception e) { LOG.error("Exception when trying to become leader", e); } }