Class BaseBundler

java.lang.Object
org.jgroups.protocols.BaseBundler
All Implemented Interfaces:
Bundler
Direct Known Subclasses:
NoBundler, PerDestinationBundler, 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
Author:
Bela Ban
  • Field Details

    • msgs

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

      protected final Function<Address, List<Message>> FUNC
    • transport

      protected TP transport
    • msg_processing_policy

      protected MessageProcessingPolicy msg_processing_policy
    • lock

      protected final ReentrantLock lock
    • count

      protected long count
    • output

      protected ByteBufferOutputStream output
    • msg_stats

      protected MsgStats msg_stats
    • log

      protected Log log
    • suppress_log

      protected SuppressLog<Address> suppress_log
    • FMT

      protected static final String FMT
      See Also:
    • 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
    • remove_queue_capacity

      protected int remove_queue_capacity
    • use_ringbuffer

      protected boolean use_ringbuffer
    • use_single_sender_thread

      protected boolean use_single_sender_thread
    • drop_when_full

      @Deprecated(since="5.5.0", forRemoval=true) protected boolean drop_when_full
      Deprecated, for removal: This API element is subject to removal in a future version.
    • suppress_log_timeout

      protected long suppress_log_timeout
    • remove_delay

      protected long remove_delay
    • avg_fill_count

      protected final AverageMinMax avg_fill_count
    • avg_remove_queue_size

      protected final AverageMinMax avg_remove_queue_size
    • avg_send_time

      protected final AverageMinMax avg_send_time
    • total_msgs_sent

      protected final LongAdder total_msgs_sent
    • num_single_msgs_sent

      protected final LongAdder num_single_msgs_sent
    • num_batches_sent

      protected final LongAdder num_batches_sent
    • num_sends_because_full_queue

      protected final LongAdder num_sends_because_full_queue
    • num_sends_because_no_msgs

      protected final LongAdder num_sends_because_no_msgs
    • num_drops_on_full_queue

      protected final LongAdder num_drops_on_full_queue
    • members

      protected volatile List<Address> members
  • Constructor Details

    • BaseBundler

      public BaseBundler()
  • Method Details

    • printBuffers

      public String printBuffers()
    • getCapacity

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

      public Bundler setCapacity(int c)
    • removeQueueCapacity

      public int removeQueueCapacity()
    • removeQueueCapacity

      public Bundler removeQueueCapacity(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
    • dropWhenFull

      public boolean dropWhenFull()
    • dropWhenFull

      public Bundler dropWhenFull(boolean ignored)
    • useSingleSenderThread

      public boolean useSingleSenderThread()
    • useSingleSenderThread

      public Bundler useSingleSenderThread(boolean u)
    • useRingBuffer

      public boolean useRingBuffer()
    • useRingBuffer

      public Bundler useRingBuffer(boolean u)
    • suppressLogTimeout

      public long suppressLogTimeout()
    • suppressLogTimeout

      public void suppressLogTimeout(long s)
    • removeDelay

      public long removeDelay()
    • removeDelay

      public Bundler removeDelay(long remove_delay)
    • avgBatchSize

      public double avgBatchSize()
    • 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.
    • sendSingle

      protected void sendSingle(Address dst, Message msg, ByteBufferOutputStream out) throws Exception
      Throws:
      Exception
    • sendMultiple

      protected void sendMultiple(Address dst, Address sender, List<Message> list, ByteBufferOutputStream out) throws Exception
      Throws:
      Exception
    • loopbackUnlessDontLoopbackIsSet

      protected void loopbackUnlessDontLoopbackIsSet(Message msg)
    • loopback

      protected void loopback(Address dest, Address sender, Iterable<Message> list, int size)
    • loopback

      protected void loopback(Address dest, Address sender, Message[] list, int len)
    • sendSingleMessage

      protected void sendSingleMessage(Address dest, Message msg, ByteBufferOutputStream out) throws Exception
      Throws:
      Exception
    • sendMessageList

      protected void sendMessageList(Address dest, Address src, List<Message> list, ByteBufferOutputStream out) throws Exception
      Throws:
      Exception
    • addMessage

      protected void addMessage(Message msg, int size)