currentVotes); newLeader = LeaderElection.getLeader(candidates, getVotes()); } else { se.leaderVote = newLeader;
getVotes())); String newLeader = LeaderElection.getLeader(candidates, getVotes(), getLeader()); setLeader(newLeader);
  private void electLeader() {    //logger.info("electLeader");    try {      SortedSet candidates = getCandidates();      List currentVotes = getVotes();      String newLeader =          LeaderElection.getLeader(candidates, currentVotes);      StatusEntry se = (StatusEntry)statusMap.get(thisAgent);      if (se != null) {        if (newLeader == null || !newLeader.equals(preferredLeader)) {          se.leaderVote =              LeaderElection.chooseCandidate(preferredLeader,                                             candidates,                                             currentVotes);          newLeader = LeaderElection.getLeader(candidates, getVotes());        } else {          se.leaderVote = newLeader;        }      }      setLeader(newLeader);    } catch (Exception ex) {      logger.error(ex.getMessage() + " thisAgent=" + thisAgent, ex);    }  }