protected Follower makeFollower(FileTxnSnapLog logFactory) throws IOException { return new Follower(this, new FollowerZooKeeperServer(logFactory, this, this.zkDb)); }
@Override protected Follower makeFollower(FileTxnSnapLog logFactory) throws IOException { return new Follower(this, new FollowerZooKeeperServer(logFactory, this, this.getZkDb())) { @Override protected void processPacket(QuorumPacket qp) throws Exception { if (stopPing && qp.getType() == Leader.PING) { LOG.info("Follower skipped ping"); throw new SocketException("Socket time out while sending the ping response"); } else { super.processPacket(qp); } } }; }
@Override protected Follower makeFollower(FileTxnSnapLog logFactory) throws IOException { return new Follower(this, new FollowerZooKeeperServer(logFactory, this, this.getZkDb())) { @Override void readPacket(QuorumPacket pp) throws IOException { /** * In real scenario got SocketTimeoutException while reading * the packet from leader because of network problem, but * here throwing SocketTimeoutException based on whether * error is injected or not */ super.readPacket(pp); if (injectError && pp.getType() == Leader.PROPOSAL) { String type = LearnerHandler.packetToString(pp); throw new SocketTimeoutException( "Socket timeout while reading the packet for operation " + type); } } }; }
@Override protected Follower makeFollower(FileTxnSnapLog logFactory) throws IOException { return new Follower(this, new FollowerZooKeeperServer(logFactory, this, this.getZkDb())) { @Override void writePacket(QuorumPacket pp, boolean flush) throws IOException { if (pp != null && pp.getType() == Leader.ACK) { newLeaderMessage = true; try { /** * Delaying the ACK message, a follower sends as * response to a NEWLEADER message, so that the * leader has a chance to send the reconfig and only * then the UPTODATE message. */ Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } super.writePacket(pp, flush); } }; } }
protected Follower makeFollower(FileTxnSnapLog logFactory) throws IOException { return new Follower(this, new FollowerZooKeeperServer(logFactory, this,new ZooKeeperServer.BasicDataTreeBuilder(), this.zkDb)); }
@Override protected Follower makeFollower(FileTxnSnapLog logFactory) throws IOException { return new Follower(this, new FollowerZooKeeperServer(logFactory, this, this.getZkDb())) { @Override void followLeader() throws InterruptedException { if (context.quitFollowing) { // reset the flag context.quitFollowing = false; LOG.info("Quit following"); return; } else { super.followLeader(); } } @Override void writePacket(QuorumPacket pp, boolean flush) throws IOException { if (pp != null && pp.getType() == Leader.ACK && context.exitWhenAckNewLeader) { if (context.newLeaderAckCallback != null) { context.newLeaderAckCallback.start(); } } super.writePacket(pp, flush); } }; }
throws IOException { return new Follower(this, new FollowerZooKeeperServer( logFactory, this, this.getZkDb())) {
private ConversableFollower createFollower(File tmpDir, QuorumPeer peer) throws IOException { FileTxnSnapLog logFactory = new FileTxnSnapLog(tmpDir, tmpDir); peer.setTxnFactory(logFactory); ZKDatabase zkDb = new ZKDatabase(logFactory); FollowerZooKeeperServer zk = new FollowerZooKeeperServer(logFactory, peer, zkDb); peer.setZKDatabase(zkDb); return new ConversableFollower(peer, zk); }
fzks = new FollowerZooKeeperServer(logfactory, quorumPeer, database); fzks.startup(); fzks.setServerCnxnFactory(serverCnxnFactory);
protected Follower makeFollower(FileTxnSnapLog logFactory) throws IOException { return new Follower(this, new FollowerZooKeeperServer(logFactory, this,new ZooKeeperServer.BasicDataTreeBuilder(), this.zkDb)); }
protected Follower makeFollower(FileTxnSnapLog logFactory) throws IOException { return new Follower(this, new FollowerZooKeeperServer(logFactory, this,new ZooKeeperServer.BasicDataTreeBuilder(), this.zkDb)); }