use of org.apache.ignite.raft.jraft.core.StateMachineAdapter in project ignite-3 by apache.
the class ItJraftCounterServerTest method hasLeader.
/**
* Returns {@code true} if a raft group has elected a leader for a some term.
*
* @param grpId Group id.
* @return {@code True} if a leader is elected.
*/
private boolean hasLeader(String grpId) {
return servers.stream().anyMatch(s -> {
NodeImpl node = (NodeImpl) s.raftGroupService(grpId).getRaftNode();
StateMachineAdapter fsm = (StateMachineAdapter) node.getOptions().getFsm();
return node.isLeader() && fsm.getLeaderTerm() == node.getCurrentTerm();
});
}
Aggregations