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

x33g5p2x  于2022-02-05 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(136)

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

ZKDatabase.loadDataBase介绍

[英]load the database from the disk onto memory and also add the transactions to the committedlog in memory.
[中]将数据库从磁盘加载到内存中,并将事务添加到内存中的committedlog。

代码示例

代码示例来源:origin: apache/zookeeper

/**
 * 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;
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

/**
 * 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;
}

代码示例来源:origin: apache/zookeeper

private void loadDataBase() {
  try {
    zkDb.loadDataBase();

代码示例来源:origin: org.apache.zookeeper/zookeeper

UPDATING_EPOCH_FILENAME);
try {
  zkDb.loadDataBase();

代码示例来源:origin: apache/zookeeper

setZxid(zkDb.loadDataBase());

代码示例来源:origin: org.apache.zookeeper/zookeeper

setZxid(zkDb.loadDataBase());

代码示例来源:origin: apache/zookeeper

try {
  zks.startdata();
  zxid = zks.getZKDatabase().loadDataBase();
  Assert.fail("Should have gotten exception for corrupted database");
} catch (IOException e) {

代码示例来源:origin: apache/zookeeper

zkDb2.loadDataBase();
while (zkDb2.getSessionWithTimeOuts().isEmpty() && (System.currentTimeMillis() - start) < 50) {
  Thread.sleep(1);
  zkDb2.loadDataBase();

代码示例来源:origin: apache/zookeeper

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

代码示例来源:origin: apache/zookeeper

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

代码示例来源:origin: org.apache.hadoop/zookeeper

@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();
}

代码示例来源:origin: org.apache.hadoop/zookeeper

/**
 * 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;
}

代码示例来源:origin: org.apache.hadoop/zookeeper

/**
 * 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;
}

代码示例来源:origin: org.apache.hadoop/zookeeper

/**
 *  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();
}

代码示例来源:origin: jboss-fuse/fabric8

UPDATING_EPOCH_FILENAME);
try {
  zkDb.loadDataBase();

相关文章