Package org.apache.zookeeper.server.quorum.Leader

Examples of org.apache.zookeeper.server.quorum.Leader.Proposal


            } catch (IOException e) {
                LOG.error("This really should be impossible", e);
            }
            QuorumPacket pp = new QuorumPacket(Leader.PROPOSAL, request.zxid,
                    baos.toByteArray(), null);
            Proposal p = new Proposal();
            p.packet = pp;
            p.request = request;
            committedLog.add(p);
            maxCommittedLog = p.packet.getZxid();
        } finally {
View Full Code Here


            } catch (IOException e) {
                LOG.error("This really should be impossible", e);
            }
            QuorumPacket pp = new QuorumPacket(Leader.PROPOSAL, request.zxid,
                    baos.toByteArray(), null);
            Proposal p = new Proposal();
            p.packet = pp;
            p.request = request;
            committedLog.add(p);
            maxCommittedLog = p.packet.getZxid();
        }
View Full Code Here

            } catch (IOException e) {
                LOG.error("This really should be impossible", e);
            }
            QuorumPacket pp = new QuorumPacket(Leader.PROPOSAL, request.zxid,
                    baos.toByteArray(), null);
            Proposal p = new Proposal();
            p.packet = pp;
            p.request = request;
            committedLog.add(p);
            maxCommittedLog = p.packet.getZxid();
        }
View Full Code Here

            } catch (IOException e) {
                LOG.error("This really should be impossible", e);
            }
            QuorumPacket pp = new QuorumPacket(Leader.PROPOSAL, request.zxid,
                    baos.toByteArray(), null);
            Proposal p = new Proposal();
            p.packet = pp;
            p.request = request;
            committedLog.add(p);
            maxCommittedLog = p.packet.getZxid();
        } finally {
View Full Code Here

    @Override
    public Proposal next() {

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
        Proposal p = new Proposal();
        try {
            TxnHeader hdr = itr.getHeader();
            Record txn = itr.getTxn();
            hdr.serialize(boa, "hdr");
            if (txn != null) {
View Full Code Here

        int createCount = 0;
        ArrayList<Long> retrievedZxids = new ArrayList<Long>(MSG_COUNT);

        // Get zxid of create requests
        while (itr.hasNext()) {
            Proposal proposal = itr.next();
            TxnHeader hdr = new TxnHeader();
            Record rec = SerializeUtils.deserializeTxn(
                    proposal.packet.getData(), hdr);
            if (hdr.getType() == OpCode.create) {
                retrievedZxids.add(hdr.getZxid());
View Full Code Here

        db = new MockZKDatabase(null);
        learnerHandler = new MockLearnerHandler(sock, leader);
    }

    Proposal createProposal(long zxid) {
        Proposal p = new Proposal();
        p.packet = new QuorumPacket();
        p.packet.setZxid(zxid);
        p.packet.setType(Leader.PROPOSAL);
        return p;
    }
View Full Code Here

    public void testMajQuorums() throws Throwable {
      
       //setup servers 1-5 to be followers
       setUp(false);
       
       Proposal p = new Proposal();
      
        p.addQuorumVerifier(s1.getQuorumVerifier());
       
        // 2 followers out of 5 is not a majority
        p.addAck(Long.valueOf(1));
        p.addAck(Long.valueOf(2));       
        Assert.assertEquals(false, p.hasAllQuorums());
       
        // 6 is not in the view - its vote shouldn't count
        p.addAck(Long.valueOf(6))
        Assert.assertEquals(false, p.hasAllQuorums());
       
        // 3 followers out of 5 are a majority of the voting view
        p.addAck(Long.valueOf(3))
        Assert.assertEquals(true, p.hasAllQuorums());
       
       //setup servers 1-3 to be followers and 4 and 5 to be observers
       setUp(true);
      
       p = new Proposal();
       p.addQuorumVerifier(s1.getQuorumVerifier());
       
        // 1 follower out of 3 is not a majority
       p.addAck(Long.valueOf(1));     
        Assert.assertEquals(false, p.hasAllQuorums());
       
        // 4 and 5 are observers, their vote shouldn't count
        p.addAck(Long.valueOf(4));
        p.addAck(Long.valueOf(5));
        Assert.assertEquals(false, p.hasAllQuorums());
       
        // 6 is not in the view - its vote shouldn't count
        p.addAck(Long.valueOf(6));
        Assert.assertEquals(false, p.hasAllQuorums());
       
        // 2 followers out of 3 are a majority of the voting view
        p.addAck(Long.valueOf(2));
        Assert.assertEquals(true, p.hasAllQuorums());
    }
View Full Code Here

        long queuedZxid = peerLastZxid;
        // as we look through proposals, this variable keeps track of previous
        // proposal Id.
        long prevProposalZxid = -1;
        while (itr.hasNext()) {
            Proposal propose = itr.next();

            long packetZxid = propose.packet.getZxid();
            // abort if we hit the limit
            if ((maxZxid != null) && (packetZxid > maxZxid)) {
                break;
View Full Code Here

TOP

Related Classes of org.apache.zookeeper.server.quorum.Leader.Proposal

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.