/** Start the registration of the {@link #candidate} for leader election. */ @Override public synchronized void start() { if (!running) { if (client.getState() != CuratorFrameworkState.STARTED) { // we want to do curator start here because it needs to // be started before leader selector and it gets a little // complicated to control ordering via beans so that // curator is fully started. client.start(); } leaderSelector = new LeaderSelector(client, buildLeaderPath(), new LeaderListener()); leaderSelector.setId(candidate.getId()); leaderSelector.autoRequeue(); leaderSelector.start(); running = true; } }
public ExampleClient(CuratorFramework client, String path, String name) { this.name = name; leaderSelector = new LeaderSelector(client, path, this); leaderSelector.autoRequeue(); }