use of org.apache.zookeeper.server.persistence.FileTxnLog in project zookeeper by apache.
the class ZooKeeperServerTest method testForceSyncDefaultEnabled.
@Test
public void testForceSyncDefaultEnabled() {
File file = new File("foo.10027c6de");
FileTxnLog log = new FileTxnLog(file);
Assert.assertTrue(log.isForceSync());
}
use of org.apache.zookeeper.server.persistence.FileTxnLog in project zookeeper by apache.
the class TruncateTest method testTruncationStreamReset.
@Test
public void testTruncationStreamReset() throws Exception {
File tmpdir = ClientBase.createTmpDir();
FileTxnSnapLog snaplog = new FileTxnSnapLog(tmpdir, tmpdir);
ZKDatabase zkdb = new ZKDatabase(snaplog);
// make sure to snapshot, so that we have something there when
// truncateLog reloads the db
snaplog.save(zkdb.getDataTree(), zkdb.getSessionWithTimeOuts());
for (int i = 1; i <= 100; i++) {
append(zkdb, i);
}
zkdb.truncateLog(1);
append(zkdb, 200);
zkdb.close();
// verify that the truncation and subsequent append were processed
// correctly
FileTxnLog txnlog = new FileTxnLog(new File(tmpdir, "version-2"));
TxnIterator iter = txnlog.read(1);
TxnHeader hdr = iter.getHeader();
Record txn = iter.getTxn();
Assert.assertEquals(1, hdr.getZxid());
Assert.assertTrue(txn instanceof SetDataTxn);
iter.next();
hdr = iter.getHeader();
txn = iter.getTxn();
Assert.assertEquals(200, hdr.getZxid());
Assert.assertTrue(txn instanceof SetDataTxn);
iter.close();
ClientBase.recursiveDelete(tmpdir);
}
Aggregations