try { if(trace) { long stop=System.currentTimeMillis(); double percentage=100.0 / max_bundle_size * count; StringBuffer sb=new StringBuffer("sending ").append(num_msgs).append(" msgs ("); sb.append(count).append(" bytes (" + f.format(percentage) + "% of max_bundle_size), collected in "+ + (stop-start) + "ms) to ").append(msgs.size()). append(" destination(s)"); if(msgs.size() > 1) sb.append(" (dests=").append(msgs.keySet()).append(")"); log.trace(sb.toString()); } boolean multicast; for(Iterator it=msgs.entrySet().iterator(); it.hasNext();) { entry=(Map.Entry)it.next(); l=(List)entry.getValue(); if(l.size() == 0) continue; dst=(Address)entry.getKey(); multicast=dst == null || dst.isMulticastAddress(); synchronized(out_stream) { try { buffer=listToBuffer(l, multicast); doSend(buffer, dst, multicast); } catch(Throwable e) { if(log.isErrorEnabled()) log.error("exception sending msg", e); }
try {  boolean multicast; for(Iterator it=copy.entrySet().iterator(); it.hasNext();) { entry=(Map.Entry)it.next(); l=(List)entry.getValue(); if(l.size() == 0) continue; dst=(Address)entry.getKey(); multicast=dst == null || dst.isMulticastAddress(); synchronized(out_stream) { try { buffer=listToBuffer(l, multicast); doSend(buffer, dst, multicast); } catch(Throwable e) { if(log.isErrorEnabled()) log.error("exception sending msg", e);
        private void bundleAndSend() {            Map.Entry      entry;            Address        dst;            Buffer         buffer;            List           l;            synchronized(msgs) {                if(msgs.size() == 0)                    return;                try {                    if(trace) {                        long stop=System.currentTimeMillis();                        double percentage=100.0 / max_bundle_size * count;                        StringBuffer sb=new StringBuffer("sending ").append(num_msgs).append(" msgs (");                        sb.append(count).append(" bytes (" + f.format(percentage) + "% of max_bundle_size), collected in "+                                + (stop-start) + "ms) to ").append(msgs.size()).                                append(" destination(s)");                        if(msgs.size() > 1) sb.append(" (dests=").append(msgs.keySet()).append(")");                        log.trace(sb.toString());                    }                    boolean multicast;                    for(Iterator it=msgs.entrySet().iterator(); it.hasNext();) {                        entry=(Map.Entry)it.next();                        l=(List)entry.getValue();                        if(l.size() == 0)                            continue;                        dst=(Address)entry.getKey();                        multicast=dst == null || dst.isMulticastAddress();                        synchronized(out_stream) {                            try {                                buffer=listToBuffer(l, multicast);                                doSend(buffer, dst, multicast);                            }                            catch(Throwable e) {                                if(log.isErrorEnabled()) log.error("exception sending msg", e);                            }                        }                    }                }                finally {                    msgs.clear();                    num_msgs=0;                    start=0;                    count=0;                }            }        }