@Override public void awaitLiveNode() throws Exception { LOGGER.debug("ENTER awaitLiveNode"); try { boolean liveWhileLocked = false; while (!liveWhileLocked) { //check first without holding any lock final SharedStateManager.State state = readSharedState(); if (state == SharedStateManager.State.LIVE) { //verify if the state is live while holding the live node lock too liveWhileLocked = lockLiveAndCheckLiveState(); } else { LOGGER.debugf("state while awaiting live node: %s", state); } if (!liveWhileLocked) { checkInterrupted(() -> "awaitLiveNode got interrupted!"); pauser.idle(); } } //state is LIVE and live lock is acquired and valid LOGGER.debugf("acquired live node lock while state is %s: starting scheduledLiveLock", SharedStateManager.State.LIVE); this.scheduledLiveLock.start(); } finally { LOGGER.debug("EXIT awaitLiveNode"); } }