ConsoleCrossDcServer extends AbstractStartStoppable implements CrossDcClusterServer, LeaderAware, Observer, ApplicationContextAware { @Override public void notLeader() { try { stop(); setCrossDcLeader(false, "lose cluster leader"); } catch (Exception e) { logger.error("[isCrossDcLeader]", e); } }  @Override boolean amILeader(); @Override void update(Object crossDcLeader, Observable observable); @Override List<String> getAllServers(); @Override void isleader(); @Override void notLeader(); synchronized void setCrossDcLeader(boolean crossDcLeader, String reason); void forceSetCrossLeader(ConfigModel config, Date until); void refreshCrossLeaderStatus(); @Override void setApplicationContext(ApplicationContext applicationContext);  }
@Test public void testNotLeader() throws Exception { siteLeader.set(true); crossDcClusterServer.start(); Assert.assertTrue(consoleLeaderElector.amILeader()); sleep(electInterval); waitConditionUntilTimeOut(() -> !crossDcClusterServer.amILeader()); }