Package org.jgroups.protocols
Class TransferQueueBundler
- java.lang.Object
-
- org.jgroups.protocols.BaseBundler
-
- org.jgroups.protocols.TransferQueueBundler
-
- All Implemented Interfaces:
java.lang.Runnable,Bundler
- Direct Known Subclasses:
AlternatingBundler,SimplifiedTransferQueueBundler
public class TransferQueueBundler extends BaseBundler implements java.lang.Runnable
This bundler adds all (unicast or multicast) messages to a queue until max size has been exceeded, but does send messages immediately when no other messages are available. https://issues.jboss.org/browse/JGRP-1540
-
-
Field Summary
Fields Modifier and Type Field Description protected AverageMinMaxavg_fill_countprotected java.lang.Threadbundler_threadprotected booleandrop_when_fullprotected longnum_drops_on_full_queueprotected longnum_sends_because_full_queueprotected longnum_sends_because_no_msgsprotected java.util.concurrent.BlockingQueue<Message>queueprotected java.util.List<Message>remove_queueprotected booleanrunningprotected static java.lang.StringTHREAD_NAME
-
Constructor Summary
Constructors Modifier Constructor Description TransferQueueBundler()TransferQueueBundler(int capacity)protectedTransferQueueBundler(java.util.concurrent.BlockingQueue<Message> queue)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_addMessage(Message msg, long size)protected void_sendBundledMessages()protected voidaddAndSendIfSizeExceeded(Message msg)protected static intassertPositive(int value, java.lang.String message)protected voiddrain()Takes all messages from the queue, adds them to the hashmap and then sends all bundled messagesintgetBufferSize()booleangetDropWhenFull()intgetQueueSize()If the bundler has a queue and it should be managed by a queuing discipline (like Random Early Detection), then return the number of elements in the queue, else -1.java.util.Map<java.lang.String,java.lang.Object>getStats()Returns stats about the bundler itself.java.lang.ThreadgetThread()voidinit(TP tp)Called after creation of the bundlerintremoveQueueSize()TransferQueueBundlerremoveQueueSize(int size)voidresetStats()voidrun()voidsend(Message msg)TransferQueueBundlersetDropWhenFull(boolean b)intsize()Returns the total number of messages in the hashmapvoidstart()Called afterBundler.init(TP)voidstop()-
Methods inherited from class org.jgroups.protocols.BaseBundler
addMessage, clearMessages, sendBundledMessages, sendMessageList, sendSingleMessage, viewChange
-
-
-
-
Field Detail
-
queue
protected java.util.concurrent.BlockingQueue<Message> queue
-
remove_queue
protected java.util.List<Message> remove_queue
-
bundler_thread
protected volatile java.lang.Thread bundler_thread
-
drop_when_full
protected boolean drop_when_full
-
running
protected volatile boolean running
-
num_sends_because_full_queue
protected long num_sends_because_full_queue
-
num_sends_because_no_msgs
protected long num_sends_because_no_msgs
-
num_drops_on_full_queue
protected long num_drops_on_full_queue
-
avg_fill_count
protected final AverageMinMax avg_fill_count
-
THREAD_NAME
protected static final java.lang.String THREAD_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TransferQueueBundler
public TransferQueueBundler()
-
TransferQueueBundler
protected TransferQueueBundler(java.util.concurrent.BlockingQueue<Message> queue)
-
TransferQueueBundler
public TransferQueueBundler(int capacity)
-
-
Method Detail
-
getThread
public java.lang.Thread getThread()
-
getBufferSize
public int getBufferSize()
-
removeQueueSize
public int removeQueueSize()
-
removeQueueSize
public TransferQueueBundler removeQueueSize(int size)
-
getDropWhenFull
public boolean getDropWhenFull()
-
setDropWhenFull
public TransferQueueBundler setDropWhenFull(boolean b)
-
getStats
public java.util.Map<java.lang.String,java.lang.Object> getStats()
Description copied from interface:BundlerReturns stats about the bundler itself.
-
resetStats
public void resetStats()
- Specified by:
resetStatsin interfaceBundler
-
init
public void init(TP tp)
Description copied from interface:BundlerCalled after creation of the bundler- Specified by:
initin interfaceBundler- Overrides:
initin classBaseBundler- Parameters:
tp- the transport, for further reference
-
start
public void start()
Description copied from interface:BundlerCalled afterBundler.init(TP)- Specified by:
startin interfaceBundler- Overrides:
startin classBaseBundler
-
stop
public void stop()
- Specified by:
stopin interfaceBundler- Overrides:
stopin classBaseBundler
-
size
public int size()
Description copied from class:BaseBundlerReturns the total number of messages in the hashmap- Specified by:
sizein interfaceBundler- Overrides:
sizein classBaseBundler
-
getQueueSize
public int getQueueSize()
Description copied from interface:BundlerIf the bundler has a queue and it should be managed by a queuing discipline (like Random Early Detection), then return the number of elements in the queue, else -1. In the latter case, the queue won't be managed.
This method needs to be fast as it might get called on every message to be sent.- Specified by:
getQueueSizein interfaceBundler
-
send
public void send(Message msg) throws java.lang.Exception
- Specified by:
sendin interfaceBundler- Overrides:
sendin classBaseBundler- Throws:
java.lang.Exception
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
addAndSendIfSizeExceeded
protected void addAndSendIfSizeExceeded(Message msg)
-
drain
protected void drain()
Takes all messages from the queue, adds them to the hashmap and then sends all bundled messages
-
_sendBundledMessages
protected void _sendBundledMessages()
-
_addMessage
protected void _addMessage(Message msg, long size)
-
assertPositive
protected static int assertPositive(int value, java.lang.String message)
-
-