Package org.apache.twill.api

Examples of org.apache.twill.api.ElectionHandler


    try {
      keyCache.init();
    } catch (InterruptedException ie) {
      throw Throwables.propagate(ie);
    }
    this.leaderElection = new LeaderElection(zookeeper, "/leader", new ElectionHandler() {
      @Override
      public void leader() {
        leader.set(true);
        LOG.info("Transitioned to leader");
        if (currentKey == null) {
View Full Code Here


  @Override
  public void start() {
    zkClientService.startAndWait();

    leaderElection = new LeaderElection(zkClientService, "/election/" + serviceName, new ElectionHandler() {
      @Override
      public void leader() {
        LOG.info("Became leader.");
        Injector injector = baseInjector.createChildInjector(new TwillModule());
        twillRunnerService = injector.getInstance(TwillRunnerService.class);
View Full Code Here

    return server.getBindAddress();
  }

  @Override
  protected void doStart() {
    leaderElection = new LeaderElection(zkClient, "/tx.service/leader", new ElectionHandler() {
      @Override
      public void leader() {
        // if the txManager fails, we should stop the server
        txManager = txManagerProvider.get();
        txManager.addListener(new ServiceListenerAdapter() {
View Full Code Here

    LogAppenderInitializer logAppenderInitializer = baseInjector.getInstance(LogAppenderInitializer.class);
    logAppenderInitializer.initialize();

    Services.chainStart(zkClientService, kafkaClientService, metricsCollectionService);

    leaderElection = new LeaderElection(zkClientService, "/election/" + serviceName, new ElectionHandler() {
      @Override
      public void leader() {
        Map<String, Integer> instanceCount = getSystemServiceInstances();
        twillApplication = createTwillApplication(instanceCount);
        if (twillApplication == null) {
View Full Code Here

  public DistributedStreamFileJanitorService(ZKClient zkClient,
                                             final StreamFileJanitor janitor,
                                             final CConfiguration cConf) {

    String electionPrefix = "/" + Constants.Service.STREAMS + "/leader";
    leaderElection = new LeaderElection(zkClient, electionPrefix, new ElectionHandler() {

      Service janitorService;

      @Override
      public void leader() {
View Full Code Here

    return server.getBindAddress();
  }

  @Override
  protected void doStart() {
    leaderElection = new LeaderElection(zkClient, "/tx.service/leader", new ElectionHandler() {
      @Override
      public void leader() {
        // if the txManager fails, we should stop the server
        txManager = txManagerProvider.get();
        txManager.addListener(new ServiceListenerAdapter() {
View Full Code Here

  private void runElection(Set<Integer> partitions) throws Exception {
    for (final int partition : partitions) {
      // Start leader election.
      LOG.info("Start leader election for partition {}", partition);
      LeaderElection election =
        new LeaderElection(zkClient, String.format("/election/%s/part-%d", name, partition), new ElectionHandler() {
          @Override
          public void leader() {
            leaderPartitions.add(partition);
            executor.submit(runHandler);
          }
View Full Code Here

    return server.getBindAddress();
  }

  @Override
  protected void doStart() {
    leaderElection = new LeaderElection(zkClient, "/tx.service/leader", new ElectionHandler() {
      @Override
      public void leader() {
        // if the txManager fails, we should stop the server
        txManager = txManagerProvider.get();
        txManager.addListener(new ServiceListenerAdapter() {
View Full Code Here

TOP

Related Classes of org.apache.twill.api.ElectionHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.