org.apache.zookeeper.server.quorum.flexible.QuorumVerifier.getWeight()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(94)

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

QuorumVerifier.getWeight介绍

暂无

代码示例

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

/**
 * Check if a pair (server id, zxid) succeeds our
 * current vote.
 *
 * @param id    Server identifier
 * @param zxid  Last zxid observed by the issuer of this vote
 */
protected boolean totalOrderPredicate(long newId, long newZxid, long newEpoch, long curId, long curZxid, long curEpoch) {
  LOG.debug("id: " + newId + ", proposed id: " + curId + ", zxid: 0x" +
      Long.toHexString(newZxid) + ", proposed zxid: 0x" + Long.toHexString(curZxid));
  if(self.getQuorumVerifier().getWeight(newId) == 0){
    return false;
  }
  /*
   * We return true if one of the following three cases hold:
   * 1- New epoch is higher
   * 2- New epoch is the same as current epoch, but new zxid is higher
   * 3- New epoch is the same as current epoch, new zxid is the same
   *  as current zxid, but server id is higher.
   */
  return ((newEpoch > curEpoch) ||
      ((newEpoch == curEpoch) &&
      ((newZxid > curZxid) || ((newZxid == curZxid) && (newId > curId)))));
}

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

/**
 * Check if a pair (server id, zxid) succeeds our
 * current vote.
 *
 * @param id    Server identifier
 * @param zxid  Last zxid observed by the issuer of this vote
 */
protected boolean totalOrderPredicate(long newId, long newZxid, long newEpoch, long curId, long curZxid, long curEpoch) {
  LOG.debug("id: " + newId + ", proposed id: " + curId + ", zxid: 0x" +
      Long.toHexString(newZxid) + ", proposed zxid: 0x" + Long.toHexString(curZxid));
  if(self.getQuorumVerifier().getWeight(newId) == 0){
    return false;
  }
  
  /*
   * We return true if one of the following three cases hold:
   * 1- New epoch is higher
   * 2- New epoch is the same as current epoch, but new zxid is higher
   * 3- New epoch is the same as current epoch, new zxid is the same
   *  as current zxid, but server id is higher.
   */
  
  return ((newEpoch > curEpoch) || 
      ((newEpoch == curEpoch) &&
      ((newZxid > curZxid) || ((newZxid == curZxid) && (newId > curId)))));
}

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

/**
 * Check if a pair (server id, zxid) succeeds our
 * current vote.
 * 
 * @param id    Server identifier
 * @param zxid  Last zxid observed by the issuer of this vote
 */
private boolean totalOrderPredicate(long newId, long newZxid, long curId, long curZxid) {
  LOG.debug("id: " + newId + ", proposed id: " + curId + ", zxid: " + newZxid + ", proposed zxid: " + curZxid);
  if(self.getQuorumVerifier().getWeight(newId) == 0){
    return false;
  }
  
  if ((newZxid > curZxid)
      || ((newZxid == curZxid) && (newId > curId)))
    return true;
  else
    return false;
}

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

(self.getQuorumVerifier().getWeight(proposedLeader) != 0)){
self.setPeerState((proposedLeader == self.getId()) ? 
    ServerState.LEADING: learningState());

相关文章