protected void handleAckReceived(Address sender, long seqno, short conn_id) { if (log.isTraceEnabled()) log.trace( new StringBuilder() .append(local_addr) .append(" <-- ACK(") .append(sender) .append(": #") .append(seqno) .append(", conn-id=") .append(conn_id) .append(')')); SenderEntry entry = send_table.get(sender); if (entry != null && entry.send_conn_id != conn_id) { if (log.isTraceEnabled()) log.trace( local_addr + ": my conn_id (" + entry.send_conn_id + ") != received conn_id (" + conn_id + "); discarding ACK"); return; } Table<Message> win = entry != null ? entry.sent_msgs : null; if (win != null) { win.purge(seqno, true); // removes all messages <= seqno (forced purge) num_acks_received++; } }
/** * Purge all messages in window for local_addr, which are <= low. Check if the window's highest * received message is > high: if true, retransmit all messages from high - win.high to sender * * @param sender * @param hd Highest delivered seqno * @param hr Highest received seqno */ protected void stable(Address sender, short conn_id, long hd, long hr) { SenderEntry entry = send_table.get(sender); Table<Message> win = entry != null ? entry.sent_msgs : null; if (win == null) return; if (log.isTraceEnabled()) log.trace( new StringBuilder() .append(local_addr) .append(" <-- STABLE(") .append(sender) .append(": ") .append(hd) .append("-") .append(hr) .append(", conn_id=" + conn_id) + ")"); if (entry.send_conn_id != conn_id) { log.warn( local_addr + ": my conn_id (" + entry.send_conn_id + ") != received conn_id (" + conn_id + "); discarding STABLE message !"); return; } win.purge(hd, true); long win_hr = win.getHighestReceived(); if (win_hr > hr) { for (long seqno = hr; seqno <= win_hr; seqno++) { Message msg = win.get( seqno); // destination is still the same (the member which sent the STABLE message) if (msg != null) down_prot.down(new Event(Event.MSG, msg)); } } }