Search in sources :

Example 1 with VotingState

use of org.opendaylight.controller.cluster.raft.VotingState in project controller by opendaylight.

the class EntityOwnershipShard method getViableCandidates.

private Collection<String> getViableCandidates(final Collection<String> candidates) {
    Map<MemberName, VotingState> memberToVotingState = new HashMap<>();
    getRaftActorContext().getPeers().forEach(peerInfo -> memberToVotingState.put(ShardIdentifier.fromShardIdString(peerInfo.getId()).getMemberName(), peerInfo.getVotingState()));
    Collection<String> viableCandidates = new ArrayList<>();
    for (String candidate : candidates) {
        MemberName memberName = MemberName.forName(candidate);
        if (memberToVotingState.get(memberName) != VotingState.NON_VOTING && !downPeerMemberNames.contains(memberName)) {
            viableCandidates.add(candidate);
        }
    }
    return viableCandidates;
}
Also used : HashMap(java.util.HashMap) VotingState(org.opendaylight.controller.cluster.raft.VotingState) ArrayList(java.util.ArrayList) MemberName(org.opendaylight.controller.cluster.access.concepts.MemberName)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 MemberName (org.opendaylight.controller.cluster.access.concepts.MemberName)1 VotingState (org.opendaylight.controller.cluster.raft.VotingState)1