org.apache.zookeeper.server.util.ZxidUtils类的使用及代码示例

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

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

ZxidUtils介绍

暂无

代码示例

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

long epochOfZxid = ZxidUtils.getEpochFromZxid(lastProcessedZxid);
try {
  currentEpoch = readLongFromFile(CURRENT_EPOCH_FILENAME);
  throw new IOException("The current epoch, " + ZxidUtils.zxidToString(currentEpoch) + ", is older than the last zxid, " + lastProcessedZxid);
  throw new IOException("The accepted epoch, " + ZxidUtils.zxidToString(acceptedEpoch) + " is less than the current epoch, " + ZxidUtils.zxidToString(currentEpoch));

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

long getZxid(long epoch, long counter){
  return ZxidUtils.makeZxid(epoch, counter);
}

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

long txnEpoch = ZxidUtils.getEpochFromZxid(txnZxid);
long txnCounter = ZxidUtils.getCounterFromZxid(txnZxid);
long previousEpoch = ZxidUtils.getEpochFromZxid(previousZxid);
if (txnEpoch == previousEpoch) {
  System.out.println(

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

QuorumPacket qp = new QuorumPacket();                
qp.setType(pktType);
qp.setZxid(ZxidUtils.makeZxid(self.getAcceptedEpoch(), 0));
final long newEpoch = ZxidUtils.getEpochFromZxid(qp.getZxid());
if (qp.getType() == Leader.LEADERINFO) {
  return ZxidUtils.makeZxid(newEpoch, 0);
} else {
  if (newEpoch > self.getAcceptedEpoch()) {

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

/**
 * Returns the current epoch of the leader.
 *
 * @return
 */
public long getEpoch(){
  return ZxidUtils.getEpochFromZxid(lastProposed);
}

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

QuorumPacket qp = new QuorumPacket();                
qp.setType(pktType);
qp.setZxid(ZxidUtils.makeZxid(self.getAcceptedEpoch(), 0));
final long newEpoch = ZxidUtils.getEpochFromZxid(qp.getZxid());
if (qp.getType() == Leader.LEADERINFO) {
  return ZxidUtils.makeZxid(newEpoch, 0);
} else {
  if (newEpoch > self.getAcceptedEpoch()) {

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

/**
 * Returns the current epoch of the leader.
 * 
 * @return
 */
public long getEpoch(){
  return ZxidUtils.getEpochFromZxid(lastProposed);
}

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

long lastAcceptedEpoch = ZxidUtils.getEpochFromZxid(qp.getZxid());
long zxid = qp.getZxid();
long newEpoch = learnerMaster.getEpochToPropose(this.getSid(), lastAcceptedEpoch);
long newLeaderZxid = ZxidUtils.makeZxid(newEpoch, 0);
  long epoch = ZxidUtils.getEpochFromZxid(zxid);
  ss = new StateSummary(epoch, zxid);

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

long epochOfZxid = ZxidUtils.getEpochFromZxid(lastProcessedZxid);
try {
  currentEpoch = readLongFromFile(CURRENT_EPOCH_FILENAME);
  throw new IOException("The current epoch, " + ZxidUtils.zxidToString(currentEpoch) + ", is older than the last zxid, " + lastProcessedZxid);
  throw new IOException("The accepted epoch, " + ZxidUtils.zxidToString(acceptedEpoch) + " is less than the current epoch, " + ZxidUtils.zxidToString(currentEpoch));

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

@Test
public void testLookingDiffRounds() {
  HashMap<Long, Vote> votes = new HashMap<Long, Vote>();
  votes.put(0L, new Vote(4L, ZxidUtils.makeZxid(1, 1), 1, 1, ServerState.LOOKING));
  votes.put(1L, new Vote(4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.LOOKING));
  votes.put(3L, new Vote(4L, ZxidUtils.makeZxid(2, 1), 3, 2, ServerState.LOOKING));
  votes.put(4L, new Vote(4L, ZxidUtils.makeZxid(2, 1), 3, 2, ServerState.LEADING));
  Assert.assertFalse(fle.getVoteTracker(votes,
      new Vote(4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.LOOKING)).hasAllQuorums());
}

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

if (ZxidUtils.getEpochFromZxid(packetZxid) !=
    ZxidUtils.getEpochFromZxid(peerLastZxid)) {

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

long lastAcceptedEpoch = ZxidUtils.getEpochFromZxid(qp.getZxid());
  long epoch = ZxidUtils.getEpochFromZxid(zxid);
  ss = new StateSummary(epoch, zxid);
  byte ver[] = new byte[4];
  ByteBuffer.wrap(ver).putInt(0x10000);
  QuorumPacket newEpochPacket = new QuorumPacket(Leader.LEADERINFO, ZxidUtils.makeZxid(newEpoch, 0), ver, null);
  oa.writeRecord(newEpochPacket, "packet");
  bufferedOutput.flush();
    ZxidUtils.makeZxid(newEpoch, 0), null, null);
 if (getVersion() < 0x10000) {
  oa.writeRecord(newLeaderQP, "packet");

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

long newEpoch = ZxidUtils.getEpochFromZxid(newEpochZxid);
if (newEpoch < self.getAcceptedEpoch()) {
  LOG.error("Proposed leader epoch " + ZxidUtils.zxidToString(newEpochZxid)
      + " is less than our accepted epoch " + ZxidUtils.zxidToString(self.getAcceptedEpoch()));
  throw new IOException("Error: Epoch of leader is lower");

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

@Test
public void testElectionWIthDifferentVersion() {
  Map<Long, Vote> votes = new HashMap<Long, Vote>();
  votes.put(0L, new Vote(0x1, 4L, ZxidUtils.makeZxid(1, 1), 1, 1, ServerState.FOLLOWING));
  votes.put(1L, new Vote(0x1, 4L, ZxidUtils.makeZxid(1, 1), 1, 1, ServerState.FOLLOWING));
  votes.put(3L, new Vote(4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.FOLLOWING));
  votes.put(4L, new Vote(4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.LEADING));
  Assert.assertTrue(fle.getVoteTracker(votes, 
      new Vote(4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.FOLLOWING)).hasAllQuorums());
}

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

rpeerepoch = ZxidUtils.getEpochFromZxid(rzxid);

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

QuorumPacket ack = new QuorumPacket(Leader.ACK, 0, null, null);
QuorumPacket qp = new QuorumPacket();
long newEpoch = ZxidUtils.getEpochFromZxid(newLeaderZxid);
ack.setZxid(ZxidUtils.makeZxid(newEpoch, 0));
writePacket(ack, true);
sock.setSoTimeout(self.tickTime * self.syncLimit);

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

long newEpoch = ZxidUtils.getEpochFromZxid(newEpochZxid);
if (newEpoch < self.getAcceptedEpoch()) {
  LOG.error("Proposed leader epoch " + ZxidUtils.zxidToString(newEpochZxid)
      + " is less than our accepted epoch " + ZxidUtils.zxidToString(self.getAcceptedEpoch()));
  throw new IOException("Error: Epoch of leader is lower");

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

@Test
public void testIgnoringZxidElectionEpoch() {
  Map<Long, Vote> votes = new HashMap<Long, Vote>();
  votes.put(0L, new Vote(0x1, 4L, ZxidUtils.makeZxid(1, 1), 1, 2, ServerState.FOLLOWING));
  votes.put(1L, new Vote(0x1, 4L, ZxidUtils.makeZxid(1, 2), 1, 2, ServerState.FOLLOWING));
  votes.put(3L, new Vote(0x1, 4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.FOLLOWING));
  votes.put(4L, new Vote(0x1, 4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.LEADING));
  Assert.assertTrue(fle.getVoteTracker(votes, 
      new Vote(4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.FOLLOWING)).hasAllQuorums());
}

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

LOG.info("Backward compatibility mode, server id=" + n.sid);
n.peerEpoch = ZxidUtils.getEpochFromZxid(n.zxid);

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

QuorumPacket ack = new QuorumPacket(Leader.ACK, 0, null, null);
QuorumPacket qp = new QuorumPacket();
long newEpoch = ZxidUtils.getEpochFromZxid(newLeaderZxid);
ack.setZxid(ZxidUtils.makeZxid(newEpoch, 0));
writePacket(ack, true);
sock.setSoTimeout(self.tickTime * self.syncLimit);

相关文章