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
public abstract class BaseBundler extends java.lang.Object implements Bundler
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
- Author:
- Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected long
count
protected java.util.concurrent.locks.ReentrantLock
lock
protected Log
log
protected java.util.Map<Address,java.util.List<Message>>
msgs
Keys are destinations, values are lists of Messagesprotected ByteArrayDataOutputStream
output
protected TP
transport
-
Constructor Summary
Constructors Constructor Description BaseBundler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addMessage(Message msg, long size)
protected void
clearMessages()
void
init(TP transport)
Called after creation of the bundlervoid
send(Message msg)
protected void
sendBundledMessages()
Sends all messages in the map.protected void
sendMessageList(Address dest, Address src, java.util.List<Message> list)
protected void
sendSingleMessage(Message msg)
int
size()
Returns the total number of messages in the hashmapvoid
start()
Called afterBundler.init(TP)
void
stop()
void
viewChange(View view)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jgroups.protocols.Bundler
getQueueSize, getStats, resetStats
-
-
-
-
Field Detail
-
msgs
protected final java.util.Map<Address,java.util.List<Message>> msgs
Keys are destinations, values are lists of Messages
-
transport
protected TP transport
-
lock
protected final java.util.concurrent.locks.ReentrantLock lock
-
count
protected long count
-
output
protected ByteArrayDataOutputStream output
-
log
protected Log log
-
-
Method Detail
-
init
public void init(TP transport)
Description copied from interface:Bundler
Called after creation of the bundler
-
start
public void start()
Description copied from interface:Bundler
Called afterBundler.init(TP)
-
send
public void send(Message msg) throws java.lang.Exception
-
viewChange
public void viewChange(View view)
- Specified by:
viewChange
in interfaceBundler
-
size
public int size()
Returns the total number of messages in the hashmap
-
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.
-
clearMessages
protected void clearMessages()
-
sendSingleMessage
protected void sendSingleMessage(Message msg)
-
sendMessageList
protected void sendMessageList(Address dest, Address src, java.util.List<Message> list)
-
addMessage
protected void addMessage(Message msg, long size)
-
-