/** * Start up Leader ZooKeeper server and initialize zxid to the new epoch */ private synchronized void startZkServer() { // Update lastCommitted and Db's zxid to a value representing the new epoch lastCommitted = zk.getZxid(); LOG.info("Have quorum of supporters, sids: [ " + getSidSetString(newLeaderProposal.ackSet) + " ]; starting up and setting last processed zxid: 0x{}", Long.toHexString(zk.getZxid())); zk.startup(); /* * Update the election vote here to ensure that all members of the * ensemble report the same vote to new servers that start up and * send leader election notifications to the ensemble. * * @see https://issues.apache.org/jira/browse/ZOOKEEPER-1732 */ self.updateElectionVote(getEpoch()); zk.getZKDatabase().setlastProcessedZxid(zk.getZxid()); }
database.setlastProcessedZxid(2L); QuorumPeer quorumPeer = mock(QuorumPeer.class); FileTxnSnapLog logfactory = mock(FileTxnSnapLog.class);
zk.getZKDatabase().setlastProcessedZxid(zk.getZxid());
/** * ZOOKEEPER-1573: test restoring a snapshot with deleted txns ahead of the * snapshot file's zxid. */ @Test public void testReloadSnapshotWithMissingParent() throws Exception { // create transactions to create the snapshot with create/delete pattern ZooKeeper zk = createZKClient(hostPort); zk.create("/a", "".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); Stat stat = zk.exists("/a", false); long createZxId = stat.getMzxid(); zk.create("/a/b", "".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); zk.delete("/a/b", -1); zk.delete("/a", -1); // force the zxid to be behind the content ZooKeeperServer zks = getServer(serverFactory); zks.getZKDatabase().setlastProcessedZxid(createZxId); LOG.info("Set lastProcessedZxid to {}", zks.getZKDatabase() .getDataTreeLastProcessedZxid()); // Force snapshot and restore zks.takeSnapshot(); zks.shutdown(); stopServer(); startServer(); } }
throw new IOException("Missing signature"); zk.getZKDatabase().setlastProcessedZxid(qp.getZxid()); System.exit(ExitCode.QUORUM_PACKET_ERROR.getValue()); zk.getZKDatabase().setlastProcessedZxid(qp.getZxid());
throw new IOException("Missing signature"); zk.getZKDatabase().setlastProcessedZxid(qp.getZxid()); } else if (qp.getType() == Leader.TRUNC) { System.exit(13); zk.getZKDatabase().setlastProcessedZxid(qp.getZxid());
long eZxid = zks.getZKDatabase().getDataTreeLastProcessedZxid(); zks.getZKDatabase().setlastProcessedZxid( zks.getZKDatabase().getDataTreeLastProcessedZxid() - 10); LOG.info("Set lastProcessedZxid to "
zks.getZKDatabase().setlastProcessedZxid( zks.getZKDatabase().getDataTreeLastProcessedZxid() - 10); LOG.info("Set lastProcessedZxid to "
zk.getZKDatabase().setlastProcessedZxid(newLeaderZxid);
epoch++; zk.setZxid(epoch << 32L); zk.getZKDatabase().setlastProcessedZxid(zk.getZxid());