Package org.jgroups.util

Examples of org.jgroups.util.RetransmitTable


        if(cmd != null)
            retransmitter=use_range_based_retransmitter?
                    new RangeBasedRetransmitter(sender, cmd, sched) :
                    new DefaultRetransmitter(sender, cmd, sched);

        xmit_table=new RetransmitTable(num_rows, msgs_per_row, low, resize_factor, max_compaction_time, automatic_purging);
    }
View Full Code Here


@Test(groups=Global.FUNCTIONAL,sequential=false)
public class RetransmitTableTest {
    static final Message MSG=new Message(null, null, "test");

    public static void testCreation() {
        RetransmitTable table=new RetransmitTable(3, 10, 0);
        int size=table.size();
        assert size == 0;
        assert table.get(15) == null;
    }
View Full Code Here

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


    public static void testAddition() {
        RetransmitTable table=new RetransmitTable(3, 10, 0);
        addAndGet(table,  0"0");
        addAndGet(table,  1"1");
        addAndGet(table,  5"5");
        addAndGet(table,  9"9");
        addAndGet(table, 10, "10");
        addAndGet(table, 11, "11");
        addAndGet(table, 19, "19");
        addAndGet(table, 20, "20");
        addAndGet(table, 29, "29");
        System.out.println("table: " + table.dump());
        assert table.size() == 9;
        assert table.size() == table.computeSize();
        assert table.capacity() == 30;
    }
View Full Code Here

        assert table.capacity() == 30;
    }


    public static void testAdditionWithOffset() {
        RetransmitTable table=new RetransmitTable(3, 10, 100);
        addAndGet(table, 100, "100");
        addAndGet(table, 101, "101");
        addAndGet(table, 105, "105");
        addAndGet(table, 109, "109");
        addAndGet(table, 110, "110");
        addAndGet(table, 111, "111");
        addAndGet(table, 119, "119");
        addAndGet(table, 120, "120");
        addAndGet(table, 129, "129");
        System.out.println("table: " + table.dump());
        assert table.size() == 9;
        assert table.capacity() == 30;
    }
View Full Code Here

        assert table.capacity() == 30;
    }
   

    public static void testDuplicateAddition() {
        RetransmitTable table=new RetransmitTable(3, 10, 0);
        addAndGet(table,  0"0");
        addAndGet(table,  1"1");
        addAndGet(table,  5"5");
        addAndGet(table,  9"9");
        addAndGet(table, 10, "10");

        assert !table.put(5, new Message());
        assert table.get(5).getObject().equals("5");
        assert table.size() == 5;
    }
View Full Code Here

        assert table.size() == 5;
    }


    public static void testDumpMatrix() {
        RetransmitTable table=new RetransmitTable(3, 10, 1);
        long[] seqnos={1,3,5,7,9,12,14,16,18,20,21,22,23,24};
        for(long seqno: seqnos)
            table.put(seqno, MSG);
        System.out.println("matrix:\n" + table.dumpMatrix());
    }
View Full Code Here

        System.out.println("matrix:\n" + table.dumpMatrix());
    }


    public static void testMassAddition() {
        RetransmitTable table=new RetransmitTable(3, 10, 0);
        final int NUM_MSGS=10005;
        final Message MSG=new Message(null, null, "hello world");
        for(int i=0; i < NUM_MSGS; i++)
            table.put(i, MSG);
        System.out.println("table = " + table);
        assert table.size() == NUM_MSGS;
        assert table.capacity() == 10010;
    }
View Full Code Here

        assert table.size() == NUM_MSGS;
        assert table.capacity() == 10010;
    }

    public static void testResize() {
        RetransmitTable table=new RetransmitTable(3, 10, 0);
        assert table.capacity() == 30;
        addAndGet(table, 30, "30");
        addAndGet(table, 35, "35");
        assert table.capacity() == 40;
        addAndGet(table, 500, "500");
        assert table.capacity() == 510;

        addAndGet(table, 515, "515");
        assert table.capacity() == 520;
    }
View Full Code Here

        addAndGet(table, 515, "515");
        assert table.capacity() == 520;
    }

    public void testResizeWithPurge() {
        RetransmitTable table=new RetransmitTable(3, 10, 0);
        for(long i=1; i <= 100; i++)
            addAndGet(table, i, "hello-" + i);
        System.out.println("table: " + table);
       
        // now remove 60 messages
        for(long i=1; i <= 60; i++) {
            Message msg=table.remove(i);
            assert msg.getObject().equals("hello-" + i);
        }
        System.out.println("table after removal of seqno 60: " + table);

        table.purge(50);
        System.out.println("now triggering a resize() by addition of seqno=120");
        addAndGet(table, 120, "120");
       
    }
View Full Code Here

       
    }


    public void testResizeWithPurgeAndGetOfNonExistingElement() {
        RetransmitTable table=new RetransmitTable(3, 10, 0);
        for(long i=0; i < 50; i++)
            addAndGet(table, i, "hello-" + i);
        System.out.println("table: " + table);

        // now remove 15 messages
        for(long i=0; i <= 15; i++) {
            Message msg=table.remove(i);
            assert msg.getObject().equals("hello-" + i);
        }
        System.out.println("table after removal of seqno 15: " + table);

        table.purge(15);
        System.out.println("now triggering a resize() by addition of seqno=55");
        addAndGet(table, 55, "hello-55");

        // now we have elements 40-49 in row 1 and 55 in row 2:
        List<String> list=new ArrayList<String>(20);
        for(int i=16; i < 50; i++)
            list.add("hello-" + i);
        list.add("hello-55");

        for(long i=table.getOffset(); i < table.capacity() + table.getOffset(); i++) {
            Message msg=table.get(i);
            if(msg != null) {
                String message=(String)msg.getObject();
                System.out.println(i + ": " + message);
                list.remove(message);
            }
        }

        System.out.println("table:\n" + table.dumpMatrix());
        assert list.isEmpty() : " list: " + Util.print(list);
    }
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.