当前位置: 首页>>代码示例>>Java>>正文


Java Vote.getId方法代码示例

本文整理汇总了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;

}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:22,代码来源:AuthFastLeaderElection.java

示例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;

}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:22,代码来源:AuthFastLeaderElection.java

示例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();
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:37,代码来源:LETest.java


注:本文中的org.apache.zookeeper.server.quorum.Vote.getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。