Search in sources :

Example 1 with ZookeeperElectionService

use of com.dangdang.ddframe.job.reg.zookeeper.ZookeeperElectionService 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();
        }
    });
}
Also used : ZookeeperRegistryCenter(com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter) ZookeeperElectionService(com.dangdang.ddframe.job.reg.zookeeper.ZookeeperElectionService) CountDownLatch(java.util.concurrent.CountDownLatch) SchedulerElectionCandidate(com.dangdang.ddframe.job.cloud.scheduler.ha.SchedulerElectionCandidate) CoordinatorRegistryCenter(com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter)

Aggregations

SchedulerElectionCandidate (com.dangdang.ddframe.job.cloud.scheduler.ha.SchedulerElectionCandidate)1 CoordinatorRegistryCenter (com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter)1 ZookeeperElectionService (com.dangdang.ddframe.job.reg.zookeeper.ZookeeperElectionService)1 ZookeeperRegistryCenter (com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter)1 CountDownLatch (java.util.concurrent.CountDownLatch)1