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 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
  • Field Details

    • msgs

      protected final Map<Address,List<Message>> msgs
      Keys are destinations, values are lists of Messages
    • transport

      protected TP transport
    • lock

      protected final ReentrantLock lock
    • count

      protected long count
    • output

      protected ByteArrayDataOutputStream output
    • log

      protected Log log
    • max_size

      protected int max_size
      Maximum number of bytes for messages to be queued until they are sent. This value needs to be smaller than the largest datagram packet size in case of UDP
    • capacity

      protected int capacity
    • avg_send_time

      protected final AverageMinMax avg_send_time
  • Constructor Details

    • BaseBundler

      public BaseBundler()
  • Method Details

    • getCapacity

      public int getCapacity()
      Description copied from interface: Bundler
      If the bundler implementation supports a capacity (e.g. RingBufferBundler, then return it, else return -1
      Specified by:
      getCapacity in interface Bundler
    • setCapacity

      public Bundler setCapacity(int c)
    • getMaxSize

      public int getMaxSize()
      Description copied from interface: Bundler
      Maximum number of bytes for messages to be queued until they are sent
      Specified by:
      getMaxSize in interface Bundler
    • setMaxSize

      public Bundler setMaxSize(int s)
      Specified by:
      setMaxSize in interface Bundler
    • init

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

      public void resetStats()
      Specified by:
      resetStats in interface Bundler
    • start

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

      public void stop()
      Specified by:
      stop in interface Bundler
    • send

      public void send(Message msg) throws Exception
      Specified by:
      send in interface Bundler
      Throws:
      Exception
    • viewChange

      public void viewChange(View view)
      Specified by:
      viewChange in interface Bundler
    • size

      public int size()
      Returns the total number of messages in the hashmap
      Specified by:
      size in interface Bundler
    • 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
    • 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.
    • sendSingleMessage

      protected void sendSingleMessage(Message msg)
    • sendMessageList

      protected void sendMessageList(Address dest, Address src, List<Message> list)
    • addMessage

      protected void addMessage(Message msg, int size)