public synchronized void restartLeaderElection(QuorumVerifier qvOLD, QuorumVerifier qvNEW){ if (qvOLD == null || !qvOLD.equals(qvNEW)) { LOG.warn("Restarting Leader Election"); getElectionAlg().shutdown(); shuttingDownLE = false; startLeaderElection(); } }
@After public void tearDown() throws Exception { for(int i = 0; i < restartThreads.size(); i++) { ((FastLeaderElection) restartThreads.get(i).peer.getElectionAlg()).shutdown(); } }
@After public void tearDown() throws Exception { for(int i = 0; i < threads.size(); i++) { ((FastLeaderElection) threads.get(i).peer.getElectionAlg()).shutdown(); } }
public void shutdown() { running = false; x509Util.close(); if (leader != null) { leader.shutdown("quorum Peer shutdown"); } if (follower != null) { follower.shutdown(); } shutdownServerCnxnFactory(); if(udpSocket != null) { udpSocket.close(); } try { adminServer.shutdown(); } catch (AdminServerException e) { LOG.warn("Problem stopping AdminServer", e); } if(getElectionAlg() != null){ this.interrupt(); getElectionAlg().shutdown(); } try { zkDb.close(); } catch (IOException ie) { LOG.warn("Error closing logs ", ie); } }
public void shutdown() { running = false; if (leader != null) { leader.shutdown("quorum Peer shutdown"); } if (follower != null) { follower.shutdown(); } cnxnFactory.shutdown(); if(udpSocket != null) { udpSocket.close(); } if(getElectionAlg() != null){ this.interrupt(); getElectionAlg().shutdown(); } try { zkDb.close(); } catch (IOException ie) { LOG.warn("Error closing logs ", ie); } }
peer.setPeerState(ServerState.LOOKING); LOG.info("Going to call leader election again: " + i); v = peer.getElectionAlg().lookForLeader();
LOG.info("restarting leader election"); self.shuttingDownLE = true; self.getElectionAlg().shutdown();
peer.setPeerState(ServerState.LOOKING); LOG.info("Going to call leader election again."); v = peer.getElectionAlg().lookForLeader(); if(v == null){ LOG.info("Thread " + i + " got a null vote"); LOG.info("First peer, shutting it down"); QuorumBase.shutdown(peer); ((FastLeaderElection) restartThreads.get(i).peer.getElectionAlg()).shutdown();
public void run() { try { Vote v = null; peer.setPeerState(ServerState.LOOKING); LOG.info("Going to call leader election: {}", i); v = peer.getElectionAlg().lookForLeader(); if (v == null) { Assert.fail("Thread " + i + " got a null vote"); } /* * A real zookeeper would take care of setting the current vote. Here * we do it manually. */ peer.setCurrentVote(v); LOG.info("Finished election: {}, {}", i, v.getId()); Assert.assertTrue("State is not leading.", peer.getPeerState() == ServerState.LEADING); } catch (Exception e) { e.printStackTrace(); } LOG.info("Joining"); } }
v = peer.getElectionAlg().lookForLeader(); if(v == null){ LOG.info("Thread " + i + " got a null vote");
public void shutdown(int id) { QuorumPeer qp = getPeer(id).peer; try { LOG.info("Shutting down quorum peer " + qp.getName()); qp.shutdown(); Election e = qp.getElectionAlg(); if (e != null) { LOG.info("Shutting down leader election " + qp.getName()); e.shutdown(); } else { LOG.info("No election available to shutdown " + qp.getName()); } LOG.info("Waiting for " + qp.getName() + " to exit thread"); qp.join(30000); if (qp.isAlive()) { Assert.fail("QP failed to shutdown in 30 seconds: " + qp.getName()); } } catch (InterruptedException e) { LOG.debug("QP interrupted: " + qp.getName(), e); } }
public static void shutdown(QuorumPeer qp) { if (qp == null) { return; } try { LOG.info("Shutting down quorum peer " + qp.getName()); qp.shutdown(); Election e = qp.getElectionAlg(); if (e != null) { LOG.info("Shutting down leader election " + qp.getName()); e.shutdown(); } else { LOG.info("No election available to shutdown " + qp.getName()); } LOG.info("Waiting for " + qp.getName() + " to exit thread"); long readTimeout = qp.getTickTime() * qp.getInitLimit(); long connectTimeout = qp.getTickTime() * qp.getSyncLimit(); long maxTimeout = Math.max(readTimeout, connectTimeout); maxTimeout = Math.max(maxTimeout, ClientBase.CONNECTION_TIMEOUT); qp.join(maxTimeout * 2); if (qp.isAlive()) { Assert.fail("QP failed to shutdown in " + (maxTimeout * 2) + " seconds: " + qp.getName()); } } catch (InterruptedException e) { LOG.debug("QP interrupted: " + qp.getName(), e); } }
v = peer.getElectionAlg().lookForLeader(); if(v == null){ LOG.info("Thread " + i + " got a null vote"); int lc = (int) ((FastLeaderElection) peer.getElectionAlg()).getLogicalClock(); LOG.info("Leader " + i + " dying"); FastLeaderElection election = (FastLeaderElection) peer.getElectionAlg(); election.shutdown();
public void shutdown() { running = false; if (leader != null) { leader.shutdown("quorum Peer shutdown"); } if (follower != null) { follower.shutdown(); } cnxnFactory.shutdown(); if(udpSocket != null) { udpSocket.close(); } if(getElectionAlg() != null){ getElectionAlg().shutdown(); } try { zkDb.close(); } catch (IOException ie) { LOG.warn("Error closing logs ", ie); } }
public void shutdown() { running = false; if (leader != null) { leader.shutdown("quorum Peer shutdown"); } if (follower != null) { follower.shutdown(); } cnxnFactory.shutdown(); if(udpSocket != null) { udpSocket.close(); } if(getElectionAlg() != null){ this.interrupt(); getElectionAlg().shutdown(); } try { zkDb.close(); } catch (IOException ie) { LOG.warn("Error closing logs ", ie); } }