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
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.redhat.com/browse/JGRP-1540
-
-
Field Summary
Fields Modifier and Type Field Description protected AverageMinMax
avg_fill_count
protected java.lang.Thread
bundler_thread
protected boolean
drop_when_full
protected long
num_drops_on_full_queue
protected long
num_sends_because_full_queue
protected long
num_sends_because_no_msgs
protected java.util.concurrent.BlockingQueue<Message>
queue
protected java.util.List<Message>
remove_queue
protected boolean
running
protected static java.lang.String
THREAD_NAME
-
Fields inherited from class org.jgroups.protocols.BaseBundler
avg_send_time, capacity, count, FUNC, lock, log, max_size, msg_processing_policy, msg_stats, msgs, output, transport
-
-
Constructor Summary
Constructors Constructor Description TransferQueueBundler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addAndSendIfSizeExceeded(Message msg)
protected void
drain()
Takes all messages from the queue, adds them to the hashmap and then sends all bundled messagesboolean
dropWhenFull()
<T extends Bundler>
TdropWhenFull(boolean d)
int
getQueueSize()
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.void
init(TP tp)
Called after creation of the bundlerint
removeQueueCapacity()
int
removeQueueSize()
void
renameThread()
void
resetStats()
void
run()
void
send(Message msg)
int
size()
Returns the total number of messages in the hashmapvoid
start()
Called afterBundler.init(TP)
void
stop()
-
Methods inherited from class org.jgroups.protocols.BaseBundler
addMessage, getCapacity, getMaxSize, loopback, loopback, loopbackUnlessDontLoopbackIsSet, printBuffers, sendBundledMessages, sendMessageList, sendMessageList, sendMultiple, sendMultiple, sendSingle, sendSingleMessage, setCapacity, setMaxSize, viewChange
-
-
-
-
Field Detail
-
queue
protected java.util.concurrent.BlockingQueue<Message> queue
-
remove_queue
protected final 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
-
-
Method Detail
-
getQueueSize
public int getQueueSize()
Description copied from interface:Bundler
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. 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:
getQueueSize
in interfaceBundler
- Overrides:
getQueueSize
in classBaseBundler
-
removeQueueSize
public int removeQueueSize()
-
removeQueueCapacity
public int removeQueueCapacity()
-
dropWhenFull
public boolean dropWhenFull()
-
dropWhenFull
public <T extends Bundler> T dropWhenFull(boolean d)
-
resetStats
public void resetStats()
- Specified by:
resetStats
in interfaceBundler
- Overrides:
resetStats
in classBaseBundler
-
init
public void init(TP tp)
Description copied from interface:Bundler
Called after creation of the bundler- Specified by:
init
in interfaceBundler
- Overrides:
init
in classBaseBundler
- Parameters:
tp
- the transport, for further reference
-
start
public void start()
Description copied from interface:Bundler
Called afterBundler.init(TP)
- Specified by:
start
in interfaceBundler
- Overrides:
start
in classBaseBundler
-
stop
public void stop()
- Specified by:
stop
in interfaceBundler
- Overrides:
stop
in classBaseBundler
-
renameThread
public void renameThread()
- Specified by:
renameThread
in interfaceBundler
-
size
public int size()
Description copied from class:BaseBundler
Returns the total number of messages in the hashmap- Specified by:
size
in interfaceBundler
- Overrides:
size
in classBaseBundler
-
send
public void send(Message msg) throws java.lang.Exception
- Specified by:
send
in interfaceBundler
- Overrides:
send
in classBaseBundler
- Throws:
java.lang.Exception
-
run
public void run()
- Specified by:
run
in 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
-
-