Package org.jgroups.util

Examples of org.jgroups.util.MutableDigest


    public void testMerge() {
        Map<Address, Digest.Entry> map=new HashMap<Address, Digest.Entry>();
        map.put(a1, new Digest.Entry(3, 499, 502));
        map.put(a2, new Digest.Entry(20, 26, 27));
        map.put(a3, new Digest.Entry(21, 26, 35));
        MutableDigest digest=new MutableDigest(map);

        System.out.println("d: " + d);
        System.out.println("digest: " + digest);
       
        digest.merge(d);
        System.out.println("merged digest: " + digest);

        assertEquals(3, d.size());
        assertEquals(3, digest.size());

        assertEquals(3, digest.lowSeqnoAt(a1));
        assertEquals(500, digest.highestDeliveredSeqnoAt(a1));
        assertEquals(502, digest.highestReceivedSeqnoAt(a1));

        assertEquals(20, digest.lowSeqnoAt(a2));
        assertEquals(26, digest.highestDeliveredSeqnoAt(a2));
        assertEquals(27, digest.highestReceivedSeqnoAt(a2));

        assertEquals(20, digest.lowSeqnoAt(a3));
        assertEquals(26, digest.highestDeliveredSeqnoAt(a3));
        assertEquals(35, digest.highestReceivedSeqnoAt(a3));
    }
View Full Code Here


        assertEquals(26, digest.highestDeliveredSeqnoAt(a3));
        assertEquals(35, digest.highestReceivedSeqnoAt(a3));
    }

    public void testNonConflictingMerge() {
        MutableDigest cons_d=new  MutableDigest(5);
        IpAddress ip1=new IpAddress(1111), ip2=new IpAddress(2222);

        cons_d.add(ip1, 1, 10, 10);
        cons_d.add(ip2, 2, 20, 20);
        // System.out.println("\ncons_d before: " + cons_d);
        cons_d.merge(d);

        assertEquals(5, cons_d.size());
        //System.out.println("\ncons_d after: " + cons_d);
        assertEquals(1, cons_d.lowSeqnoAt(ip1));
        assertEquals(2, cons_d.lowSeqnoAt(ip2));
        assertEquals(4, cons_d.lowSeqnoAt(a1));
        assertEquals(25, cons_d.lowSeqnoAt(a2));
        assertEquals(20, cons_d.lowSeqnoAt(a3));

        assertEquals(10, cons_d.highestDeliveredSeqnoAt(ip1));
        assertEquals(20, cons_d.highestDeliveredSeqnoAt(ip2));
        assertEquals(500, cons_d.highestDeliveredSeqnoAt(a1));
        assertEquals(26, cons_d.highestDeliveredSeqnoAt(a2));
        assertEquals(25, cons_d.highestDeliveredSeqnoAt(a3));

        assertEquals(10, cons_d.highestReceivedSeqnoAt(ip1));
        assertEquals(20, cons_d.highestReceivedSeqnoAt(ip2));
        assertEquals(501, cons_d.highestReceivedSeqnoAt(a1));
        assertEquals(26, cons_d.highestReceivedSeqnoAt(a2));
        assertEquals(33, cons_d.highestReceivedSeqnoAt(a3));
    }
View Full Code Here

        assertEquals(33, cons_d.highestReceivedSeqnoAt(a3));
    }


    public void testConflictingMerge() {
        MutableDigest new_d=new MutableDigest(2);
        new_d.add(a1, 5, 450, 501);
        new_d.add(a3, 18, 28, 35);
        //System.out.println("\nd before: " + d);
        //System.out.println("new_: " + new_d);
        md.merge(new_d);

        assertEquals(3, md.size());
View Full Code Here

        d2=d.copy();
        assertTrue(d.sameSenders(d2));
    }

    public void testSameSendersNotIdentical() {
        MutableDigest tmp=new MutableDigest(3);
        tmp.add(a1, 4, 500, 501);
        tmp.add(a3, 20, 25, 33);
        tmp.add(a2, 25, 26, 26);
        assertTrue(md.sameSenders(tmp));
        assertTrue(d.sameSenders(tmp));
    }
View Full Code Here

        assertTrue(md.sameSenders(tmp));
        assertTrue(d.sameSenders(tmp));
    }

    public void testSameSendersNotSameLength() {
        md=new MutableDigest(3);
        md.add(a1, 4, 500, 501);
        md.add(a2, 25, 26, 26);
        assertFalse(d.sameSenders(md));
    }
View Full Code Here

    }

    public void testStableHeader2() throws Exception {
        org.jgroups.protocols.pbcast.STABLE.StableHeader hdr;
        IpAddress addr=new IpAddress("127.0.0.1", 5555);
        MutableDigest digest=new MutableDigest(2);
        digest.add(addr, 100, 200, 205);
        hdr=new STABLE.StableHeader(STABLE.StableHeader.STABLE_GOSSIP, digest);
        _testSize(hdr);

        hdr=new STABLE.StableHeader(STABLE.StableHeader.STABILITY, null);
        _testSize(hdr);
View Full Code Here

        Vector members=new Vector();

        members.add(new IpAddress(1111));
        members.add(new IpAddress(2222));
        View v=new View(new IpAddress(1234), 322649, members);
        MutableDigest d=new MutableDigest(3);
        d.add(new IpAddress(3524), 1,2,3);
        d.add(new IpAddress(1324), 3,4,5);
        rsp=new JoinRsp();
        _testSize(rsp);
        rsp=new JoinRsp(v, d);
        _testSize(rsp);
        rsp=new JoinRsp("this is a failure");
View Full Code Here

        hdr=new STATE_TRANSFER.StateHeader(STATE_TRANSFER.StateHeader.STATE_REQ, addr, 322649, null, "my_state");
        _testSize(hdr);


        MutableDigest digest=new MutableDigest(2);
        digest.add(addr, 100, 200, 205);
        digest.add(new IpAddress(2314), 102, 104, 105);
        hdr=new STATE_TRANSFER.StateHeader(STATE_TRANSFER.StateHeader.STATE_RSP, addr, 322649, digest);
        _testSize(hdr);

        hdr=new STATE_TRANSFER.StateHeader(STATE_TRANSFER.StateHeader.STATE_RSP, addr, 322649, digest, "my_state");
        _testSize(hdr);
View Full Code Here

            // in the digest returned to the client, so the client will *not* be able to ask for retransmission
            // of those messages if he misses them           
            if(hasJoiningMembers) {
                gms.getDownProtocol().down(new Event(Event.SUSPEND_STABLE, MAX_SUSPEND_TIMEOUT));
                Digest tmp=gms.getDigest(); // get existing digest
                MutableDigest join_digest=null;
                if(tmp == null){
                    log.error("received null digest from GET_DIGEST: will cause JOIN to fail");
                }
                else {
                    // create a new digest, which contains the new member
                    join_digest=new MutableDigest(tmp.size() + new_mbrs.size());
                    join_digest.add(tmp); // add the existing digest to the new one
                    for(Address member:new_mbrs)
                        join_digest.add(member, 0, 0); // ... and add the new members. their first seqno will be 1
                }
                join_rsp=new JoinRsp(new_view, join_digest != null? join_digest.copy() : null);
            }

            sendLeaveResponses(leaving_mbrs); // no-op if no leaving members                           
            gms.castViewChangeWithDest(new_view, null,join_rsp,new_mbrs);                     
        }
View Full Code Here

    /**
     * Merge all digests into one. For each sender, the new value is min(low_seqno), max(high_seqno),
     * max(high_seqno_seen). This method has a lock on merge_rsps
     */
    private Digest consolidateDigests(Vector<MergeData> merge_rsps, int num_mbrs) {              
        MutableDigest retval=new MutableDigest(num_mbrs);

        for(MergeData data:merge_rsps) {           
            Digest tmp_digest=data.getDigest();
            if(tmp_digest == null) {
                if(log.isErrorEnabled()) log.error("tmp_digest == null; skipping");
                continue;
            }
            retval.merge(tmp_digest);
        }
        return retval.copy();
    }
View Full Code Here

TOP

Related Classes of org.jgroups.util.MutableDigest

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.