public MessageBatch add(final Message msg) { add(msg, true); return this; }
public MessageBatch add(final MessageBatch batch) { add(batch, true); return this; }
protected boolean allowedToSubmitToThreadPool(MessageBatch msg_batch) { lock.lock(); try { if(!running) return running=true; // the caller can submit a new BatchHandlerLoop task to the thread pool this.batch.add(msg_batch, resize); queued_batches.increment(); return false; } finally { lock.unlock(); } }
/** * Either allows access to submit a task to the thread pool for delivery to the application, or queues the * message * @param msg the message * @return true if the message can be submitted to the thread pool, or false (msg was queued) */ protected boolean allowedToSubmitToThreadPool(Message msg) { lock.lock(); try { if(!running) return running=true; // the caller can submit a new BatchHandlerLoop task to the thread pool this.batch.add(msg, resize); queued_msgs.increment(); return false; } finally { lock.unlock(); } }
protected void submit(Message msg, boolean loopback) { // running is true, we didn't queue msg and need to submit a task to the thread pool try { submitted_msgs.increment(); BatchHandlerLoop handler=new BatchHandlerLoop(batch_creator.apply(16).add(msg), this, loopback); if(!tp.submitToThreadPool(handler, false)) setRunning(false); } catch(Throwable t) { setRunning(false); } }
protected void submit(MessageBatch mb) { try { submitted_batches.increment(); BatchHandlerLoop handler=new BatchHandlerLoop(batch_creator.apply(mb.size()).add(mb), this, false); if(!tp.submitToThreadPool(handler, false)) setRunning(false); } catch(Throwable t) { setRunning(false); } }
protected void handleBatchReceived(final ReceiverEntry entry, Address sender, List<LongTuple<Message>> msgs, boolean oob) { if(is_trace) log.trace("%s <-- DATA(%s: %s)", local_addr, sender, printMessageList(msgs)); int batch_size=msgs.size(); Table<Message> win=entry.msgs; // adds all messages to the table, removing messages from 'msgs' which could not be added (already present) boolean added=win.add(msgs, oob, oob? DUMMY_OOB_MSG : null); update(entry, batch_size); if(batch_size >= ack_threshold) sendAck(sender, win.getHighestDeliverable(), entry.connId()); else entry.sendAck(true); // OOB msg is passed up. When removed, we discard it. Affects ordering: http://jira.jboss.com/jira/browse/JGRP-379 if(added && oob) { MessageBatch oob_batch=new MessageBatch(local_addr, sender, null, false, MessageBatch.Mode.OOB, msgs.size()); for(LongTuple<Message> tuple: msgs) oob_batch.add(tuple.getVal2()); deliverBatch(oob_batch); } removeAndDeliver(win, sender); }
oob_batch.add(msg);
batches[index].add(msg);
public MessageBatch add(final Message msg) { add(msg, true); return this; }
public MessageBatch add(final MessageBatch batch) { add(batch, true); return this; }
protected boolean allowedToSubmitToThreadPool(MessageBatch msg_batch) { lock.lock(); try { if(!running) return running=true; // the caller can submit a new BatchHandlerLoop task to the thread pool this.batch.add(msg_batch, resize); queued_batches.increment(); return false; } finally { lock.unlock(); } }
/** * Either allows access to submit a task to the thread pool for delivery to the application, or queues the * message * @param msg the message * @return true if the message can be submitted to the thread pool, or false (msg was queued) */ protected boolean allowedToSubmitToThreadPool(Message msg) { lock.lock(); try { if(!running) return running=true; // the caller can submit a new BatchHandlerLoop task to the thread pool this.batch.add(msg, resize); queued_msgs.increment(); return false; } finally { lock.unlock(); } }
protected void submit(Message msg, boolean loopback) { // running is true, we didn't queue msg and need to submit a task to the thread pool try { submitted_msgs.increment(); BatchHandlerLoop handler=new BatchHandlerLoop(batch_creator.apply(16).add(msg), this, loopback); if(!tp.submitToThreadPool(handler, false)) setRunning(false); } catch(Throwable t) { setRunning(false); } }
protected void submit(MessageBatch mb) { try { submitted_batches.increment(); BatchHandlerLoop handler=new BatchHandlerLoop(batch_creator.apply(mb.size()).add(mb), this, false); if(!tp.submitToThreadPool(handler, false)) setRunning(false); } catch(Throwable t) { setRunning(false); } }
protected void handleBatchReceived(final ReceiverEntry entry, Address sender, List<LongTuple<Message>> msgs, boolean oob) { if(is_trace) log.trace("%s <-- DATA(%s: %s)", local_addr, sender, printMessageList(msgs)); int batch_size=msgs.size(); Table<Message> win=entry.msgs; // adds all messages to the table, removing messages from 'msgs' which could not be added (already present) boolean added=win.add(msgs, oob, oob? DUMMY_OOB_MSG : null); update(entry, batch_size); if(batch_size >= ack_threshold) sendAck(sender, win.getHighestDeliverable(), entry.connId()); else entry.sendAck(true); // OOB msg is passed up. When removed, we discard it. Affects ordering: http://jira.jboss.com/jira/browse/JGRP-379 if(added && oob) { MessageBatch oob_batch=new MessageBatch(local_addr, sender, null, false, MessageBatch.Mode.OOB, msgs.size()); for(LongTuple<Message> tuple: msgs) oob_batch.add(tuple.getVal2()); deliverBatch(oob_batch); } removeAndDeliver(win, sender); }
batches[index].add(msg);
oob_batch.add(msg);