• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ToSend类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.zookeeper.server.quorum.FastLeaderElection.ToSend的典型用法代码示例。如果您正苦于以下问题:Java ToSend类的具体用法?Java ToSend怎么用?Java ToSend使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ToSend类属于org.apache.zookeeper.server.quorum.FastLeaderElection包,在下文中一共展示了ToSend类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testBackwardCompatibility

点赞 2

import org.apache.zookeeper.server.quorum.FastLeaderElection.ToSend; //导入依赖的package包/类
@Test(timeout=20000)
public void testBackwardCompatibility() 
throws Exception {
    populate();
    
    QuorumPeer peer = new QuorumPeer(peers, tmpdir[0], tmpdir[0], port[0], 3, 0, 1000, 2, 2);
    peer.setPeerState(ServerState.LOOKING);
    QuorumCnxManager mng = new QuorumCnxManager(peer);
    
    /*
     * Check that it generates an internal notification correctly
     */
    MockFLEMessengerBackward fle = new MockFLEMessengerBackward(peer, mng);
    ByteBuffer buffer = FastLeaderElection.buildMsg(ServerState.LOOKING.ordinal(), 2, 0x1, 1, 1);
    fle.manager.recvQueue.add(new Message(buffer, 2));
    Notification n = fle.recvqueue.take();
    Assert.assertTrue("Wrong state", n.state == ServerState.LOOKING);
    Assert.assertTrue("Wrong leader", n.leader == 2);
    Assert.assertTrue("Wrong zxid", n.zxid == 0x1);
    Assert.assertTrue("Wrong epoch", n.electionEpoch == 1);
    Assert.assertTrue("Wrong epoch", n.peerEpoch == 1);
    
    /*
     * Check that it sends a notification back to the sender
     */
    peer.setPeerState(ServerState.FOLLOWING);
    peer.setCurrentVote( new Vote(2, 0x1, 1, 1, ServerState.LOOKING) );
    buffer = FastLeaderElection.buildMsg(ServerState.LOOKING.ordinal(), 1, 0x1, 1, 1);
    fle.manager.recvQueue.add(new Message(buffer, 1));
    ToSend m = fle.internalqueue.take();
    Assert.assertTrue("Wrong state", m.state == ServerState.FOLLOWING);
    Assert.assertTrue("Wrong sid", m.sid == 1);
    Assert.assertTrue("Wrong leader", m.leader == 2);
    Assert.assertTrue("Wrong epoch", m.electionEpoch == 1);
    Assert.assertTrue("Wrong epoch", m.peerEpoch == 1);
}
 

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

示例2: testBackwardCompatibility

点赞 2

import org.apache.zookeeper.server.quorum.FastLeaderElection.ToSend; //导入依赖的package包/类
@Test(timeout=20000)
public void testBackwardCompatibility() 
throws Exception {
    populate();
    
    QuorumPeer peer = new QuorumPeer(peers, tmpdir[0], tmpdir[0], port[0], 3, 0, 1000, 2, 2);
    peer.setPeerState(ServerState.LOOKING);
    QuorumCnxManager mng = peer.createCnxnManager();
    
    /*
     * Check that it generates an internal notification correctly
     */
    MockFLEMessengerBackward fle = new MockFLEMessengerBackward(peer, mng);
    ByteBuffer buffer = FastLeaderElection.buildMsg(ServerState.LOOKING.ordinal(), 2, 0x1, 1, 1);
    fle.manager.recvQueue.add(new Message(buffer, 2));
    Notification n = fle.recvqueue.take();
    Assert.assertTrue("Wrong state", n.state == ServerState.LOOKING);
    Assert.assertTrue("Wrong leader", n.leader == 2);
    Assert.assertTrue("Wrong zxid", n.zxid == 0x1);
    Assert.assertTrue("Wrong epoch", n.electionEpoch == 1);
    Assert.assertTrue("Wrong epoch", n.peerEpoch == 1);
    
    /*
     * Check that it sends a notification back to the sender
     */
    peer.setPeerState(ServerState.FOLLOWING);
    peer.setCurrentVote( new Vote(2, 0x1, 1, 1, ServerState.LOOKING) );
    buffer = FastLeaderElection.buildMsg(ServerState.LOOKING.ordinal(), 1, 0x1, 1, 1);
    fle.manager.recvQueue.add(new Message(buffer, 1));
    ToSend m = fle.internalqueue.take();
    Assert.assertTrue("Wrong state", m.state == ServerState.FOLLOWING);
    Assert.assertTrue("Wrong sid", m.sid == 1);
    Assert.assertTrue("Wrong leader", m.leader == 2);
    Assert.assertTrue("Wrong epoch", m.electionEpoch == 1);
    Assert.assertTrue("Wrong epoch", m.peerEpoch == 1);
}
 

开发者ID:l294265421,
项目名称:ZooKeeper,
代码行数:37,
代码来源:FLECompatibilityTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)