Package org.jgroups.util

Examples of org.jgroups.util.RetransmitTable


        assert table.size() == 9;
        assertCapacity(table.capacity(), 3, 10);
    }

    public static void testAdditionWithOffset2() {
        RetransmitTable table=new RetransmitTable(3, 10, 2);
        addAndGet(table, 1000, "1000");
        addAndGet(table, 1001, "1001");
        table.compact();
        addAndGet(table, 1005, "1005");
        addAndGet(table, 1009, "1009");
        addAndGet(table, 1010, "1010");
        addAndGet(table, 1011, "1011");
        addAndGet(table, 1019, "1019");
        addAndGet(table, 1020, "1020");
        addAndGet(table, 1029, "1029");
        System.out.println("table: " + table.dump());
        assert table.size() == 9;
    }
View Full Code Here


        assert table.size() == 9;
    }
   

    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 testRemove() {
        RetransmitTable table=new RetransmitTable(3, 10, 1);
        for(long i=1; i <= 20; i++)
            if(i % 2 == 0)
                table.put(i, new Message());
        System.out.println("table = " + table);
        assert table.size() == 10;

        int num_null_msgs=table.getNullMessages(0, 20);
        System.out.println("num_null_msgs = " + num_null_msgs);
        assert num_null_msgs == 10;

        for(long i=1; i <= 10; i++)
            table.remove(i);
        System.out.println("table = " + table);
        assert table.size() == 5;

        num_null_msgs=table.getNullMessages(0, 20);
        System.out.println("num_null_msgs = " + num_null_msgs);
        assert num_null_msgs == 15;
    }
View Full Code Here

        System.out.println("num_null_msgs = " + num_null_msgs);
        assert num_null_msgs == 15;
    }

    public static void testGetNullMessages() {
        RetransmitTable table=new RetransmitTable(3, 10, 0);
        table.put(1, MSG);
        table.put(100, MSG);
        System.out.println("table = " + table);
        int num_null_elements=table.getNullMessages(0, 100);
        assert num_null_elements == 98; // [1 .. 99] excluding 100, as it has been received
    }
View Full Code Here

        int num_null_elements=table.getNullMessages(0, 100);
        assert num_null_elements == 98; // [1 .. 99] excluding 100, as it has been received
    }

    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;
        assertCapacity(table.capacity(), table.getLength(), 10);
    }
View Full Code Here

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

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

        addAndGet(table, 515, "515");
        assertCapacity(table.capacity(), table.getLength(), 10);
    }
View Full Code Here

        addAndGet(table, 515, "515");
        assertCapacity(table.capacity(), table.getLength(), 10);
    }

    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

        assert list.isEmpty() : " list: " + Util.print(list);
    }


    public void testResizeWithPurge2() {
        RetransmitTable table=new RetransmitTable(3, 10, 0);
        for(long i=0; i < 50; i++)
            addAndGet(table, i, "hello-" + i);
        System.out.println("table = " + table);
        assert table.size() == 50;
        assertCapacity(table.capacity(), table.getLength(), 10);
        assert table.getHighestPurged() == 0;
        assert table.getHighest() == 49;

        table.purge(43);
        addAndGet(table, 52, "hello-52");
        assert table.get(43) == null;

        for(long i=44; i < 50; i++) {
            Message msg=table.get(i);
            assert msg != null && msg.getObject().equals("hello-" + i);
        }

        assert table.get(50) == null;
        assert table.get(51) == null;
        Message msg=table.get(52);
        assert msg != null && msg.getObject().equals("hello-52");
        assert table.get(53) == null;
    }
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.