当前位置: 首页>>代码示例>>Java>>正文


Java Message类代码示例

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


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

示例1: run

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的package包/类
public void run(){
    try {
        QuorumPeer peer = new QuorumPeer(peers, peerTmpdir[0], peerTmpdir[0], peerClientPort[0], 3, 0, 1000, 2, 2);
        QuorumCnxManager cnxManager = new QuorumCnxManager(peer);
        QuorumCnxManager.Listener listener = cnxManager.listener;
        if(listener != null){
            listener.start();
        } else {
            LOG.error("Null listener when initializing cnx manager");
        }

        long sid = 1;
        cnxManager.toSend(sid, createMsg(ServerState.LOOKING.ordinal(), 0, -1, 1));

        Message m = null;
        int numRetries = 1;
        while((m == null) && (numRetries++ <= THRESHOLD)){
            m = cnxManager.pollRecvQueue(3000, TimeUnit.MILLISECONDS);
            if(m == null) cnxManager.connectAll();
        }

        if(numRetries > THRESHOLD){
            failed = true;
            return;
        }

        cnxManager.testInitiateConnection(sid);

        m = cnxManager.pollRecvQueue(3000, TimeUnit.MILLISECONDS);
        if(m == null){
            failed = true;
            return;
        }
    } catch (Exception e) {
        LOG.error("Exception while running mock thread", e);
        Assert.fail("Unexpected exception");
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:39,代码来源:CnxManagerTest.java

示例2: testCnxManager

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的package包/类
@Test
public void testCnxManager() throws Exception {
    CnxManagerThread thread = new CnxManagerThread();

    thread.start();
    
    QuorumPeer peer = new QuorumPeer(peers, peerTmpdir[1], peerTmpdir[1], peerClientPort[1], 3, 1, 1000, 2, 2);
    QuorumCnxManager cnxManager = new QuorumCnxManager(peer);
    QuorumCnxManager.Listener listener = cnxManager.listener;
    if(listener != null){
        listener.start();
    } else {
        LOG.error("Null listener when initializing cnx manager");
    }

    cnxManager.toSend(new Long(0), createMsg(ServerState.LOOKING.ordinal(), 1, -1, 1));

    Message m = null;
    int numRetries = 1;
    while((m == null) && (numRetries++ <= THRESHOLD)){
        m = cnxManager.pollRecvQueue(3000, TimeUnit.MILLISECONDS);
        if(m == null) cnxManager.connectAll();
    }
    
    Assert.assertTrue("Exceeded number of retries", numRetries <= THRESHOLD);

    thread.join(5000);
    if (thread.isAlive()) {
        Assert.fail("Thread didn't join");
    } else {
        if(thread.failed)
            Assert.fail("Did not receive expected message");
    }
    
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:36,代码来源:CnxManagerTest.java

示例3: testBackwardCompatibility

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的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

示例4: testForwardCompatibility

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的package包/类
@Test(timeout=20000)
public void testForwardCompatibility() 
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
     */
    MockFLEMessengerForward fle = new MockFLEMessengerForward(peer, mng);
    ByteBuffer notBuffer = FastLeaderElection.buildMsg(ServerState.LOOKING.ordinal(), 2, 0x1, 1, 1);
    ByteBuffer buffer = ByteBuffer.allocate( notBuffer.capacity() + 8 );
    notBuffer.flip();
    buffer.put(notBuffer);
    buffer.putLong( Long.MAX_VALUE );
    buffer.flip();
    
    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);
    Assert.assertTrue("Wrong version", n.version == FastLeaderElection.Notification.CURRENTVERSION);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:30,代码来源:FLECompatibilityTest.java

示例5: testCnxManager

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的package包/类
@Test
public void testCnxManager() throws Exception {
    CnxManagerThread thread = new CnxManagerThread();

    thread.start();

    QuorumPeer peer = new QuorumPeer(peers, peerTmpdir[1], peerTmpdir[1], peerClientPort[1], 3, 1, 1000, 2, 2);
    QuorumCnxManager cnxManager = new QuorumCnxManager(peer);
    QuorumCnxManager.Listener listener = cnxManager.listener;
    if(listener != null){
        listener.start();
    } else {
        LOG.error("Null listener when initializing cnx manager");
    }

    cnxManager.toSend(0L, createMsg(ServerState.LOOKING.ordinal(), 1, -1, 1));

    Message m = null;
    int numRetries = 1;
    while((m == null) && (numRetries++ <= THRESHOLD)){
        m = cnxManager.pollRecvQueue(3000, TimeUnit.MILLISECONDS);
        if(m == null) cnxManager.connectAll();
    }

    Assert.assertTrue("Exceeded number of retries", numRetries <= THRESHOLD);

    thread.join(5000);
    if (thread.isAlive()) {
        Assert.fail("Thread didn't join");
    } else {
        if(thread.failed)
            Assert.fail("Did not receive expected message");
    }
    cnxManager.halt();
    Assert.assertFalse(cnxManager.listener.isAlive());
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:37,代码来源:CnxManagerTest.java

示例6: run

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的package包/类
public void run(){
    try {
        QuorumPeer peer = new QuorumPeer(peers, peerTmpdir[0], peerTmpdir[0], peerClientPort[0], 3, 0, 1000, 2, 2);
        QuorumCnxManager cnxManager = peer.createCnxnManager();
        QuorumCnxManager.Listener listener = cnxManager.listener;
        if(listener != null){
            listener.start();
        } else {
            LOG.error("Null listener when initializing cnx manager");
        }

        long sid = 1;
        cnxManager.toSend(sid, createMsg(ServerState.LOOKING.ordinal(), 0, -1, 1));

        Message m = null;
        int numRetries = 1;
        while((m == null) && (numRetries++ <= THRESHOLD)){
            m = cnxManager.pollRecvQueue(3000, TimeUnit.MILLISECONDS);
            if(m == null) cnxManager.connectAll();
        }

        if(numRetries > THRESHOLD){
            failed = true;
            return;
        }

        cnxManager.testInitiateConnection(sid);

        m = cnxManager.pollRecvQueue(3000, TimeUnit.MILLISECONDS);
        if(m == null){
            failed = true;
            return;
        }
    } catch (Exception e) {
        LOG.error("Exception while running mock thread", e);
        Assert.fail("Unexpected exception");
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:39,代码来源:CnxManagerTest.java

示例7: testCnxManager

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的package包/类
@Test
public void testCnxManager() throws Exception {
    CnxManagerThread thread = new CnxManagerThread();

    thread.start();
    
    QuorumPeer peer = new QuorumPeer(peers, peerTmpdir[1], peerTmpdir[1], peerClientPort[1], 3, 1, 1000, 2, 2);
    QuorumCnxManager cnxManager = peer.createCnxnManager();
    QuorumCnxManager.Listener listener = cnxManager.listener;
    if(listener != null){
        listener.start();
    } else {
        LOG.error("Null listener when initializing cnx manager");
    }

    cnxManager.toSend(new Long(0), createMsg(ServerState.LOOKING.ordinal(), 1, -1, 1));

    Message m = null;
    int numRetries = 1;
    while((m == null) && (numRetries++ <= THRESHOLD)){
        m = cnxManager.pollRecvQueue(3000, TimeUnit.MILLISECONDS);
        if(m == null) cnxManager.connectAll();
    }
    
    Assert.assertTrue("Exceeded number of retries", numRetries <= THRESHOLD);

    thread.join(5000);
    if (thread.isAlive()) {
        Assert.fail("Thread didn't join");
    } else {
        if(thread.failed)
            Assert.fail("Did not receive expected message");
    }
    
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:36,代码来源:CnxManagerTest.java

示例8: testBackwardCompatibility

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的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

示例9: testForwardCompatibility

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的package包/类
@Test(timeout=20000)
public void testForwardCompatibility() 
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
     */
    MockFLEMessengerForward fle = new MockFLEMessengerForward(peer, mng);
    ByteBuffer notBuffer = FastLeaderElection.buildMsg(ServerState.LOOKING.ordinal(), 2, 0x1, 1, 1);
    ByteBuffer buffer = ByteBuffer.allocate( notBuffer.capacity() + 8 );
    notBuffer.flip();
    buffer.put(notBuffer);
    buffer.putLong( Long.MAX_VALUE );
    buffer.flip();
    
    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);
    Assert.assertTrue("Wrong version", n.version == FastLeaderElection.Notification.CURRENTVERSION);
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:30,代码来源:FLECompatibilityTest.java

示例10: run

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的package包/类
public void run(){
    try {
        QuorumPeer peer = new QuorumPeer(peers, peerTmpdir[0], peerTmpdir[0], peerClientPort[0], 3, 0, 2, 2, 2);
        QuorumCnxManager cnxManager = new QuorumCnxManager(peer);
        QuorumCnxManager.Listener listener = cnxManager.listener;
        if(listener != null){
            listener.start();
        } else {
            LOG.error("Null listener when initializing cnx manager");
        }

        long sid = 1;
        cnxManager.toSend(sid, createMsg(ServerState.LOOKING.ordinal(), 0, -1, 1));

        Message m = null;
        int numRetries = 1;
        while((m == null) && (numRetries++ <= THRESHOLD)){
            m = cnxManager.pollRecvQueue(3000, TimeUnit.MILLISECONDS);
            if(m == null) cnxManager.connectAll();
        }

        if(numRetries > THRESHOLD){
            failed = true;
            return;
        }

        cnxManager.testInitiateConnection(sid);

        m = cnxManager.pollRecvQueue(3000, TimeUnit.MILLISECONDS);
        if(m == null){
            failed = true;
            return;
        }
    } catch (Exception e) {
        LOG.error("Exception while running mock thread", e);
        Assert.fail("Unexpected exception");
    }
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:39,代码来源:CnxManagerTest.java

示例11: testCnxManager

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的package包/类
@Test
public void testCnxManager() throws Exception {
    CnxManagerThread thread = new CnxManagerThread();

    thread.start();
    
    QuorumPeer peer = new QuorumPeer(peers, peerTmpdir[1], peerTmpdir[1], peerClientPort[1], 3, 1, 2, 2, 2);
    QuorumCnxManager cnxManager = new QuorumCnxManager(peer);
    QuorumCnxManager.Listener listener = cnxManager.listener;
    if(listener != null){
        listener.start();
    } else {
        LOG.error("Null listener when initializing cnx manager");
    }

    cnxManager.toSend(new Long(0), createMsg(ServerState.LOOKING.ordinal(), 1, -1, 1));

    Message m = null;
    int numRetries = 1;
    while((m == null) && (numRetries++ <= THRESHOLD)){
        m = cnxManager.pollRecvQueue(3000, TimeUnit.MILLISECONDS);
        if(m == null) cnxManager.connectAll();
    }
    
    Assert.assertTrue("Exceeded number of retries", numRetries <= THRESHOLD);

    thread.join(5000);
    if (thread.isAlive()) {
        Assert.fail("Thread didn't join");
    } else {
        if(thread.failed)
            Assert.fail("Did not receive expected message");
    }
    
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:36,代码来源:CnxManagerTest.java

示例12: run

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的package包/类
public void run(){
    try {
        QuorumPeer peer = new QuorumPeer(peers, peerTmpdir[0], peerTmpdir[0], peerClientPort[0], 3, 0, 1000, 2, 2);
        QuorumCnxManager cnxManager = new QuorumCnxManager(peer);
        QuorumCnxManager.Listener listener = cnxManager.listener;
        if(listener != null){
            listener.start();
        } else {
            LOG.error("Null listener when initializing cnx manager");
        }
        
        long sid = 1;
        cnxManager.toSend(sid, createMsg(ServerState.LOOKING.ordinal(), 0, -1, 1));
        
        Message m = null;
        int numRetries = 1;
        while((m == null) && (numRetries++ <= THRESHOLD)){
            m = cnxManager.recvQueue.poll(3000, TimeUnit.MILLISECONDS);
            if(m == null) cnxManager.connectAll();
        }
        
        if(numRetries > THRESHOLD){
            failed = true;
            return;
        }
        
        cnxManager.testInitiateConnection(sid);
    
        m = cnxManager.recvQueue.poll(3000, TimeUnit.MILLISECONDS);
        if(m == null){
            failed = true;
            return;
        }
    } catch (Exception e) {
        LOG.error("Exception while running mock thread", e);
        fail("Unexpected exception");
    }
}
 
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:39,代码来源:CnxManagerTest.java

示例13: testCnxManager

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的package包/类
@Test
public void testCnxManager() throws Exception {
    CnxManagerThread thread = new CnxManagerThread();
    
    thread.start();
    
    QuorumPeer peer = new QuorumPeer(peers, peerTmpdir[1], peerTmpdir[1], peerClientPort[1], 3, 1, 1000, 2, 2);
    QuorumCnxManager cnxManager = new QuorumCnxManager(peer);
    QuorumCnxManager.Listener listener = cnxManager.listener;
    if(listener != null){
        listener.start();
    } else {
        LOG.error("Null listener when initializing cnx manager");
    }
        
    cnxManager.toSend(new Long(0), createMsg(ServerState.LOOKING.ordinal(), 1, -1, 1));
    
    Message m = null;
    int numRetries = 1;
    while((m == null) && (numRetries++ <= THRESHOLD)){
        m = cnxManager.recvQueue.poll(3000, TimeUnit.MILLISECONDS);
        if(m == null) cnxManager.connectAll();
    }
    
    assertTrue("Exceeded number of retries", numRetries <= THRESHOLD);

    thread.join(5000);
    if (thread.isAlive()) {
        fail("Thread didn't join");
    } else {
        if(thread.failed)
            fail("Did not receive expected message");
    }
}
 
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:35,代码来源:CnxManagerTest.java

示例14: getSid

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的package包/类
long getSid(Message m){
    return m.sid;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:4,代码来源:CnxManagerTest.java

示例15: getMsgString

import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message; //导入依赖的package包/类
String getMsgString(Message m){
    return new String(m.buffer.array());
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:4,代码来源:CnxManagerTest.java


注:本文中的org.apache.zookeeper.server.quorum.QuorumCnxManager.Message类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。