/** * Starts an election. * * <p>The election group is specified and a ThinkLeaderMessage is sent to every peer in that group * so they can start the bully algorithm. */ private void startLeaderElection() { ArrayList<PeerAddress> initialElectionGroup = new ArrayList<PeerAddress>(tmanPartners); initialElectionGroup.add(self); System.err.println( "[ELECTION::" + self.getPeerId() + "] The election group is " + initialElectionGroup); for (PeerAddress peer : tmanPartners) { trigger(new ThinkLeaderMessage(self, peer, initialElectionGroup), networkPort); } Stats.clearElectionMessages(); Stats.registerElectionMessages(tmanPartners.size()); }