Package org.apache.zookeeper.server.quorum

Examples of org.apache.zookeeper.server.quorum.QuorumPeer


            tmpdir[i] = ClientBase.createTmpDir();
            port[i] = PortAssignment.unique();
        }

        for(int i = 0; i < count; i++) {
            QuorumPeer peer = new QuorumPeer(peers, tmpdir[i], tmpdir[i], port[i], 3, i, 1000, 2, 2);
            peer.startLeaderElection();
            FLERestartThread thread = new FLERestartThread(peer, i);
            thread.start();
            restartThreads.add(thread);
        }
        LOG.info("Started threads " + getName());
View Full Code Here


            tmpdir[i] = ClientBase.createTmpDir();
            port[i] = PortAssignment.unique();
        }

        for(int i = 0; i < le.length; i++) {
            QuorumPeer peer = new QuorumPeer(peers, tmpdir[i], tmpdir[i],
                    port[i], 3, i, 1000, 2, 2);
            peer.startLeaderElection();
            LEThread thread = new LEThread(peer, i);
            thread.start();
            threads.add(thread);
        }
        LOG.info("Started threads " + getName());
View Full Code Here

        }
       
        /*
         * peer1 and peer2 are A and B in the above example.
         */
        QuorumPeer peer1 = new MockQuorumPeer(peers, tmpdir[0], tmpdir[0], port[0], 0, 0, 2, 2, 2);
        peer1.startLeaderElection();
        LEThread thread1 = new LEThread(peer1, 0);
       
        QuorumPeer peer2 = new MockQuorumPeer(peers, tmpdir[1], tmpdir[1], port[1], 0, 1, 2, 2, 2);
        peer2.startLeaderElection();       
        LEThread thread2 = new LEThread(peer2, 1);
                           
        /*
         * Start mock server.
         */
 
View Full Code Here

                        if(peerRound == 0){
                            LOG.info("First peer, shutting it down");
                            QuorumBase.shutdown(peer);
                            ((FastLeaderElection) restartThreads.get(i).peer.getElectionAlg()).shutdown();

                            peer = new QuorumPeer(peers, tmpdir[i], tmpdir[i], port[i], 3, i, 1000, 2, 2);
                            peer.startLeaderElection();
                            peerRound++;
                        } else {
                            finish.release(2);
                            return;
View Full Code Here

                withObservers ? QuorumPeer.LearnerType.OBSERVER
                        : QuorumPeer.LearnerType.PARTICIPANT));

        LOG.info("creating QuorumPeer 1 port " + port1);
        QuorumHierarchical hq1 = new QuorumHierarchical(qp);
        s1 = new QuorumPeer(peers, s1dir, s1dir, port1, 3, 1, tickTime, initLimit, syncLimit, hq1);
        assertEquals(port1, s1.getClientPort());
       
        LOG.info("creating QuorumPeer 2 port " + port2);
        QuorumHierarchical hq2 = new QuorumHierarchical(qp);
        s2 = new QuorumPeer(peers, s2dir, s2dir, port2, 3, 2, tickTime, initLimit, syncLimit, hq2);
        assertEquals(port2, s2.getClientPort());
       
        LOG.info("creating QuorumPeer 3 port " + port3);
        QuorumHierarchical hq3 = new QuorumHierarchical(qp);
        s3 = new QuorumPeer(peers, s3dir, s3dir, port3, 3, 3, tickTime, initLimit, syncLimit, hq3);
        assertEquals(port3, s3.getClientPort());
       
        LOG.info("creating QuorumPeer 4 port " + port4);
        QuorumHierarchical hq4 = new QuorumHierarchical(qp);
        s4 = new QuorumPeer(peers, s4dir, s4dir, port4, 3, 4, tickTime, initLimit, syncLimit, hq4);
        if (withObservers) {
            s4.setLearnerType(QuorumPeer.LearnerType.OBSERVER);
        }
        assertEquals(port4, s4.getClientPort());
                      
        LOG.info("creating QuorumPeer 5 port " + port5);
        QuorumHierarchical hq5 = new QuorumHierarchical(qp);
        s5 = new QuorumPeer(peers, s5dir, s5dir, port5, 3, 5, tickTime, initLimit, syncLimit, hq5);
        if (withObservers) {
            s5.setLearnerType(QuorumPeer.LearnerType.OBSERVER);
        }
        assertEquals(port5, s5.getClientPort());
       
View Full Code Here

        peers.put(Long.valueOf(3), new QuorumServer(3, new InetSocketAddress("127.0.0.1", 3183)));
        peers.put(Long.valueOf(4), new QuorumServer(4, new InetSocketAddress("127.0.0.1", 3184)));
        peers.put(Long.valueOf(5), new QuorumServer(5, new InetSocketAddress("127.0.0.1", 3185)));

        LOG.info("creating QuorumPeer 1");
        s1 = new QuorumPeer(peers, s1dir, s1dir, 2181, 0, 1, tickTime, initLimit, syncLimit);
        assertEquals(2181, s1.getClientPort());
        LOG.info("creating QuorumPeer 2");
        s2 = new QuorumPeer(peers, s2dir, s2dir, 2182, 0, 2, tickTime, initLimit, syncLimit);
        assertEquals(2182, s2.getClientPort());
        LOG.info("creating QuorumPeer 3");
        s3 = new QuorumPeer(peers, s3dir, s3dir, 2183, 0, 3, tickTime, initLimit, syncLimit);
        assertEquals(2183, s3.getClientPort());
        LOG.info("creating QuorumPeer 4");
        s4 = new QuorumPeer(peers, s4dir, s4dir, 2184, 0, 4, tickTime, initLimit, syncLimit);
        assertEquals(2184, s4.getClientPort());
        LOG.info("creating QuorumPeer 5");
        s5 = new QuorumPeer(peers, s5dir, s5dir, 2185, 0, 5, tickTime, initLimit, syncLimit);
        assertEquals(2185, s5.getClientPort());
        LOG.info("start QuorumPeer 1");
        s1.start();
        LOG.info("start QuorumPeer 2");
        s2.start();
View Full Code Here

        peers.put(Long.valueOf(3), new QuorumServer(3, new InetSocketAddress("127.0.0.1", 3183)));
        peers.put(Long.valueOf(4), new QuorumServer(4, new InetSocketAddress("127.0.0.1", 3184)));
        peers.put(Long.valueOf(5), new QuorumServer(5, new InetSocketAddress("127.0.0.1", 3185)));

        LOG.info("creating QuorumPeer 1");
        s1 = new QuorumPeer(peers, s1dir, s1dir, 2181, 0, 1, tickTime, initLimit, syncLimit);
        assertEquals(2181, s1.getClientPort());
        LOG.info("creating QuorumPeer 2");
        s2 = new QuorumPeer(peers, s2dir, s2dir, 2182, 0, 2, tickTime, initLimit, syncLimit);
        assertEquals(2182, s2.getClientPort());
        LOG.info("creating QuorumPeer 3");
        s3 = new QuorumPeer(peers, s3dir, s3dir, 2183, 0, 3, tickTime, initLimit, syncLimit);
        assertEquals(2183, s3.getClientPort());
        LOG.info("creating QuorumPeer 4");
        s4 = new QuorumPeer(peers, s4dir, s4dir, 2184, 0, 4, tickTime, initLimit, syncLimit);
        assertEquals(2184, s4.getClientPort());
        LOG.info("creating QuorumPeer 5");
        s5 = new QuorumPeer(peers, s5dir, s5dir, 2185, 0, 5, tickTime, initLimit, syncLimit);
        assertEquals(2185, s5.getClientPort());
    }
View Full Code Here

        HashMap<Long,QuorumServer> peers = new HashMap<Long,QuorumServer>();
        peers.put(Long.valueOf(1), new QuorumServer(1, new InetSocketAddress("127.0.0.1", port1 + 1000)));
        peers.put(Long.valueOf(2), new QuorumServer(2, new InetSocketAddress("127.0.0.1", port2 + 1000)));
        peers.put(Long.valueOf(3), new QuorumServer(3, new InetSocketAddress("127.0.0.1", port3 + 1000)));

        QuorumPeer s2 = new QuorumPeer(peers, dataDir2, dataDir2, port2, 0, 2, tickTime, initLimit, syncLimit);
        s2.start();
        QuorumPeer s3 = new QuorumPeer(peers, dataDir3, dataDir3, port3, 0, 3, tickTime, initLimit, syncLimit);
        s3.start();
        connected = false;
        zk = new ZooKeeper("127.0.0.1:" + port2, 15000, nullWatcher);
        while(!connected) {
            Thread.sleep(1000);
        }
        for(int i = 0; i < 10; i++) {
            zk.create("/" + i, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        }
        zk.close();
       
        final ZooKeeper zk2 = new ZooKeeper("127.0.0.1:" + port2, 15000, nullWatcher);
        zk2.getData("/9", false, new Stat());
        try {
            zk2.getData("/10", false, new Stat());
            Assert.fail("Should have gotten an error");
        } catch(KeeperException.NoNodeException e) {
            // this is what we want
        }
        QuorumPeer s1 = new QuorumPeer(peers, dataDir1, dataDir1, port1, 0, 1, tickTime, initLimit, syncLimit);
        s1.start();

        connected = false;
        ZooKeeper zk1 = new ZooKeeper("127.0.0.1:" + port1, 15000, nullWatcher);
        while(!connected) {
            Thread.sleep(1000);
View Full Code Here

        /*
         * Start server 0
         */

        QuorumPeer peer = new QuorumPeer(peers, tmpdir[1], tmpdir[1], port[1], 3, 1, 1000, 2, 2);
        peer.startLeaderElection();
        FLETestUtils.LEThread thread = new FLETestUtils.LEThread(peer, 1);
        thread.start();

        /*
         * Start mock server 1
View Full Code Here

    void mockServer() throws InterruptedException, IOException {
        /*
         * Create an instance of the connection manager
         */
        QuorumPeer peer = new QuorumPeer(peers, tmpdir[0], tmpdir[0], port[0], 3, 0, 1000, 2, 2);
        cnxManager = new QuorumCnxManager(peer);
        QuorumCnxManager.Listener listener = cnxManager.listener;
        listener.start();


View Full Code Here

TOP

Related Classes of org.apache.zookeeper.server.quorum.QuorumPeer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.