Package org.jgroups.protocols.pbcast

Examples of org.jgroups.protocols.pbcast.NakAckHeader2



    /** Makes NAKACK2 receive a message with the given seqno */
    protected void injectMessage(long seqno) {
        Message msg=new Message(null, B, null);
        NakAckHeader2 hdr=NakAckHeader2.createMessageHeader(seqno);
        msg.putHeader(ID, hdr);
        nak.up(new Event(Event.MSG, msg));
    }
View Full Code Here


        public Object down(Event evt) {
            switch(evt.getType()) {
                case Event.MSG:
                    Message msg=(Message)evt.getArg();
                    NakAckHeader2 hdr=(NakAckHeader2)msg.getHeader(ID);
                    if(hdr == null)
                        break;
                    if(hdr.getType() == NakAckHeader2.XMIT_REQ) {
                        SeqnoList seqnos=(SeqnoList)msg.getObject();
                        System.out.println("-- XMIT-REQ: request retransmission for " + seqnos);
                        for(Long seqno: seqnos)
                            xmit_requests.add(seqno);
                    }
View Full Code Here

        public Object up(Event evt) {
            switch(evt.getType()) {
                case Event.MSG:
                    Message msg=(Message)evt.getArg();
                    NakAckHeader2 hdr=(NakAckHeader2)msg.getHeader(ID);
                    if(hdr != null && hdr.getType() == NakAckHeader2.MSG) {
                        long seqno=hdr.getSeqno();
                        msgs.add(seqno);
                        System.out.println("-- received message #" + seqno + " from " + msg.getSrc());
                    }
                    break;
            }
View Full Code Here

            return null;
        }

        public void up(MessageBatch batch) {
            for(Message msg: batch) {
                NakAckHeader2 hdr=(NakAckHeader2)msg.getHeader(ID);
                if(hdr != null && hdr.getType() == NakAckHeader2.MSG) {
                    long seqno=hdr.getSeqno();
                    msgs.add(seqno);
                    System.out.println("-- received message #" + seqno + " from " + msg.getSrc());
                }
            }
        }
View Full Code Here

        }

        public Object down(Event evt) {
            if(evt.getType() == Event.MSG) {
                Message msg=(Message)evt.getArg();
                NakAckHeader2 hdr=(NakAckHeader2)msg.getHeader(NAKACK_ID);
                if(hdr != null && hdr.getType() == NakAckHeader2.XMIT_REQ) {
                    this.range=(SeqnoList)msg.getObject();
                }
            }

            return super.down(evt);
View Full Code Here

        nak.setUpProtocol(new Protocol() {
            public Object up(Event evt) {
                if(evt.getType() == Event.MSG) {
                    delivered_msgs.incrementAndGet();
                    NakAckHeader2 hdr=(NakAckHeader2)((Message)evt.getArg()).getHeader(NAKACK_ID);
                    if(hdr != null)
                        delivered_msg_list.add(hdr.getSeqno());

                    if(delivered_msgs.get() >= num_msgs) {
                        lock.lock();
                        try {
                            all_msgs_delivered.signalAll();
                        }
                        finally {
                            lock.unlock();
                        }
                    }
                }
                return null;
            }

            public void up(MessageBatch batch) {
                for(Message msg: batch) {
                    delivered_msgs.incrementAndGet();
                    NakAckHeader2 hdr=(NakAckHeader2)msg.getHeader(NAKACK_ID);
                    if(hdr != null)
                        delivered_msg_list.add(hdr.getSeqno());

                    if(delivered_msgs.get() >= num_msgs) {
                        lock.lock();
                        try {
                            all_msgs_delivered.signalAll();
View Full Code Here

        System.out.println("OK");
    }

    private static Message createMessage(Address dest, Address src, long seqno, boolean oob) {
        Message msg=new Message(dest, src, "hello world");
        NakAckHeader2 hdr=NakAckHeader2.createMessageHeader(seqno) ;
        msg.putHeader(NAKACK_ID, hdr);
        if(oob)
            msg.setFlag(Message.Flag.OOB);
        return msg;
    }
View Full Code Here

TOP

Related Classes of org.jgroups.protocols.pbcast.NakAckHeader2

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.