本文整理了Java中org.apache.zookeeper.server.ZKDatabase.truncateLog()
方法的一些代码示例,展示了ZKDatabase.truncateLog()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKDatabase.truncateLog()
方法的具体详情如下:
包路径:org.apache.zookeeper.server.ZKDatabase
类名称:ZKDatabase
方法名:truncateLog
[英]Truncate the ZKDatabase to the specified zxid
[中]将数据库截断为指定的zxid
代码示例来源:origin: apache/zookeeper
/**
* trunccate the log to get in sync with others
* if in a quorum
* @param zxid the zxid that it needs to get in sync
* with others
* @throws IOException
*/
public void truncateLog(long zxid) throws IOException {
this.zkDb.truncateLog(zxid);
}
代码示例来源:origin: org.apache.zookeeper/zookeeper
/**
* trunccate the log to get in sync with others
* if in a quorum
* @param zxid the zxid that it needs to get in sync
* with others
* @throws IOException
*/
public void truncateLog(long zxid) throws IOException {
this.zkDb.truncateLog(zxid);
}
代码示例来源:origin: apache/zookeeper
@Test
public void testTruncationNullLog() throws Exception {
File tmpdir = ClientBase.createTmpDir();
FileTxnSnapLog snaplog = new FileTxnSnapLog(tmpdir, tmpdir);
ZKDatabase zkdb = new ZKDatabase(snaplog);
for (int i = 1; i <= 100; i++) {
append(zkdb, i);
}
zkdb.close();
File[] logs = snaplog.getDataDir().listFiles();
for(int i = 0; i < logs.length; i++) {
LOG.debug("Deleting: {}", logs[i].getName());
Assert.assertTrue("Failed to delete log file: " + logs[i].getName(), logs[i].delete());
}
try {
zkdb.truncateLog(1);
Assert.assertTrue("Should not get here", false);
}
catch(IOException e) {
Assert.assertTrue("Should have received an IOException", true);
}
catch(NullPointerException npe) {
Assert.fail("This should not throw NPE!");
}
ClientBase.recursiveDelete(tmpdir);
}
代码示例来源:origin: apache/zookeeper
boolean truncated=zk.getZKDatabase().truncateLog(qp.getZxid());
if (!truncated) {
代码示例来源:origin: org.apache.zookeeper/zookeeper
boolean truncated=zk.getZKDatabase().truncateLog(qp.getZxid());
if (!truncated) {
代码示例来源:origin: apache/zookeeper
@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(), false);
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);
}
代码示例来源:origin: org.apache.hadoop/zookeeper
/**
* trunccate the log to get in sync with others
* if in a quorum
* @param zxid the zxid that it needs to get in sync
* with others
* @throws IOException
*/
public void truncateLog(long zxid) throws IOException {
this.zkDb.truncateLog(zxid);
}
代码示例来源:origin: org.apache.hadoop/zookeeper
boolean truncated=zk.getZKDatabase().truncateLog(qp.getZxid());
if (!truncated) {
内容来源于网络,如有侵权,请联系作者删除!