本文整理汇总了Java中org.apache.zookeeper.server.quorum.FastLeaderElection.Notification方法的典型用法代码示例。如果您正苦于以下问题:Java FastLeaderElection.Notification方法的具体用法?Java FastLeaderElection.Notification怎么用?Java FastLeaderElection.Notification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.server.quorum.FastLeaderElection
的用法示例。
在下文中一共展示了FastLeaderElection.Notification方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: genNotification
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入方法依赖的package包/类
/**
* Helper method to build notifications and populate outofelection.
*
*
* @param version
* @param leader
* @param zxid
* @param electionEpoch
* @param state
* @param sid
* @param peerEpoch
* @param outofelection
* @return
*/
FastLeaderElection.Notification genNotification(int version,
long leader,
long zxid,
long electionEpoch,
ServerState state,
long sid,
long peerEpoch,
HashMap<Long,Vote> outofelection) {
FastLeaderElection.Notification n = new FastLeaderElection.Notification();
n.version = version;
n.leader = leader;
n.zxid = zxid;
n.electionEpoch = electionEpoch;
n.state = state;
n.sid = sid;
n.peerEpoch = peerEpoch;
outofelection.put(n.sid, new Vote(n.version,
n.leader,
n.zxid,
n.electionEpoch,
n.peerEpoch,
n.state));
return n;
}
示例2: ooePredicate
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入方法依赖的package包/类
public boolean ooePredicate(HashMap<Long,Vote> recv,
HashMap<Long,Vote> ooe,
FastLeaderElection.Notification n) {
return super.ooePredicate(recv, ooe, n);
}
示例3: testOutofElection
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入方法依赖的package包/类
@Test
public void testOutofElection() {
MockFLE fle = new MockFLE(peer, new QuorumCnxManager(peer));
HashMap<Long,Vote> outofelection = new HashMap<Long,Vote>();
/*
* Generates notifications emulating servers 1, 2, 4, and 5.
* Server 5 is the elected leader.
*/
genNotification( 0x0,
5,
ZxidUtils.makeZxid(15, 0),
0xa,
ServerState.FOLLOWING,
1,
0x17,
outofelection);
genNotification( 0x0,
5,
ZxidUtils.makeZxid(15, 0),
0xa,
ServerState.FOLLOWING,
2,
0x17,
outofelection);
genNotification( 0x1,
5,
ZxidUtils.makeZxid(15, 0),
0xa,
ServerState.FOLLOWING,
4,
0x18,
outofelection);
FastLeaderElection.Notification n = genNotification( 0x1,
5,
ZxidUtils.makeZxid(15, 0),
0xa,
ServerState.LEADING,
5,
0x18,
outofelection);
/*
* fle represents the FLE instance of server 3.Here we set
* its logical clock to 1.
*/
fle.logicalclock = 0x1;
/*
* Here we test the predicates we use in FLE.
*/
Assert.assertTrue("Termination predicate failed",
fle.termPredicate(outofelection,
new Vote(n.version,
n.leader,
n.zxid,
n.electionEpoch,
n.peerEpoch,
n.state)));
Assert.assertTrue("Leader check failed",
fle.checkLeader(outofelection,
n.leader,
n.electionEpoch));
Assert.assertTrue("Out of election predicate failed",
fle.ooePredicate( outofelection, outofelection, n ));
}
示例4: testOutofElection
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入方法依赖的package包/类
@Test
public void testOutofElection() {
MockFLE fle = new MockFLE(peer, peer.createCnxnManager());
HashMap<Long,Vote> outofelection = new HashMap<Long,Vote>();
/*
* Generates notifications emulating servers 1, 2, 4, and 5.
* Server 5 is the elected leader.
*/
genNotification( 0x0,
5,
ZxidUtils.makeZxid(15, 0),
0xa,
ServerState.FOLLOWING,
1,
0x17,
outofelection);
genNotification( 0x0,
5,
ZxidUtils.makeZxid(15, 0),
0xa,
ServerState.FOLLOWING,
2,
0x17,
outofelection);
genNotification( 0x1,
5,
ZxidUtils.makeZxid(15, 0),
0xa,
ServerState.FOLLOWING,
4,
0x18,
outofelection);
FastLeaderElection.Notification n = genNotification( 0x1,
5,
ZxidUtils.makeZxid(15, 0),
0xa,
ServerState.LEADING,
5,
0x18,
outofelection);
/*
* fle represents the FLE instance of server 3.Here we set
* its logical clock to 1.
*/
fle.logicalclock = 0x1;
/*
* Here we test the predicates we use in FLE.
*/
Assert.assertTrue("Termination predicate failed",
fle.termPredicate(outofelection,
new Vote(n.version,
n.leader,
n.zxid,
n.electionEpoch,
n.peerEpoch,
n.state)));
Assert.assertTrue("Leader check failed",
fle.checkLeader(outofelection,
n.leader,
n.electionEpoch));
Assert.assertTrue("Out of election predicate failed",
fle.ooePredicate( outofelection, outofelection, n ));
}