Class RingBufferBundler

java.lang.Object
org.jgroups.protocols.BaseBundler
org.jgroups.protocols.RingBufferBundler
All Implemented Interfaces:
Bundler

public class RingBufferBundler extends BaseBundler
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 Details

  • Constructor Details

    • RingBufferBundler

      public RingBufferBundler()
    • RingBufferBundler

      protected RingBufferBundler(RingBuffer<Message> rb)
    • RingBufferBundler

      public RingBufferBundler(int capacity)
  • Method Details

    • buf

      public RingBuffer<Message> buf()
    • size

      public int size()
      Description copied from class: BaseBundler
      Returns the total number of messages in the hashmap
      Specified by:
      size in interface Bundler
      Overrides:
      size in class BaseBundler
    • getQueueSize

      public int getQueueSize()
      Description copied from interface: Bundler
      If 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:
      getQueueSize in interface Bundler
      Overrides:
      getQueueSize in class BaseBundler
    • numSpins

      public int numSpins()
    • numSpins

      public RingBufferBundler numSpins(int n)
    • waitStrategy

      public String waitStrategy()
    • waitStrategy

      public RingBufferBundler waitStrategy(String st)
    • init

      public void init(TP transport)
      Description copied from interface: Bundler
      Called after creation of the bundler
      Specified by:
      init in interface Bundler
      Overrides:
      init in class BaseBundler
      Parameters:
      transport - the transport, for further reference
    • start

      public void start()
      Description copied from interface: Bundler
      Called after Bundler.init(TP)
      Specified by:
      start in interface Bundler
      Overrides:
      start in class BaseBundler
    • stop

      public void stop()
      Specified by:
      stop in interface Bundler
      Overrides:
      stop in class BaseBundler
    • renameThread

      public void renameThread()
    • send

      public void send(Message msg) throws Exception
      Specified by:
      send in interface Bundler
      Overrides:
      send in class BaseBundler
      Throws:
      Exception
    • sendBundledMessages

      public void sendBundledMessages(Message[] buf, int read_index, int available_msgs)
      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

      protected static String print(BiConsumer<Integer,Integer> wait_strategy)
    • createWaitStrategy

      protected BiConsumer<Integer,Integer> createWaitStrategy(String st, BiConsumer<Integer,Integer> default_wait_strategy)
    • assertPositive

      protected static int assertPositive(int value, String message)