Package org.jgroups.protocols
Class RingBufferBundlerLockless
java.lang.Object
org.jgroups.protocols.BaseBundler
org.jgroups.protocols.RingBufferBundlerLockless
- All Implemented Interfaces:
Bundler
Bundler which doesn't use locks but relies on CAS. There is 1 reader thread which gets unparked by (exactly one) writer
when the max size has been exceeded, or no other threads are sending messages.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicLongprotected Message[]protected Runnerprotected final AtomicIntegerprotected intprotected final Runnableprotected final AtomicIntegerprotected static final Stringprotected final AtomicIntegerprotected final AtomicBooleanprotected intprotected final AtomicIntegerFields inherited from class org.jgroups.protocols.BaseBundler
avg_send_time, capacity, count, lock, log, max_size, msgs, output, transport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintprotected intprotected static intassertPositive(int value, String message) protected intintIf 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.protected intprotected final intincrement(int index) protected final intindex(int idx) voidCalled after creation of the bundlerprotected intmarshalMessagesToSameDestination(Address dest, Message[] buf, int start_index, int available_msgs, int max_bundle_size) intprotected voidvoidvoidreset()voidprotected intsendBundledMessages(Message[] buf, int read_index, int available_msgs) Read and send messages in range [read-index ..intsize()Returns the total number of messages in the hashmapvoidstart()Called afterBundler.init(TP)voidstop()toString()intMethods inherited from class org.jgroups.protocols.BaseBundler
addMessage, getCapacity, getMaxSize, resetStats, sendBundledMessages, sendMessageList, sendSingleMessage, setCapacity, setMaxSize, viewChange
-
Field Details
-
buf
-
read_index
protected int read_index -
write_index
protected volatile int write_index -
tmp_write_index
-
write_permits
-
size
-
num_threads
-
accumulated_bytes
-
unparking
-
bundler_thread
-
THREAD_NAME
- See Also:
-
run_function
-
-
Constructor Details
-
RingBufferBundlerLockless
public RingBufferBundlerLockless() -
RingBufferBundlerLockless
public RingBufferBundlerLockless(int capacity)
-
-
Method Details
-
readIndex
public int readIndex() -
writeIndex
public int writeIndex() -
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- Overrides:
getQueueSizein classBaseBundler
-
init
Description copied from interface:BundlerCalled after creation of the bundler- Specified by:
initin interfaceBundler- Overrides:
initin classBaseBundler- Parameters:
transport- the transport, for further reference
-
reset
public void reset() -
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
-
renameThread
public void renameThread() -
send
- Specified by:
sendin interfaceBundler- Overrides:
sendin classBaseBundler- Throws:
Exception
-
getWriteIndex
protected int getWriteIndex() -
getPermitToWrite
protected int getPermitToWrite() -
advanceWriteIndex
protected int advanceWriteIndex() -
readMessages
protected void readMessages() -
sendBundledMessages
Read and send messages in range [read-index .. read-index+available_msgs-1] -
toString
-
_readMessages
public int _readMessages() -
marshalMessagesToSameDestination
protected int marshalMessagesToSameDestination(Address dest, Message[] buf, int start_index, int available_msgs, int max_bundle_size) throws Exception - Throws:
Exception
-
increment
protected final int increment(int index) -
index
protected final int index(int idx) -
assertPositive
-