Package org.jgroups.protocols
Class BaseBundler
java.lang.Object
org.jgroups.protocols.BaseBundler
- All Implemented Interfaces:
Bundler
- Direct Known Subclasses:
RemoveQueueBundler,RingBufferBundler,RingBufferBundlerLockless,RingBufferBundlerLockless2,SenderSendsBundler,TransferQueueBundler
Implements storing of messages in a hashmap and sending of single messages and message batches. Most bundler
implementations will want to extend this class
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AverageMinMaxprotected intprotected longprotected final ReentrantLockprotected Logprotected intMaximum number of bytes for messages to be queued until they are sent.Keys are destinations, values are lists of Messagesprotected ByteArrayDataOutputStreamprotected TP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddMessage(Message msg, int size) intIf the bundler implementation supports a capacity (e.g.intMaximum number of bytes for messages to be queued until they are sentintIf 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.voidCalled after creation of the bundlervoidvoidprotected voidSends all messages in the map.protected voidsendMessageList(Address dest, Address src, List<Message> list) protected voidsendSingleMessage(Message msg) setCapacity(int c) setMaxSize(int s) intsize()Returns the total number of messages in the hashmapvoidstart()Called afterBundler.init(TP)voidstop()voidviewChange(View view) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jgroups.protocols.Bundler
renameThread
-
Field Details
-
msgs
Keys are destinations, values are lists of Messages -
transport
-
lock
-
count
protected long count -
output
-
log
-
max_size
protected int max_sizeMaximum number of bytes for messages to be queued until they are sent. This value needs to be smaller than the largest datagram packet size in case of UDP -
capacity
protected int capacity -
avg_send_time
-
-
Constructor Details
-
BaseBundler
public BaseBundler()
-
-
Method Details
-
getCapacity
public int getCapacity()Description copied from interface:BundlerIf the bundler implementation supports a capacity (e.g.RingBufferBundler, then return it, else return -1- Specified by:
getCapacityin interfaceBundler
-
setCapacity
-
getMaxSize
public int getMaxSize()Description copied from interface:BundlerMaximum number of bytes for messages to be queued until they are sent- Specified by:
getMaxSizein interfaceBundler
-
setMaxSize
- Specified by:
setMaxSizein interfaceBundler
-
init
Description copied from interface:BundlerCalled after creation of the bundler -
resetStats
public void resetStats()- Specified by:
resetStatsin interfaceBundler
-
start
public void start()Description copied from interface:BundlerCalled afterBundler.init(TP) -
stop
public void stop() -
send
-
viewChange
- Specified by:
viewChangein interfaceBundler
-
size
public int size()Returns the total number of messages in the hashmap -
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
-
sendBundledMessages
protected void sendBundledMessages()Sends all messages in the map. Messages for the same destination are bundled into a message list. The map will be cleared when done. -
sendSingleMessage
-
sendMessageList
-
addMessage
-