本文整理汇总了Java中org.apache.zookeeper.server.ZKDatabase.getDataTreeLastProcessedZxid方法的典型用法代码示例。如果您正苦于以下问题:Java ZKDatabase.getDataTreeLastProcessedZxid方法的具体用法?Java ZKDatabase.getDataTreeLastProcessedZxid怎么用?Java ZKDatabase.getDataTreeLastProcessedZxid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.server.ZKDatabase
的用法示例。
在下文中一共展示了ZKDatabase.getDataTreeLastProcessedZxid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitForSync
import org.apache.zookeeper.server.ZKDatabase; //导入方法依赖的package包/类
/**
* Wait for all server to have the same lastProccessedZxid. Timeout in seconds
*/
private boolean waitForSync(QuorumUtil qu, int index, int timeout) throws InterruptedException{
LOG.info("Wait for server to sync");
int leaderIndex = (index == 1) ? 2 : 1;
ZKDatabase restartedDb = qu.getPeer(index).peer.getActiveServer().getZKDatabase();
ZKDatabase cleanDb = qu.getPeer(3).peer.getActiveServer().getZKDatabase();
ZKDatabase leadDb = qu.getPeer(leaderIndex).peer.getActiveServer().getZKDatabase();
long leadZxid = 0;
long cleanZxid = 0;
long restartedZxid = 0;
for (int i = 0; i < timeout; ++i) {
leadZxid = leadDb.getDataTreeLastProcessedZxid();
cleanZxid = cleanDb.getDataTreeLastProcessedZxid();
restartedZxid = restartedDb.getDataTreeLastProcessedZxid();
if (leadZxid == cleanZxid && leadZxid == restartedZxid) {
return true;
}
Thread.sleep(1000);
}
LOG.info("Timeout waiting for zxid to sync: leader 0x{}" +
"clean 0x{}" +
"restarted 0x{}", Long.toHexString(leadZxid), Long.toHexString(cleanZxid),
Long.toHexString(restartedZxid));
return false;
}
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:28,代码来源:FollowerResyncConcurrencyTest.java
示例2: waitForSync
import org.apache.zookeeper.server.ZKDatabase; //导入方法依赖的package包/类
/**
* Wait for all server to have the same lastProccessedZxid. Timeout in seconds
*/
private boolean waitForSync(QuorumUtil qu, int index, int timeout) throws InterruptedException{
LOG.info("Wait for server to sync");
int leaderIndex = (index == 1) ? 2 : 1;
ZKDatabase restartedDb = qu.getPeer(index).peer.getActiveServer().getZKDatabase();
ZKDatabase cleanDb = qu.getPeer(3).peer.getActiveServer().getZKDatabase();
ZKDatabase leadDb = qu.getPeer(leaderIndex).peer.getActiveServer().getZKDatabase();
long leadZxid = 0;
long cleanZxid = 0;
long restartedZxid = 0;
for (int i = 0; i < timeout; ++i) {
leadZxid = leadDb.getDataTreeLastProcessedZxid();
cleanZxid = cleanDb.getDataTreeLastProcessedZxid();
restartedZxid = restartedDb.getDataTreeLastProcessedZxid();
if (leadZxid == cleanZxid && leadZxid == restartedZxid) {
return true;
}
Thread.sleep(1000);
}
LOG.info("Timeout waiting for zxid to sync: leader 0x" + Long.toHexString(leadZxid)+
"clean 0x" + Long.toHexString(cleanZxid) +
"restarted 0x" + Long.toHexString(restartedZxid));
return false;
}