Package org.jgroups.util

Examples of org.jgroups.util.RetransmitTable


        assert table.get(53) == null;
    }


    public static void testMove() {
        RetransmitTable table=new RetransmitTable(3, 10, 0);
        for(long i=0; i < 50; i++)
            addAndGet(table, i, "hello-" + i);
        table.purge(49);
        assert table.isEmpty();
        addAndGet(table, 50, "50");
        assert table.size() == 1;
        assertCapacity(table.capacity(), table.getLength(), 10);
    }
View Full Code Here


        assertCapacity(table.capacity(), table.getLength(), 10);
    }


    public static void testPurge() {
        RetransmitTable table=new RetransmitTable(5, 10, 0);
        for(long seqno=0; seqno < 25; seqno++)
            table.put(seqno, MSG);

        long[] seqnos={30,31,32,37,38,39, 40,41,42,47,48,49};
        for(long seqno: seqnos)
            table.put(seqno, MSG);

        System.out.println("table (before remove):\n" + table.dump());
        for(long seqno=0; seqno <= 22; seqno++)
            table.remove(seqno);

        System.out.println("\ntable (after remove 22, before purge):\n" + table.dump());
        table.purge(22);
        System.out.println("\ntable: (after purge 22):\n" + table.dump());
        assert table.size() == 2 + seqnos.length;
    }
View Full Code Here

        assert table.size() == 2 + seqnos.length;
    }


    public void testCompact() {
        RetransmitTable table=new RetransmitTable(3, 10, 0);
        for(long i=0; i < 80; i++)
            addAndGet(table, i, "hello-" + i);
        assert table.size() == 80;
        table.purge(59);
        assert table.size() == 20;
        table.compact();
        assert table.size() == 20;
        assertCapacity(table.capacity(), table.getLength(), 10);
    }
View Full Code Here

        assertCapacity(table.capacity(), table.getLength(), 10);
    }


    public void testCompactWithAutomaticPurging() {
        RetransmitTable table=new RetransmitTable(3, 10, 0);
        table.setAutomaticPurging(true);
        for(long i=0; i < 80; i++)
             addAndGet(table, i, "hello-" + i);
        assert table.size() == 80;
        for(long i=0; i <= 59; i++)
            table.remove(i);

        assert table.size() == 20;
        table.compact();
        assert table.size() == 20;
        assertCapacity(table.capacity(), table.getLength(), 10);
    }
View Full Code Here

        assert table.size() == 20;
        assertCapacity(table.capacity(), table.getLength(), 10);
    }

    public void testSizeOfAllMessages() {
        RetransmitTable table=new RetransmitTable(3, 10, 0);
        long size=table.sizeOfAllMessages(false);
        assert size == 0;
        size=table.sizeOfAllMessages(true);
        assert size == 0;

        byte[] buf=new byte[100];
        Message msg=new Message(null, null, buf);
        table.put(2,msg);

        size=table.sizeOfAllMessages(false);
        System.out.println("Size(): " + table.sizeOfAllMessages(true) + ", getLength(): " + size);
        assert size == 100;

        for(long i=5; i < 10; i++)
            table.put(i, new Message(null, null, buf));

        size=table.sizeOfAllMessages(false);
        System.out.println("Size(): " + table.sizeOfAllMessages(true) + ", getLength(): " + size);
        assert size == 6 * 100;
    }
View Full Code Here

TOP

Related Classes of org.jgroups.util.RetransmitTable

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.