Search in sources :

Example 1 with Participant

use of org.apache.curator.framework.recipes.leader.Participant in project storm by apache.

the class LeaderElectorImp method getAllNimbuses.

@Override
public List<NimbusInfo> getAllNimbuses() throws Exception {
    List<NimbusInfo> nimbusInfos = new ArrayList<>();
    Collection<Participant> participants = leaderLatch.get().getParticipants();
    for (Participant participant : participants) {
        nimbusInfos.add(Zookeeper.toNimbusInfo(participant));
    }
    return nimbusInfos;
}
Also used : Participant(org.apache.curator.framework.recipes.leader.Participant) ArrayList(java.util.ArrayList) NimbusInfo(org.apache.storm.nimbus.NimbusInfo)

Example 2 with Participant

use of org.apache.curator.framework.recipes.leader.Participant in project alluxio by Alluxio.

the class LeaderSelectorClient method getParticipants.

/**
   * @return the list of participants
   */
public List<String> getParticipants() {
    try {
        List<Participant> participants = new ArrayList<>(mLeaderSelector.getParticipants());
        List<String> results = new ArrayList<>();
        for (Participant part : participants) {
            results.add(part.getId());
        }
        return results;
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        return null;
    }
}
Also used : Participant(org.apache.curator.framework.recipes.leader.Participant) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 3 with Participant

use of org.apache.curator.framework.recipes.leader.Participant in project druid by druid-io.

the class DruidCoordinator method getCurrentLeader.

public String getCurrentLeader() {
    try {
        final LeaderLatch latch = leaderLatch.get();
        if (latch == null) {
            return null;
        }
        Participant participant = latch.getLeader();
        if (participant.isLeader()) {
            return participant.getId();
        }
        return null;
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : Participant(org.apache.curator.framework.recipes.leader.Participant) LeaderLatch(org.apache.curator.framework.recipes.leader.LeaderLatch) IOException(java.io.IOException)

Aggregations

Participant (org.apache.curator.framework.recipes.leader.Participant)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 LeaderLatch (org.apache.curator.framework.recipes.leader.LeaderLatch)1 NimbusInfo (org.apache.storm.nimbus.NimbusInfo)1