@Test public void testLeaderCanHandleExistingPath() throws Exception { CuratorUtils.createPathIfNotExist(curator, zkPaths.getLeaderElectionPath(), true); CuratorUtils.createPathIfNotExist(curator, zkPaths.getLeaderAnnouncementPath(), true); ZookeeperLeaderElector elector = newZookeeperLeaderElector(); assertThat(elector.join()).isTrue(); awaitLeaderActivation(); }
@Override public boolean join() { synchronized (leaderElectionProcessRef) { if (leaderElectionProcessRef.get() == null) { leaderElectionProcessRef.set(new LeaderElectionProcess()); return true; } } return false; }
ZookeeperLeaderElector implements LeaderElector { @Override public boolean join() { synchronized (leaderElectionProcessRef) { if (leaderElectionProcessRef.get() == null) { leaderElectionProcessRef.set(new LeaderElectionProcess()); return true; } } return false; } }
ZookeeperLeaderElector implements LeaderElector { @Override public boolean join() { synchronized (leaderElectionProcessRef) { if (leaderElectionProcessRef.get() == null) { leaderElectionProcessRef.set(new LeaderElectionProcess()); return true; } } return false; } @Inject  ZookeeperLeaderElector(LeaderActivator leaderActivator,
                                  CuratorService curatorService,
                                  ZookeeperPaths zookeeperPaths,
                                  MasterDescription masterDescription,
                                  TitusRuntime titusRuntime); }
ZookeeperLeaderElector implements LeaderElector { @Override public boolean join() { synchronized (leaderElectionProcessRef) { if (leaderElectionProcessRef.get() == null) { leaderElectionProcessRef.set(new LeaderElectionProcess()); return true; } } return false; } @Inject  ZookeeperLeaderElector(LeaderActivator leaderActivator,
                                  CuratorService curatorService,
                                  ZookeeperPaths zookeeperPaths,
                                  MasterDescription masterDescription,
                                  TitusRuntime titusRuntime); @PreDestroy void shutdown(); @Override boolean join(); @Override boolean leaveIfNotLeader(); @Override Observable<MasterState> awaitElection(); }
ZookeeperLeaderElector implements LeaderElector { @Override public boolean join() { synchronized (leaderElectionProcessRef) { if (leaderElectionProcessRef.get() == null) { leaderElectionProcessRef.set(new LeaderElectionProcess()); return true; } } return false; } @Inject  ZookeeperLeaderElector(LeaderActivator leaderActivator,
                                  CuratorService curatorService,
                                  ZookeeperPaths zookeeperPaths,
                                  MasterDescription masterDescription,
                                  TitusRuntime titusRuntime); @PreDestroy void shutdown(); @Override boolean join(); @Override boolean leaveIfNotLeader(); @Override Observable<MasterState> awaitElection();  }