Package org.jgroups.stack

Examples of org.jgroups.stack.NakReceiverWindow


        }
    }


    private ReceiverEntry getOrCreateReceiverEntry(Address sender, long seqno, long conn_id) {
        NakReceiverWindow win=new NakReceiverWindow(sender, this, seqno-1, seqno-1, timer, use_range_based_retransmitter,
                                                    xmit_table_num_rows, xmit_table_msgs_per_row,
                                                    xmit_table_resize_factor, xmit_table_max_compaction_time,
                                                    xmit_table_automatic_purging);
        ReceiverEntry entry=new ReceiverEntry(win, conn_id, max_stable_msgs);
        ReceiverEntry entry2=recv_table.putIfAbsent(sender, entry);
View Full Code Here


    @ManagedOperation(description="Returns the sizes of all NakReceiverWindow.RetransmitTables")
    public String printRetransmitTableSizes() {
        StringBuilder sb=new StringBuilder();
        for(Map.Entry<Address,ReceiverEntry> entry: recv_table.entrySet()) {
            NakReceiverWindow win=entry.getValue().received_msgs;
            sb.append(entry.getKey() + ": ").append(win.getRetransmiTableSize())
              .append(" (capacity=" + win.getRetransmitTableCapacity())
              .append(", fill factor=" + win.getRetransmitTableFillFactor() + "%)\n");
        }
        return sb.toString();
    }
View Full Code Here


    @ManagedOperation(description="Compacts the retransmission tables")
    public void compact() {
        for(Map.Entry<Address,ReceiverEntry> entry: recv_table.entrySet()) {
            NakReceiverWindow win=entry.getValue().received_msgs;
            win.compact();
        }
    }
View Full Code Here

    }

    @ManagedOperation(description="Purges highes delivered messages and compacts the retransmission tables")
    public void purgeAndCompact() {
        for(Map.Entry<Address,ReceiverEntry> entry: recv_table.entrySet()) {
            NakReceiverWindow win=entry.getValue().received_msgs;
            win.stable(win.getHighestDelivered());
            win.compact();
        }
    }
View Full Code Here

            " retransmissions from senders")
    public void sendStableMessages() {
        for(Map.Entry<Address,ReceiverEntry> entry: recv_table.entrySet()) {
            Address dest=entry.getKey();
            ReceiverEntry val=entry.getValue();
            NakReceiverWindow win=val != null? val.received_msgs : null;
            if(win != null) {
                long low=win.getHighestDelivered();
                long high=win.getHighestReceived();

                if(val.last_highest == high) {
                    if(val.num_stable_msgs >= val.max_stable_msgs) {
                        continue;
                    }
View Full Code Here

            log.trace(sb.toString());
        }
        down_prot.down(new Event(Event.MSG, stable_msg));

        ReceiverEntry entry=recv_table.get(dest);
        NakReceiverWindow win=entry != null? entry.received_msgs : null;
        if(win != null) {
            //System.out.println("[" + local_addr + "] stable(" + dest + ", hd=" + win.getHighestDelivered() + "): " +
              //                   "win: " + win);
            win.stable(win.getHighestDelivered());
        }
    }
View Full Code Here

        if(entry != null)
            entry.reset();

        ReceiverEntry entry2=recv_table.remove(mbr);
        if(entry2 != null) {
            NakReceiverWindow win=entry2.received_msgs;
            if(win != null)
                sendStableMessage(mbr, win.getHighestDelivered(), win.getHighestReceived());
            entry2.reset();
        }
    }
View Full Code Here

            sb.append(')');
            log.trace(sb);
        }

        ReceiverEntry entry=recv_table.get(sender);
        NakReceiverWindow win=entry != null? entry.received_msgs : null;

        if(first) {
            if(entry == null) {
                entry=getOrCreateReceiverEntry(sender, seqno, conn_id);
                win=entry.received_msgs;
            }
            else // entry != null && win != null
                if(conn_id != entry.recv_conn_id) {
                    if(log.isTraceEnabled())
                        log.trace(local_addr + ": conn_id=" + conn_id + " != " + entry.recv_conn_id + "; resetting receiver window");

                    ReceiverEntry entry2=recv_table.remove(sender);
                    if(entry2 != null)
                        entry2.received_msgs.destroy();

                    entry=getOrCreateReceiverEntry(sender, seqno, conn_id);
                    win=entry.received_msgs;
                }
                else {
                    ;
                }
            }
        }
        else { // entry == null && win == null OR entry != null && win == null OR entry != null && win != null
            if(win == null || entry.recv_conn_id != conn_id) {
                sendRequestForFirstSeqno(sender, seqno); // drops the message and returns (see below)
                return;
            }
        }

        boolean added=win.add(seqno, msg); // win is guaranteed to be non-null if we get here
        num_msgs_received++;
        num_bytes_received+=msg.getLength();

        if(added) {
            int bytes=entry.received_bytes.addAndGet(msg.getLength());
            if(bytes >= max_bytes) {
                entry.received_bytes_lock.lock();
                try {
                    entry.received_bytes.set(0);
                }
                finally {
                    entry.received_bytes_lock.unlock();
                }

                sendStableMessage(sender, win.getHighestDelivered(), win.getHighestReceived());
            }
        }

        // An OOB message is passed up immediately. Later, when remove() is called, we discard it. This affects ordering !
        // http://jira.jboss.com/jira/browse/JGRP-377
        if(msg.isFlagSet(Message.OOB) && added) {
            try {
                up_prot.up(evt);
            }
            catch(Throwable t) {
                log.error("couldn't deliver OOB message " + msg, t);
            }
        }

        final AtomicBoolean processing=win.getProcessing();
        if(!processing.compareAndSet(false, true)) {
            return;
        }

        // try to remove (from the AckReceiverWindow) as many messages as possible and pass them up

        // Prevents concurrent passing up of messages by different threads (http://jira.jboss.com/jira/browse/JGRP-198);
        // this is all the more important once we have a concurrent stack (http://jira.jboss.com/jira/browse/JGRP-181),
        // where lots of threads can come up to this point concurrently, but only 1 is allowed to pass at a time
        // We *can* deliver messages from *different* senders concurrently, e.g. reception of P1, Q1, P2, Q2 can result in
        // delivery of P1, Q1, Q2, P2: FIFO (implemented by UNICAST) says messages need to be delivered only in the
        // order in which they were sent by their senders
        boolean released_processing=false;
        try {
            while(true) {
                List<Message> msgs=win.removeMany(processing, true, max_msg_batch_size); // remove my own messages
                if(msgs == null || msgs.isEmpty()) {
                    released_processing=true;
                    return;
                }

View Full Code Here

        System.out.println("sending " + seqnos.size() + " msgs (including duplicates); size excluding duplicates=" +
                no_duplicates.size());

        // we need to add our own messages (nak is for C1), or else they will get discarded by NAKACK.handleMessage()
        NakReceiverWindow win=nak.getWindow(c1);
        for(int i=1; i <= NUM_MSGS; i++)
            win.add(i, msg(c1, i, i, true));

        for(int i: seqnos) {
            boolean oob=Util.tossWeightedCoin(0.5);
            pool.execute(new Sender(c2, i, i, oob));
            pool.execute(new Sender(c1, i, i, oob));
View Full Code Here


    @Test(dataProvider="createTimer")
    public void test1(TimeScheduler timer) throws Exception {
        try {
            NakReceiverWindow win=new NakReceiverWindow(sender, cmd, 1, timer);
            check(win, 0, 1, 1);
            assert win.get(23) == null;
        }
        finally {
            timer.stop();
        }
    }
View Full Code Here

TOP

Related Classes of org.jgroups.stack.NakReceiverWindow

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.