Ejemplo n.º 1
0
  @Deactivate
  public void deactivate() {
    executor.shutdownNow();

    eventDispatcher.removeSink(WorkPartitionEvent.class);
    leadershipService.removeListener(leaderListener);
    log.info("Stopped");
  }
Ejemplo n.º 2
0
  @Activate
  public void activate() {
    localNodeId = clusterService.getLocalNode().id();
    leadershipService.addListener(leaderListener);

    listenerRegistry = new ListenerRegistry<>();
    eventDispatcher.addSink(WorkPartitionEvent.class, listenerRegistry);

    for (int i = 0; i < NUM_PARTITIONS; i++) {
      leadershipService.runForLeadership(getPartitionPath(i));
      log.debug("Registered to run for {}", getPartitionPath(i));
    }

    executor.scheduleAtFixedRate(
        () -> scheduleRebalance(0), 0, CHECK_PARTITION_BALANCE_PERIOD_SEC, TimeUnit.SECONDS);
    log.info("Started");
  }