in registry-center/provider/zookeeper-curator/src/main/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperElectionService.java [39:58]
public ZookeeperElectionService(final String identity, final CuratorFramework client, final String electionPath, final ElectionCandidate electionCandidate) {
leaderSelector = new LeaderSelector(client, electionPath, new LeaderSelectorListenerAdapter() {
@Override
public void takeLeadership(final CuratorFramework client) throws Exception {
log.info("Elastic job: {} has leadership", identity);
try {
electionCandidate.startLeadership();
leaderLatch.await();
log.warn("Elastic job: {} lost leadership.", identity);
electionCandidate.stopLeadership();
} catch (final RegException exception) {
log.error("Elastic job: Starting error", exception);
System.exit(1);
}
}
});
leaderSelector.autoRequeue();
leaderSelector.setId(identity);
}