Package org.jgroups.util

Examples of org.jgroups.util.MutableDigest


                    if(log.isWarnEnabled())
                        log.warn("digest response has no senders: digest=" + rsp.getDigest());
                    rsp=null; // just skip the response we guess
                    continue;
                }
                MutableDigest tmp_digest=new MutableDigest(rsp.getDigest());
                tmp_view=rsp.getView();
                if(tmp_view == null) {
                    if(log.isErrorEnabled())
                        log.error("JoinRsp has a null view, skipping it");
                    rsp=null;
                }
                else {
                    if(!tmp_digest.contains(gms.local_addr)) {
                        throw new IllegalStateException("digest returned from " + coord + " with JOIN_RSP does not contain myself (" +
                                gms.local_addr + "): join response: " + rsp);
                    }
                    tmp_digest.incrementHighestDeliveredSeqno(coord); // see doc/design/varia2.txt for details
                    tmp_digest.seal();
                    gms.setDigest(tmp_digest);

                    if(log.isDebugEnabled())
                        log.debug("[" + gms.local_addr + "]: JoinRsp=" + tmp_view + " [size=" + tmp_view.size() + "]\n\n");
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, join_rsp != null? join_rsp.getDigest() : null, join_rsp,new_mbrs);                     
        }
View Full Code Here

        Map<Address, Digest.Entry> map=new HashMap<Address, Digest.Entry>();
        map.put(a1, new Digest.Entry(4, 500, 501));
        map.put(a2, new Digest.Entry(25, 26, 26));
        map.put(a3, new Digest.Entry(20, 25, 33));
        d=new Digest(map);
        md=new MutableDigest(map);
    }
View Full Code Here

        assert !(my.isGreaterThanOrEqual(d));
    }


    public void testEquals2() {
        md=new MutableDigest(d);
        System.out.println("d: " + d + "\nmd= " + md);
        Assert.assertEquals(d, d);
        Assert.assertEquals(d, md);
        md.incrementHighestDeliveredSeqno(a1);
        System.out.println("d: " + d + "\nmd= " + md);
View Full Code Here

        Assert.assertEquals(md, md2);
    }


    public void testImmutability() {
        MutableDigest tmp=new MutableDigest(d);
        Assert.assertEquals(d, tmp);
        tmp.incrementHighestDeliveredSeqno(a2);
        assert !(d.equals(tmp));
    }
View Full Code Here

        assert !(copy.equals(md));
    }


    public void testSeal() {
        MutableDigest tmp=new MutableDigest(3);
        tmp.add(a2, 1,2,3);
        Assert.assertEquals(1, tmp.size());
        tmp.seal();
        try {
            tmp.add(a2, 4,5,6);
            assert false : "should run into an exception";
        }
        catch(IllegalAccessError e) {
            System.out.println("received exception \"" + e.toString() + "\" - as expected");
        }
        Assert.assertEquals(1, tmp.size());
    }
View Full Code Here

        }
        catch(IllegalAccessError e) {
            System.out.println("received exception \"" + e.toString() + "\" - as expected");
        }

        MutableDigest tmp=new MutableDigest(md);
        tmp.incrementHighestDeliveredSeqno(a3);
    }
View Full Code Here

        Assert.assertEquals(3, md.size());
    }


    public void testAddDigest2() {
        MutableDigest tmp=new MutableDigest(4);
        tmp.add(Util.createRandomAddress(), 1,2,3);
        tmp.add(Util.createRandomAddress(), 1,2,3);
        tmp.add(a2, 1,2,3);
        tmp.add(a3, 1,2,3);
        md.add(tmp);
        Assert.assertEquals(5, md.size());
    }
View Full Code Here

        Assert.assertEquals(entry, new Digest.Entry(20, 25, 33));
    }


    public void testIncrementHighSeqno() {
        md=new MutableDigest(3);
        md.add(a1, 1, 100);
        md.add(a2, 3, 300);
        md.add(a3, 7, 700);

        long tmp=md.highestDeliveredSeqnoAt(a1);
View Full Code Here

        Assert.assertEquals(0, dd.size());
    }


    public static void testConstructor3() {
        Digest dd=new MutableDigest(3);
        Assert.assertEquals(0, dd.size());
    }
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.