Package org.jgroups.protocols
Class RingBufferBundler
java.lang.Object
org.jgroups.protocols.BaseBundler
org.jgroups.protocols.RingBufferBundler
- All Implemented Interfaces:
Bundler
Bundler which uses
RingBuffer to store messages. The difference to TransferQueueBundler is that
RingBuffer uses a wait strategy (to for example spinning) before blocking. Also, the hashmap of the superclass is not
used, but the array of the RingBuffer is used directly to bundle and send messages, minimizing memory allocation.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Runnerprotected intprotected static final BiConsumer<Integer, Integer> protected RingBuffer<Message> protected final Runnableprotected static final BiConsumer<Integer, Integer> protected static final BiConsumer<Integer, Integer> protected static final BiConsumer<Integer, Integer> protected static final Stringprotected BiConsumer<Integer, Integer> protected static final BiConsumer<Integer, Integer> Fields 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 TypeMethodDescriptionprotected final intadvance(int index) protected static intassertPositive(int value, String message) buf()protected BiConsumer<Integer, Integer> createWaitStrategy(String st, BiConsumer<Integer, Integer> default_wait_strategy) 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 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) intnumSpins()numSpins(int n) protected static Stringprint(BiConsumer<Integer, Integer> wait_strategy) protected voidvoidvoidvoidsendBundledMessages(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()waitStrategy(String st) Methods inherited from class org.jgroups.protocols.BaseBundler
addMessage, getCapacity, getMaxSize, resetStats, sendBundledMessages, sendMessageList, sendSingleMessage, setCapacity, setMaxSize, viewChange
-
Field Details
-
rb
-
bundler_thread
-
num_spins
protected int num_spins -
THREAD_NAME
- See Also:
-
wait_strategy
-
run_function
-
SPIN
-
YIELD
-
PARK
-
SPIN_PARK
-
SPIN_YIELD
-
-
Constructor Details
-
RingBufferBundler
public RingBufferBundler() -
RingBufferBundler
-
RingBufferBundler
public RingBufferBundler(int capacity)
-
-
Method Details
-
buf
-
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
-
numSpins
public int numSpins() -
numSpins
-
waitStrategy
-
waitStrategy
-
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
-
sendBundledMessages
Read and send messages in range [read-index .. read-index+available_msgs-1] -
marshalMessagesToSameDestination
protected int marshalMessagesToSameDestination(Address dest, Message[] buf, int start_index, int end_index, int max_bundle_size) throws Exception - Throws:
Exception
-
readMessages
protected void readMessages() -
advance
protected final int advance(int index) -
index
protected final int index(int idx) -
print
-
createWaitStrategy
protected BiConsumer<Integer,Integer> createWaitStrategy(String st, BiConsumer<Integer, Integer> default_wait_strategy) -
assertPositive
-