gpt4 book ai didi

org.apache.zookeeper.server.ZKDatabase.truncateLog()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 09:04:40 28 4
gpt4 key购买 nike

本文整理了Java中org.apache.zookeeper.server.ZKDatabase.truncateLog()方法的一些代码示例,展示了ZKDatabase.truncateLog()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKDatabase.truncateLog()方法的具体详情如下:
包路径:org.apache.zookeeper.server.ZKDatabase
类名称:ZKDatabase
方法名:truncateLog

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) {

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com