Class MultipleReqBatch

  • All Implemented Interfaces:
    CipMsgProcessor
    Direct Known Subclasses:
    AutoBatchMsgProc

    public class MultipleReqBatch
    extends java.lang.Object
    implements CipMsgProcessor
    Perform size-based accumulation of CIP Requests into batches using MultipleReq. When a requested is "sent", if it will fit in both the current send buffer and the current reply buffer, it will be queued instead of sent downstream. When a new request won't fit, the queue is flushed downstream as a single request, then the pending request is rechecked.

    Requests that don't fit the buffer at all will be sent solo. If strict order is requested, the queue will be flushed before sending such.

    The creator of this batching processor is expected to call flush() after the last requested is queued.

    Proper operation depends on all submitted requests having a reply size forecast that covers the maximum reply possible. Requests that do not have a forecast will be treated as oversize.

    • Field Detail

      • sLogger

        public static final org.slf4j.Logger sLogger
      • strictOrder

        protected final boolean strictOrder
      • capacity

        protected final int capacity
      • bypassThreshold

        protected final int bypassThreshold
      • reqThreshold

        protected double reqThreshold
      • rspThreshold

        protected double rspThreshold
      • capacityReserve

        protected double capacityReserve
      • reqRemain

        protected int reqRemain
      • rspRemain

        protected int rspRemain
      • innerRequests

        protected final java.util.LinkedList<CipRequest> innerRequests
      • batchSupported

        public boolean batchSupported
    • Constructor Detail

      • MultipleReqBatch

        public MultipleReqBatch​(CipMsgProcessor cx,
                                boolean strictOrder)
        Create a batching processor, with or without strict ordering.
        Parameters:
        cx - The downstream message processor.
        strictOrder - Whether to continuing queuing small requests when oversize requests are submitted. If false, requests can be passed downstream out of order for optimization.
    • Method Detail

      • getCapacityReserve

        public double getCapacityReserve()
      • setCapacityReserve

        public void setCapacityReserve​(double capacityReserve)
      • resetRemaining

        protected void resetRemaining()
      • outerSend

        protected void outerSend​(CipRequest req)
      • flush

        public void flush()
      • send

        public void send​(CipRequest req)
        Queue or send a request. If it fits with other requests, it will be queued to assemble into a multiple request. Otherwise it will be sent directly downstream.
        Specified by:
        send in interface CipMsgProcessor
        Parameters:
        req -
      • getMaxMsg

        public int getMaxMsg()
        Description copied from interface: CipMsgProcessor
        Return this message processor's max allowed message size in bytes. Applies to both request and reply.
        Specified by:
        getMaxMsg in interface CipMsgProcessor
        Returns:
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable