Package org.jgroups

Examples of org.jgroups.Message


        FragReceiver(FragTest t) {
            this.t=t;
        }

        public Object up(Event evt) {
            Message msg=null;
            Address sender;

            if(evt == null || evt.getType() != Event.MSG)
                return null;
            msg=(Message)evt.getArg();
            sender=msg.getSrc();
            if(sender == null) {
                log.error("FragTest.FragReceiver.up(): sender is null; discarding msg");
                return null;
            }
            System.out.println("Received msg from " + sender + " [" + msg.getLength() + " bytes]");
            return null;
        }
View Full Code Here


    @Test(dataProvider="provider")
    public void testSimpleAdd(TimeScheduler timer, AckSenderWindow win) throws InterruptedException {
        try {
            for(int i=1; i <=5; i++)
                win.add(i, new Message());
            System.out.println("win = " + win);
            assert win.size() == 5;
            win.ack(1);
            System.out.println("win = " + win);
            assert win.size() == 4;
View Full Code Here

        try {
            // 1. Send NUM_MSGS messages:
            System.out.println("-- sending " + NUM_MSGS + " messages:");
            for(long i=0; i < NUM_MSGS; i++) {
                msgs.put(new Long(i), new Entry());
                win.add(i, new Message());
            }
            System.out.println("-- done");

            // 2. Wait for at least 4 xmits/msg: total of 1000 + 2000 + 4000 + 8000ms = 15000ms; wait for 20000ms
            System.out.println("-- waiting for all retransmits");
View Full Code Here

    @Test(dataProvider="provider")
    public void testLowest(TimeScheduler timer, AckSenderWindow win) {
        try {
            for(long i=1; i < 5; i++)
                win.add(i, new Message());
            System.out.println("win = " + win + ", lowest=" + win.getLowest());
            assert win.getLowest() == Global.DEFAULT_FIRST_UNICAST_SEQNO;

            win.ack(3);
            System.out.println("win = " + win + ", lowest=" + win.getLowest());
View Full Code Here


    @Test(dataProvider="provider")
    public void testGetLowestMessage(TimeScheduler timer, AckSenderWindow win) {
        long[] seqnos={1,2,3,4,5};
        final Message[] messages=new Message[]{new Message(),new Message(),new Message(),new Message(),new Message()};


        try {
            for(int i=0; i < seqnos.length; i++) {
                win.add(seqnos[i], messages[i]);
            }
            System.out.println("win = " + win);

            Message msg=win.getLowestMessage();
            assert messages[0] == msg;

            win.ack(2);
            msg=win.getLowestMessage();
            assert messages[2] == msg;
View Full Code Here

    @Test(dataProvider="provider")
    public void testAdd(TimeScheduler timer, AckSenderWindow win) {
        try {
            for(int i=1; i <= 10; i++)
                win.add(i, new Message());
            System.out.println("win = " + win);
            assert win.size() == 10;
            win.ack(7);
            assert win.size() == 3;
        }
View Full Code Here

    @Test(dataProvider="provider")
    public void testAck(TimeScheduler timer, AckSenderWindow win) {
        try {
            for(int i=1; i <= 3; i++)
                win.add(i, new Message());
            assert win.size() == 3;
            win.ack(1);
            assert win.size() == 2;
            win.ack(2);
            assert win.size() == 1;
View Full Code Here

            }

            // Case #3: we finally received a missing message. Case #2 handled seqno <= highest_delivered, so this
            // seqno *must* be between highest_delivered and next_to_add
            if(seqno < next_to_add) {
                Message existing=xmit_table.putIfAbsent(seqno, msg);
                if(existing != null)
                    return false; // key/value was present
                num_xmits=retransmitter.remove(seqno);
                if(log.isTraceEnabled())
                    log.trace(new StringBuilder("added missing msg ").append(msg.getSrc()).append('#').append(seqno));
View Full Code Here

        return remove(true, false);
    }


    public Message remove(boolean acquire_lock, boolean remove_msg) {
        Message retval;

        if(acquire_lock)
            lock.writeLock().lock();
        try {
            long next=highest_delivered +1;
View Full Code Here

        lock.writeLock().lock();
        try {
            while(true) {
                long next=highest_delivered +1;
                Message msg=remove_msgs? xmit_table.remove(next) : xmit_table.get(next);
                if(msg != null) { // message exists and is ready for delivery
                    highest_delivered=next;
                    if(retval == null)
                        retval=new LinkedList<Message>();
                    retval.add(msg);
View Full Code Here

TOP

Related Classes of org.jgroups.Message

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.