@Override public void start() throws Exception { mJournalSystem.start(); try { mLeaderSelector.start(getRpcAddress()); } catch (IOException e) { LOG.error(e.getMessage(), e); throw new RuntimeException(e); } startMasters(false); LOG.info("Secondary started"); while (!Thread.interrupted()) { mLeaderSelector.waitForState(State.PRIMARY); if (gainPrimacy()) { mLeaderSelector.waitForState(State.SECONDARY); losePrimacy(); } } }
if (mServingThread == null) { mLeaderSelector.waitForState(State.PRIMARY); LOG.info("Transitioning from secondary to primary"); mJournalSystem.gainPrimacy(); } else { mLeaderSelector.waitForState(State.SECONDARY); LOG.info("Transitioning from primary to secondary"); stopServing();
@Override public void start() throws Exception { mJournalSystem.start(); try { mLeaderSelector.start(getRpcAddress()); } catch (IOException e) { LOG.error(e.getMessage(), e); throw new RuntimeException(e); } startMasters(false); LOG.info("Secondary started"); while (!Thread.interrupted()) { mLeaderSelector.waitForState(State.PRIMARY); if (gainPrimacy()) { mLeaderSelector.waitForState(State.SECONDARY); losePrimacy(); } } }