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;
}
Aggregations