本文整理汇总了Java中org.apache.zookeeper.server.util.ZxidUtils类的典型用法代码示例。如果您正苦于以下问题:Java ZxidUtils类的具体用法?Java ZxidUtils怎么用?Java ZxidUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ZxidUtils类属于org.apache.zookeeper.server.util包,在下文中一共展示了ZxidUtils类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testAbandonBeforeACKEpoch
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
/**
* Tests that when a quorum of followers send LearnerInfo but do not ack the epoch (which is sent
* by the leader upon receipt of LearnerInfo from a quorum), the leader does not start using this epoch
* as it would in the normal case (when a quorum do ack the epoch). This tests ZK-1192
* @throws Exception
*/
@Test
public void testAbandonBeforeACKEpoch() throws Exception {
testLeaderConversation(new LeaderConversation() {
public void converseWithLeader(InputArchive ia, OutputArchive oa, Leader l)
throws IOException, InterruptedException {
/* we test a normal run. everything should work out well. */
LearnerInfo li = new LearnerInfo(1, 0x10000);
byte liBytes[] = new byte[12];
ByteBufferOutputStream.record2ByteBuffer(li,
ByteBuffer.wrap(liBytes));
QuorumPacket qp = new QuorumPacket(Leader.FOLLOWERINFO, 0,
liBytes, null);
oa.writeRecord(qp, null);
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.LEADERINFO, qp.getType());
Assert.assertEquals(ZxidUtils.makeZxid(1, 0), qp.getZxid());
Assert.assertEquals(ByteBuffer.wrap(qp.getData()).getInt(),
0x10000);
Thread.sleep(l.self.getInitLimit()*l.self.getTickTime() + 5000);
// The leader didn't get a quorum of acks - make sure that leader's current epoch is not advanced
Assert.assertEquals(0, l.self.getCurrentEpoch());
}
});
}
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:32,代码来源:Zab1_0Test.java
示例2: addRequestToSyncProcessor
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
private void addRequestToSyncProcessor() {
long zxid = ZxidUtils.makeZxid(3, 7);
TxnHeader hdr = new TxnHeader(1, 1, zxid, 1,
ZooDefs.OpCode.setData);
Record txn = new SetDataTxn("/foo" + zxid, new byte[0], 1);
byte[] buf;
try {
buf = Util.marshallTxnEntry(hdr, txn);
} catch (IOException e) {
LOG.error("IOException while adding request to SyncRequestProcessor", e);
Assert.fail("IOException while adding request to SyncRequestProcessor!");
return;
}
NettyServerCnxnFactory factory = new NettyServerCnxnFactory();
final MockNettyServerCnxn nettyCnxn = new MockNettyServerCnxn(null,
this, factory);
Request req = new Request(nettyCnxn, 1, 1, ZooDefs.OpCode.setData,
ByteBuffer.wrap(buf), null);
req.hdr = hdr;
req.txn = txn;
syncProcessor.processRequest(req);
}
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:23,代码来源:ZooKeeperServerMainTest.java
示例3: testAbandonBeforeACKEpoch
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
/**
* Tests that when a quorum of followers send LearnerInfo but do not ack the epoch (which is sent
* by the leader upon receipt of LearnerInfo from a quorum), the leader does not start using this epoch
* as it would in the normal case (when a quorum do ack the epoch). This tests ZK-1192
* @throws Exception
*/
@Test
public void testAbandonBeforeACKEpoch() throws Exception {
testLeaderConversation(new LeaderConversation() {
public void converseWithLeader(InputArchive ia, OutputArchive oa, Leader l)
throws IOException, InterruptedException {
/* we test a normal run. everything should work out well. */
LearnerInfo li = new LearnerInfo(1, 0x10000, 0);
byte liBytes[] = new byte[20];
ByteBufferOutputStream.record2ByteBuffer(li,
ByteBuffer.wrap(liBytes));
QuorumPacket qp = new QuorumPacket(Leader.FOLLOWERINFO, 0,
liBytes, null);
oa.writeRecord(qp, null);
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.LEADERINFO, qp.getType());
Assert.assertEquals(ZxidUtils.makeZxid(1, 0), qp.getZxid());
Assert.assertEquals(ByteBuffer.wrap(qp.getData()).getInt(),
0x10000);
Thread.sleep(l.self.getInitLimit()*l.self.getTickTime() + 5000);
// The leader didn't get a quorum of acks - make sure that leader's current epoch is not advanced
Assert.assertEquals(0, l.self.getCurrentEpoch());
}
});
}
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:32,代码来源:Zab1_0Test.java
示例4: testDontCare
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testDontCare() {
MockFLE fle = new MockFLE(peer, new QuorumCnxManager(peer));
HashMap<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.termPredicate(votes,
new Vote(4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.FOLLOWING)));
}
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:14,代码来源:FLEDontCareTest.java
示例5: testDontCareVersion
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testDontCareVersion() {
MockFLE fle = new MockFLE(peer, new QuorumCnxManager(peer));
HashMap<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.termPredicate(votes,
new Vote(4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.FOLLOWING)));
}
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:14,代码来源:FLEDontCareTest.java
示例6: testLookingNormal
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testLookingNormal() {
MockFLE fle = new MockFLE(peer, new QuorumCnxManager(peer));
HashMap<Long, Vote> votes = new HashMap<Long, Vote>();
votes.put(0L, new Vote(4L, ZxidUtils.makeZxid(2, 1), 1, 1, ServerState.LOOKING));
votes.put(1L, new Vote(4L, ZxidUtils.makeZxid(2, 1), 1, 1, ServerState.LOOKING));
votes.put(3L, new Vote(4L, ZxidUtils.makeZxid(2, 1), 1, 1, ServerState.LOOKING));
votes.put(4L, new Vote(4L, ZxidUtils.makeZxid(2, 1), 1, 1, ServerState.LEADING));
Assert.assertTrue(fle.termPredicate(votes,
new Vote(4L, ZxidUtils.makeZxid(2, 1), 1, 1, ServerState.LOOKING)));
}
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:14,代码来源:FLEDontCareTest.java
示例7: testLookingDiffRounds
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testLookingDiffRounds() {
MockFLE fle = new MockFLE(peer, new QuorumCnxManager(peer));
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.termPredicate(votes,
new Vote(4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.LOOKING)));
}
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:14,代码来源:FLEDontCareTest.java
示例8: testUnnecessarySnap
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testUnnecessarySnap() throws Exception {
testPopulatedLeaderConversation(new PopulatedLeaderConversation() {
@Override
public void converseWithLeader(InputArchive ia, OutputArchive oa,
Leader l, long zxid) throws Exception {
Assert.assertEquals(1, l.self.getAcceptedEpoch());
Assert.assertEquals(1, l.self.getCurrentEpoch());
/* we test a normal run. everything should work out well. */
LearnerInfo li = new LearnerInfo(1, 0x10000);
byte liBytes[] = new byte[12];
ByteBufferOutputStream.record2ByteBuffer(li,
ByteBuffer.wrap(liBytes));
QuorumPacket qp = new QuorumPacket(Leader.FOLLOWERINFO, 1,
liBytes, null);
oa.writeRecord(qp, null);
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.LEADERINFO, qp.getType());
Assert.assertEquals(ZxidUtils.makeZxid(2, 0), qp.getZxid());
Assert.assertEquals(ByteBuffer.wrap(qp.getData()).getInt(),
0x10000);
Assert.assertEquals(2, l.self.getAcceptedEpoch());
Assert.assertEquals(1, l.self.getCurrentEpoch());
byte epochBytes[] = new byte[4];
final ByteBuffer wrappedEpochBytes = ByteBuffer.wrap(epochBytes);
wrappedEpochBytes.putInt(1);
qp = new QuorumPacket(Leader.ACKEPOCH, zxid, epochBytes, null);
oa.writeRecord(qp, null);
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.DIFF, qp.getType());
}
}, 2);
}
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:40,代码来源:Zab1_0Test.java
示例9: testLeaderBehind
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testLeaderBehind() throws Exception {
testLeaderConversation(new LeaderConversation() {
public void converseWithLeader(InputArchive ia, OutputArchive oa, Leader l)
throws IOException {
/* we test a normal run. everything should work out well. */
LearnerInfo li = new LearnerInfo(1, 0x10000);
byte liBytes[] = new byte[12];
ByteBufferOutputStream.record2ByteBuffer(li,
ByteBuffer.wrap(liBytes));
/* we are going to say we last acked epoch 20 */
QuorumPacket qp = new QuorumPacket(Leader.FOLLOWERINFO, ZxidUtils.makeZxid(20, 0),
liBytes, null);
oa.writeRecord(qp, null);
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.LEADERINFO, qp.getType());
Assert.assertEquals(ZxidUtils.makeZxid(21, 0), qp.getZxid());
Assert.assertEquals(ByteBuffer.wrap(qp.getData()).getInt(),
0x10000);
qp = new QuorumPacket(Leader.ACKEPOCH, 0, new byte[4], null);
oa.writeRecord(qp, null);
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.DIFF, qp.getType());
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.NEWLEADER, qp.getType());
Assert.assertEquals(ZxidUtils.makeZxid(21, 0), qp.getZxid());
qp = new QuorumPacket(Leader.ACK, qp.getZxid(), null, null);
oa.writeRecord(qp, null);
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.UPTODATE, qp.getType());
}
});
}
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:36,代码来源:Zab1_0Test.java
示例10: testInitialAcceptedCurrent
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testInitialAcceptedCurrent() throws Exception {
File tmpDir = File.createTempFile("test", ".dir", testData);
tmpDir.delete();
tmpDir.mkdir();
try {
FileTxnSnapLog logFactory = new FileTxnSnapLog(tmpDir, tmpDir);
File version2 = new File(tmpDir, "version-2");
version2.mkdir();
long zxid = ZxidUtils.makeZxid(3, 3);
TxnHeader hdr = new TxnHeader(1, 1, zxid, 1, ZooDefs.OpCode.error);
ErrorTxn txn = new ErrorTxn(1);
byte[] buf = Util.marshallTxnEntry(hdr, txn);
Request req = new Request(null, 1, 1, ZooDefs.OpCode.error,
ByteBuffer.wrap(buf), null);
req.hdr = hdr;
req.txn = txn;
logFactory.append(req);
logFactory.commit();
ZKDatabase zkDb = new ZKDatabase(logFactory);
QuorumPeer peer = new QuorumPeer();
peer.setZKDatabase(zkDb);
peer.setTxnFactory(logFactory);
peer.getLastLoggedZxid();
Assert.assertEquals(3, peer.getAcceptedEpoch());
Assert.assertEquals(3, peer.getCurrentEpoch());
Assert.assertEquals(3, Integer
.parseInt(readContentsOfFile(new File(version2,
QuorumPeer.CURRENT_EPOCH_FILENAME))));
Assert.assertEquals(3, Integer
.parseInt(readContentsOfFile(new File(version2,
QuorumPeer.ACCEPTED_EPOCH_FILENAME))));
} finally {
recursiveDelete(tmpDir);
}
}
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:38,代码来源:Zab1_0Test.java
示例11: testUnnecessarySnap
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testUnnecessarySnap() throws Exception {
testPopulatedLeaderConversation(new PopulatedLeaderConversation() {
@Override
public void converseWithLeader(InputArchive ia, OutputArchive oa,
Leader l, long zxid) throws Exception {
Assert.assertEquals(1, l.self.getAcceptedEpoch());
Assert.assertEquals(1, l.self.getCurrentEpoch());
/* we test a normal run. everything should work out well. */
LearnerInfo li = new LearnerInfo(1, 0x10000, 0);
byte liBytes[] = new byte[20];
ByteBufferOutputStream.record2ByteBuffer(li,
ByteBuffer.wrap(liBytes));
QuorumPacket qp = new QuorumPacket(Leader.FOLLOWERINFO, 1,
liBytes, null);
oa.writeRecord(qp, null);
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.LEADERINFO, qp.getType());
Assert.assertEquals(ZxidUtils.makeZxid(2, 0), qp.getZxid());
Assert.assertEquals(ByteBuffer.wrap(qp.getData()).getInt(),
0x10000);
Assert.assertEquals(2, l.self.getAcceptedEpoch());
Assert.assertEquals(1, l.self.getCurrentEpoch());
byte epochBytes[] = new byte[4];
final ByteBuffer wrappedEpochBytes = ByteBuffer.wrap(epochBytes);
wrappedEpochBytes.putInt(1);
qp = new QuorumPacket(Leader.ACKEPOCH, zxid, epochBytes, null);
oa.writeRecord(qp, null);
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.DIFF, qp.getType());
}
}, 2);
}
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:40,代码来源:Zab1_0Test.java
示例12: testLeaderBehind
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testLeaderBehind() throws Exception {
testLeaderConversation(new LeaderConversation() {
public void converseWithLeader(InputArchive ia, OutputArchive oa, Leader l)
throws IOException {
/* we test a normal run. everything should work out well. */
LearnerInfo li = new LearnerInfo(1, 0x10000, 0);
byte liBytes[] = new byte[20];
ByteBufferOutputStream.record2ByteBuffer(li,
ByteBuffer.wrap(liBytes));
/* we are going to say we last acked epoch 20 */
QuorumPacket qp = new QuorumPacket(Leader.FOLLOWERINFO, ZxidUtils.makeZxid(20, 0),
liBytes, null);
oa.writeRecord(qp, null);
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.LEADERINFO, qp.getType());
Assert.assertEquals(ZxidUtils.makeZxid(21, 0), qp.getZxid());
Assert.assertEquals(ByteBuffer.wrap(qp.getData()).getInt(),
0x10000);
qp = new QuorumPacket(Leader.ACKEPOCH, 0, new byte[4], null);
oa.writeRecord(qp, null);
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.DIFF, qp.getType());
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.NEWLEADER, qp.getType());
Assert.assertEquals(ZxidUtils.makeZxid(21, 0), qp.getZxid());
qp = new QuorumPacket(Leader.ACK, qp.getZxid(), null, null);
oa.writeRecord(qp, null);
readPacketSkippingPing(ia, qp);
Assert.assertEquals(Leader.UPTODATE, qp.getType());
}
});
}
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:36,代码来源:Zab1_0Test.java
示例13: testInitialAcceptedCurrent
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testInitialAcceptedCurrent() throws Exception {
File tmpDir = File.createTempFile("test", ".dir", testData);
tmpDir.delete();
tmpDir.mkdir();
try {
FileTxnSnapLog logFactory = new FileTxnSnapLog(tmpDir, tmpDir);
File version2 = new File(tmpDir, "version-2");
version2.mkdir();
logFactory.save(new DataTree(), new ConcurrentHashMap<Long, Integer>(), false);
long zxid = ZxidUtils.makeZxid(3, 3);
logFactory.append(new Request(1, 1, ZooDefs.OpCode.error,
new TxnHeader(1, 1, zxid, 1, ZooDefs.OpCode.error),
new ErrorTxn(1), zxid));
logFactory.commit();
ZKDatabase zkDb = new ZKDatabase(logFactory);
QuorumPeer peer = new QuorumPeer();
peer.setZKDatabase(zkDb);
peer.setTxnFactory(logFactory);
peer.getLastLoggedZxid();
Assert.assertEquals(3, peer.getAcceptedEpoch());
Assert.assertEquals(3, peer.getCurrentEpoch());
Assert.assertEquals(3, Integer
.parseInt(readContentsOfFile(new File(version2,
QuorumPeer.CURRENT_EPOCH_FILENAME))));
Assert.assertEquals(3, Integer
.parseInt(readContentsOfFile(new File(version2,
QuorumPeer.ACCEPTED_EPOCH_FILENAME))));
} finally {
TestUtils.deleteFileRecursively(tmpDir);
}
}
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:33,代码来源:Zab1_0Test.java
示例14: testDontCare
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testDontCare() {
MockFLE fle = new MockFLE(peer, peer.createCnxnManager());
HashMap<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.termPredicate(votes,
new Vote(4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.FOLLOWING)));
}
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:14,代码来源:FLEDontCareTest.java
示例15: testDontCareVersion
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testDontCareVersion() {
MockFLE fle = new MockFLE(peer, peer.createCnxnManager());
HashMap<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.termPredicate(votes,
new Vote(4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.FOLLOWING)));
}
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:14,代码来源:FLEDontCareTest.java
示例16: testLookingNormal
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testLookingNormal() {
MockFLE fle = new MockFLE(peer, peer.createCnxnManager());
HashMap<Long, Vote> votes = new HashMap<Long, Vote>();
votes.put(0L, new Vote(4L, ZxidUtils.makeZxid(2, 1), 1, 1, ServerState.LOOKING));
votes.put(1L, new Vote(4L, ZxidUtils.makeZxid(2, 1), 1, 1, ServerState.LOOKING));
votes.put(3L, new Vote(4L, ZxidUtils.makeZxid(2, 1), 1, 1, ServerState.LOOKING));
votes.put(4L, new Vote(4L, ZxidUtils.makeZxid(2, 1), 1, 1, ServerState.LEADING));
Assert.assertTrue(fle.termPredicate(votes,
new Vote(4L, ZxidUtils.makeZxid(2, 1), 1, 1, ServerState.LOOKING)));
}
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:14,代码来源:FLEDontCareTest.java
示例17: testLookingDiffRounds
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testLookingDiffRounds() {
MockFLE fle = new MockFLE(peer, peer.createCnxnManager());
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.termPredicate(votes,
new Vote(4L, ZxidUtils.makeZxid(2, 1), 2, 2, ServerState.LOOKING)));
}
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:14,代码来源:FLEDontCareTest.java
示例18: testInitialAcceptedCurrent
import org.apache.zookeeper.server.util.ZxidUtils; //导入依赖的package包/类
@Test
public void testInitialAcceptedCurrent() throws Exception {
File tmpDir = File.createTempFile("test", ".dir", testData);
tmpDir.delete();
tmpDir.mkdir();
try {
FileTxnSnapLog logFactory = new FileTxnSnapLog(tmpDir, tmpDir);
File version2 = new File(tmpDir, "version-2");
version2.mkdir();
long zxid = ZxidUtils.makeZxid(3, 3);
TxnHeader hdr = new TxnHeader(1, 1, zxid, 1, ZooDefs.OpCode.error);
ErrorTxn txn = new ErrorTxn(1);
byte[] buf = Util.marshallTxnEntry(hdr, txn);
Request req = new Request(null, 1, 1, ZooDefs.OpCode.error,
ByteBuffer.wrap(buf), null);
req.hdr = hdr;
req.txn = txn;
logFactory.append(req);
logFactory.commit();
ZKDatabase zkDb = new ZKDatabase(logFactory);
QuorumPeer peer = QuorumPeer.testingQuorumPeer();
peer.setZKDatabase(zkDb);
peer.setTxnFactory(logFactory);
peer.getLastLoggedZxid();
Assert.assertEquals(3, peer.getAcceptedEpoch());
Assert.assertEquals(3, peer.getCurrentEpoch());
Assert.assertEquals(3, Integer
.parseInt(readContentsOfFile(new File(version2,
QuorumPeer.CURRENT_EPOCH_FILENAME))));
Assert.assertEquals(3, Integer
.parseInt(readContentsOfFile(new File(version2,
QuorumPeer.ACCEPTED_EPOCH_FILENAME))));
} finally {
recursiveDelete(tmpDir);
}
}
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:38,代码来源:Zab1_0Test.java
注:本文中的org.apache.zookeeper.server.util.ZxidUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论