private class BufferSizeManager.StreamInfo
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
BufferSizeManager.StreamInfo.OutputOperation
Container which describes a PUT/DISPLAY operation.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Set<BlockingOperation> |
blockingOperations
The set blocking operations that has been called while the stream
was opened.
|
private java.util.Map<OutputOperationType,java.lang.Integer> |
closeLimits
Buffer sizes (which correspond the current stream state) for a close
action for different output operation types.
|
private java.util.Map<OutputOperationType,java.lang.Integer> |
flushLimits
Buffer sizes (which correspond the current stream state) for a flush
action for different output operation types.
|
private int |
maxCalcutatedIndex
Maximum element (inclusive index) of
outputOperations
array that has already been added to tempPseudoBytes . |
private int |
maxCloseLimit
Maximum buffer size among the values contained into
closeLimits map. |
private int |
maxFlushLimit
Maximum buffer size among the values contained into
flushLimits map. |
private java.util.List<BufferSizeManager.StreamInfo.OutputOperation> |
outputOperations
The list of output operations that has been performed using the
corresponding stream.
|
private boolean |
pendingRefresh
Indicates whether the contained information should be refreshed
because of changes into the stream state.
|
private ProcessStream |
stream
The stream to which this information relates.
|
private int |
tempPseudoBytes
Cached sum of pseudo-bytes that have been written.
|
Constructor and Description |
---|
StreamInfo(ProcessStream stream)
Default c'tor.
|
Modifier and Type | Method and Description |
---|---|
private int |
calculatePseudoBytesWritten(java.util.Map<OutputOperationType,java.lang.Integer> operationsMap,
int maxValue)
Calculates the number of pseudo-bytes written through this stream.
|
java.util.Set<BlockingOperation> |
getBlockingOperations()
Get the set of blocking operation that has been performed while the
stream was open.
|
void |
notifyBlockingOperation(BlockingOperation blockingOperation)
Notify that a blocking operation has been performed while this stream
was open.
|
void |
notifyOutputOperation(OutputOperationType type,
int bytes)
Notify that an output operation has been performed using this stream.
|
private void |
refreshInformation()
Refresh the contained information according to the current stream
state.
|
boolean |
shouldRaiseStop(boolean close)
Determine whether the stream has exceeded the buffer size and the
STOP condition should be raised.
|
private ProcessStream stream
private java.util.Set<BlockingOperation> blockingOperations
private java.util.Map<OutputOperationType,java.lang.Integer> flushLimits
private java.util.Map<OutputOperationType,java.lang.Integer> closeLimits
private int maxFlushLimit
flushLimits
map.private int maxCloseLimit
closeLimits
map.private java.util.List<BufferSizeManager.StreamInfo.OutputOperation> outputOperations
private boolean pendingRefresh
private int tempPseudoBytes
calculatePseudoBytesWritten(java.util.Map, int)
private int maxCalcutatedIndex
outputOperations
array that has already been added to tempPseudoBytes
.public StreamInfo(ProcessStream stream)
stream
- The stream to which this information relates.public void notifyBlockingOperation(BlockingOperation blockingOperation)
blockingOperation
- Blocking operation that was performed.public void notifyOutputOperation(OutputOperationType type, int bytes)
type
- Type of the performed output operation.bytes
- Number of bytes that has been written by the output operation.public java.util.Set<BlockingOperation> getBlockingOperations()
public boolean shouldRaiseStop(boolean close)
close
- true
if we are performing a close operation,
false
if we are performing a flush operation.private int calculatePseudoBytesWritten(java.util.Map<OutputOperationType,java.lang.Integer> operationsMap, int maxValue)
Writing different number of bytes in a single operation may lead to different buffer sizes. E.g. if we are using only PUT "xxxx" operations we can output 40 bytes in this way, but if we are using only PUT "xxxxxxxxxx" operations we can output only 20 bytes.
Consider we have the following sequence of operations:
PUT "xxxx"
We have 5 * 4 + 1 * 10 = 30 "real" bytes written.
PUT "xxxx"
PUT "xxxx"
PUT "xxxx"
PUT "xxxx"
PUT "xxxxxxxxxx"
But we have 5 * 4 * (40 / 40) + 1 * 10 * (40 / 20) = 40 pseudo-bytes
written which equals the buffer size limit for this case.
operationsMap
- Map which contains current buffer sizes for different output
operation types.maxValue
- The maximum buffer size among the values contained in the
operationsMap
private void refreshInformation()