Пример #1
0
    @Override
    public void event(LeadershipEvent event) {
      Leadership leadership = event.subject();

      if (Objects.equals(leadership.leaderNodeId(), localNodeId)
          && leadership.topic().startsWith(ELECTION_PREFIX)) {

        eventDispatcher.post(
            new WorkPartitionEvent(WorkPartitionEvent.Type.LEADER_CHANGED, leadership.topic()));
      }

      if (event.type() == LeadershipEvent.Type.CANDIDATES_CHANGED) {
        scheduleRebalance(0);
      }
    }
Пример #2
0
 @Override
 public void event(LeadershipEvent event) {
   if (event.subject().topic().equals(appId.name())) {
     processLeadershipChange(event.subject().leader());
   }
 }