Package org.jgroups.protocols
Class RingBufferBundlerLockless2
java.lang.Object
org.jgroups.protocols.BaseBundler
org.jgroups.protocols.RingBufferBundlerLockless2
- All Implemented Interfaces:
Bundler
Lockless bundler using a reader thread which is unparked by (exactly one) writer thread.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicLongprotected Message[]protected Runnerstatic final Messageprotected final AtomicIntegerprotected final AtomicIntegerprotected intprotected final Runnableprotected static final Stringprotected final AtomicBooleanprotected final AtomicIntegerFields inherited from class org.jgroups.protocols.BaseBundler
avg_send_time, capacity, count, lock, log, max_size, msgs, output, transport -
Constructor Summary
ConstructorsConstructorDescriptionRingBufferBundlerLockless2(int capacity) RingBufferBundlerLockless2(int capacity, boolean padded) -
Method Summary
Modifier and TypeMethodDescriptionintprotected int_size(int ri, int wi) protected booleanadvanceReadIndex(int wi) protected static intassertPositive(int value, String message) intIf 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 intgetWriteIndex(int current_read_index) protected final intincrement(int index) protected final intindex(int idx) voidCalled after creation of the bundlerprotected intmarshalMessagesToSameDestination(Address dest, Message[] buf, int start_index, int end_index, int max_bundle_size) intprotected voidvoidreset()voidprotected intsendBundledMessages(Message[] buf, int read_index, int write_index) Read and send messages in range [read-index+1 ..intsize()Returns the total number of messages in the hashmapvoidstart()Called afterBundler.init(TP)voidstop()toString()protected voidunparkIfNeeded(int size) intMethods inherited from class org.jgroups.protocols.BaseBundler
addMessage, getCapacity, getMaxSize, resetStats, sendBundledMessages, sendMessageList, sendSingleMessage, setCapacity, setMaxSize, viewChange
-
Field Details
-
buf
-
read_index
-
ri
protected int ri -
write_index
-
accumulated_bytes
-
num_threads
-
unparking
-
bundler_thread
-
run_function
-
THREAD_NAME
-
NULL_MSG
-
-
Constructor Details
-
RingBufferBundlerLockless2
public RingBufferBundlerLockless2() -
RingBufferBundlerLockless2
public RingBufferBundlerLockless2(int capacity) -
RingBufferBundlerLockless2
public RingBufferBundlerLockless2(int capacity, boolean padded)
-
-
Method Details
-
readIndex
public int readIndex() -
writeIndex
public int writeIndex() -
reset
-
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
-
size
public int size()Description copied from class:BaseBundlerReturns the total number of messages in the hashmap- Specified by:
sizein interfaceBundler- Overrides:
sizein classBaseBundler
-
_size
protected int _size(int ri, int wi) -
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
-
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
-
toString
-
unparkIfNeeded
protected void unparkIfNeeded(int size) -
getWriteIndex
protected int getWriteIndex(int current_read_index) -
_readMessages
public int _readMessages() -
advanceReadIndex
protected boolean advanceReadIndex(int wi) -
readMessages
protected void readMessages() -
sendBundledMessages
Read and send messages in range [read-index+1 .. write_index-1] -
marshalMessagesToSameDestination
protected int marshalMessagesToSameDestination(Address dest, Message[] buf, int start_index, int end_index, int max_bundle_size) throws Exception - Throws:
Exception
-
increment
protected final int increment(int index) -
index
protected final int index(int idx) -
assertPositive
-