本文整理汇总了Java中org.apache.zookeeper.server.quorum.Vote.getId方法的典型用法代码示例。如果您正苦于以下问题:Java Vote.getId方法的具体用法?Java Vote.getId怎么用?Java Vote.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.server.quorum.Vote
的用法示例。
在下文中一共展示了Vote.getId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: termPredicate
import org.apache.zookeeper.server.quorum.Vote; //导入方法依赖的package包/类
private boolean termPredicate(HashMap<InetSocketAddress, Vote> votes,
long l, long zxid) {
Collection<Vote> votesCast = votes.values();
int count = 0;
/*
* First make the views consistent. Sometimes peers will have different
* zxids for a server depending on timing.
*/
for (Vote v : votesCast) {
if ((v.getId() == l) && (v.getZxid() == zxid))
count++;
}
if (count > (self.getVotingView().size() / 2))
return true;
else
return false;
}
示例2: termPredicate
import org.apache.zookeeper.server.quorum.Vote; //导入方法依赖的package包/类
private boolean termPredicate(Map<InetSocketAddress, Vote> votes,
long l, long zxid) {
Collection<Vote> votesCast = votes.values();
int count = 0;
/*
* First make the views consistent. Sometimes peers will have different
* zxids for a server depending on timing.
*/
for (Vote v : votesCast) {
if ((v.getId() == l) && (v.getZxid() == zxid))
count++;
}
if (count > (self.getVotingView().size() / 2))
return true;
else
return false;
}
示例3: run
import org.apache.zookeeper.server.quorum.Vote; //导入方法依赖的package包/类
public void run() {
try {
Vote v = null;
while(true) {
v = le.lookForLeader();
votes[i] = v;
if (v.getId() == i) {
synchronized(LETest.this) {
if (leaderDies) {
leaderDies = false;
peer.stopLeaderElection();
LOG.info("Leader " + i + " dying");
leader = -2;
} else {
leader = i;
}
LETest.this.notifyAll();
}
break;
}
synchronized(LETest.this) {
if (leader == -1) {
LETest.this.wait();
}
if (leader == v.getId()) {
break;
}
}
Thread.sleep(rand.nextInt(1000));
peer.setCurrentVote(new Vote(peer.getId(), 0));
}
LOG.info("Thread " + i + " votes " + v);
} catch (InterruptedException e) {
e.printStackTrace();
}
}