Class MultipleReqBatch
- java.lang.Object
-
- com.automation_pros.odva.cip.requests.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 usingMultipleReq
. 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 Summary
Fields Modifier and Type Field Description boolean
batchSupported
protected int
bypassThreshold
protected int
capacity
protected double
capacityReserve
protected CipMsgProcessor
cx
protected java.util.LinkedList<CipRequest>
innerRequests
protected int
reqRemain
protected double
reqThreshold
protected int
rspRemain
protected double
rspThreshold
static org.slf4j.Logger
sLogger
protected boolean
strictOrder
-
Constructor Summary
Constructors Constructor Description MultipleReqBatch(CipMsgProcessor cx, boolean strictOrder)
Create a batching processor, with or without strict ordering.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
finalize()
void
flush()
double
getCapacityReserve()
int
getMaxMsg()
Return this message processor's max allowed message size in bytes.protected void
outerSend(CipRequest req)
protected void
resetRemaining()
void
send(CipRequest req)
Queue or send a request.void
setCapacityReserve(double capacityReserve)
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.automation_pros.odva.cip.types.CipMsgProcessor
send
-
-
-
-
Field Detail
-
sLogger
public static final org.slf4j.Logger sLogger
-
cx
protected final CipMsgProcessor cx
-
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 interfaceCipMsgProcessor
- 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 interfaceCipMsgProcessor
- Returns:
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
-