public SchedulerSelector(WorkflowManagerImpl workflowManager, QueueFactory queueFactory, AutoCleanerHolder autoCleanerHolder) { this.workflowManager = workflowManager; this.queueFactory = queueFactory; this.autoCleanerHolder = autoCleanerHolder; LeaderSelectorListener listener = new LeaderSelectorListenerAdapter() { @Override public void takeLeadership(CuratorFramework client) throws Exception { SchedulerSelector.this.takeLeadership(); } }; leaderSelector = new LeaderSelector(workflowManager.getCurator(), ZooKeeperConstants.getSchedulerLeaderPath(), listener); leaderSelector.autoRequeue(); }