/** * Truncate the ZKDatabase to the specified zxid * @param zxid the zxid to truncate zk database to * @return true if the truncate is successful and false if not * @throws IOException */ public boolean truncateLog(long zxid) throws IOException { clear(); // truncate the log boolean truncated = snapLog.truncateLog(zxid); if (!truncated) { return false; } loadDataBase(); return true; }
/** * Truncate the ZKDatabase to the specified zxid * @param zxid the zxid to truncate zk database to * @return true if the truncate is successful and false if not * @throws IOException */ public boolean truncateLog(long zxid) throws IOException { clear(); // truncate the log boolean truncated = snapLog.truncateLog(zxid); if (!truncated) { return false; } loadDataBase(); return true; }
private void loadDataBase() { try { zkDb.loadDataBase();
UPDATING_EPOCH_FILENAME); try { zkDb.loadDataBase();
setZxid(zkDb.loadDataBase());
setZxid(zkDb.loadDataBase());
try { zks.startdata(); zxid = zks.getZKDatabase().loadDataBase(); Assert.fail("Should have gotten exception for corrupted database"); } catch (IOException e) {
zkDb2.loadDataBase(); while (zkDb2.getSessionWithTimeOuts().isEmpty() && (System.currentTimeMillis() - start) < 50) { Thread.sleep(1); zkDb2.loadDataBase();
long lastZxid = zkDb2.loadDataBase(); Assert.assertEquals("data1", new String(zkDb2.getData("/foo", stat, null))); Assert.assertEquals(firstZxid, lastZxid); lastZxid = zkDb2.loadDataBase(); Assert.assertEquals("data2", new String(zkDb2.getData("/foo", stat, null))); Assert.assertEquals(proposalZxid, lastZxid);
long lastZxid = zkDb2.loadDataBase(); Assert.assertEquals("data1", new String(zkDb2.getData("/foo1", stat, null))); lastZxid = zkDb2.loadDataBase(); Assert.assertEquals("data2", new String(zkDb2.getData("/foo1", stat, null))); Assert.assertEquals("data2", new String(zkDb2.getData("/foo2", stat, null)));
@Override public synchronized void start() { try { zkDb.loadDataBase(); } catch(IOException ie) { LOG.fatal("Unable to load database on disk", ie); throw new RuntimeException("Unable to run quorum server ", ie); } cnxnFactory.start(); startLeaderElection(); super.start(); }
/** * returns the highest zxid that this host has seen * * @return the highest zxid for this host */ public long getLastLoggedZxid() { long lastLogged= -1L; try { if (!zkDb.isInitialized()) { zkDb.loadDataBase(); } lastLogged = zkDb.getDataTreeLastProcessedZxid(); } catch(IOException ie) { LOG.warn("Unable to load database ", ie); } return lastLogged; }
/** * truncate the zkdatabase to this zxid * @param zxid the zxid to truncate zk database to * @return true if the truncate is succesful and false if not * @throws IOException */ public boolean truncateLog(long zxid) throws IOException { clear(); boolean truncated = this.snapLog.truncateLog(zxid); loadDataBase(); return truncated; }
/** * Restore sessions and data */ public void loadData() throws IOException, InterruptedException { zkDb.loadDataBase(); setZxid(zkDb.loadDataBase()); // Clean up dead sessions LinkedList<Long> deadSessions = new LinkedList<Long>(); for (long session : zkDb.getSessions()) { sessionsWithTimeouts = zkDb.getSessionWithTimeOuts(); if (sessionsWithTimeouts.get(session) == null) { deadSessions.add(session); } } zkDb.setDataTreeInit(true); for (long session : deadSessions) { // XXX: Is lastProcessedZxid really the best thing to use? killSession(session, zkDb.getDataTreeLastProcessedZxid()); } // Make a clean snapshot takeSnapshot(); }
UPDATING_EPOCH_FILENAME); try { zkDb.loadDataBase();