use of com.dangdang.ddframe.job.cloud.scheduler.ha.SchedulerElectionCandidate in project elastic-job by dangdangdotcom.
the class Bootstrap method main.
/**
* 启动入口.
*
* @param args 命令行参数无需传入
* @throws InterruptedException 线程中断异常
*/
// CHECKSTYLE:OFF
public static void main(final String[] args) throws InterruptedException {
// CHECKSTYLE:ON
CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(BootstrapEnvironment.getInstance().getZookeeperConfiguration());
regCenter.init();
final ZookeeperElectionService electionService = new ZookeeperElectionService(BootstrapEnvironment.getInstance().getFrameworkHostPort(), (CuratorFramework) regCenter.getRawClient(), HANode.ELECTION_NODE, new SchedulerElectionCandidate(regCenter));
electionService.start();
final CountDownLatch latch = new CountDownLatch(1);
latch.await();
Runtime.getRuntime().addShutdownHook(new Thread("shutdown-hook") {
@Override
public void run() {
electionService.stop();
latch.countDown();
}
});
}
Aggregations