public class FrameFlusher extends IteratingCallback
Modifier and Type | Class and Description |
---|---|
private class |
FrameFlusher.FrameEntry |
IteratingCallback.Action
Callback.Completable, Callback.Completing, Callback.Nested
Invocable.InvocationType
Modifier and Type | Field and Description |
---|---|
private java.nio.ByteBuffer |
aggregate |
private BatchMode |
batchMode |
private ByteBufferPool |
bufferPool |
private java.util.List<java.nio.ByteBuffer> |
buffers |
private int |
bufferSize |
private java.util.concurrent.atomic.LongAdder |
bytesOut |
private boolean |
canEnqueue |
private boolean |
closed |
private EndPoint |
endPoint |
private java.util.List<FrameFlusher.FrameEntry> |
entries |
static BinaryFrame |
FLUSH_FRAME |
private Generator |
generator |
private static Logger |
LOG |
private int |
maxGather |
private java.util.concurrent.atomic.LongAdder |
messagesOut |
private java.util.Deque<FrameFlusher.FrameEntry> |
queue |
private java.lang.Throwable |
terminated |
__nonBlocking
Constructor and Description |
---|
FrameFlusher(ByteBufferPool bufferPool,
Generator generator,
EndPoint endPoint,
int bufferSize,
int maxGather) |
Modifier and Type | Method and Description |
---|---|
private IteratingCallback.Action |
batch() |
boolean |
enqueue(Frame frame,
WriteCallback callback,
BatchMode batchMode) |
private IteratingCallback.Action |
flush() |
long |
getBytesOut() |
long |
getMessagesOut() |
private int |
getQueueSize() |
protected void |
notifyCallbackFailure(WriteCallback callback,
java.lang.Throwable failure) |
protected void |
notifyCallbackSuccess(WriteCallback callback) |
void |
onCompleteFailure(java.lang.Throwable failure)
Invoked when the overall task has completed with a failure.
|
protected IteratingCallback.Action |
process()
Method called by
IteratingCallback.iterate() to process the sub task. |
private void |
releaseAggregate() |
void |
succeeded()
Invoked when the sub task succeeds.
|
private void |
succeedEntries() |
(package private) void |
terminate(java.lang.Throwable cause) |
java.lang.String |
toString() |
close, failed, isClosed, isFailed, isSucceeded, iterate, onCompleteSuccess, reset
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getInvocationType, getInvocationType, invokeNonBlocking, isNonBlockingInvocation
public static final BinaryFrame FLUSH_FRAME
private static final Logger LOG
private final ByteBufferPool bufferPool
private final EndPoint endPoint
private final int bufferSize
private final Generator generator
private final int maxGather
private final java.util.Deque<FrameFlusher.FrameEntry> queue
private final java.util.List<FrameFlusher.FrameEntry> entries
private final java.util.List<java.nio.ByteBuffer> buffers
private final java.util.concurrent.atomic.LongAdder messagesOut
private final java.util.concurrent.atomic.LongAdder bytesOut
private boolean closed
private boolean canEnqueue
private java.lang.Throwable terminated
private java.nio.ByteBuffer aggregate
private BatchMode batchMode
public FrameFlusher(ByteBufferPool bufferPool, Generator generator, EndPoint endPoint, int bufferSize, int maxGather)
public boolean enqueue(Frame frame, WriteCallback callback, BatchMode batchMode)
protected IteratingCallback.Action process() throws java.lang.Throwable
IteratingCallback
IteratingCallback.iterate()
to process the sub task.
Implementations must start the asynchronous execution of the sub task (if any) and return an appropriate action:
IteratingCallback.Action.IDLE
when no sub tasks are available for execution
but the overall job is not completed yetIteratingCallback.Action.SCHEDULED
when the sub task asynchronous execution
has been startedIteratingCallback.Action.SUCCEEDED
when the overall job is completedprocess
in class IteratingCallback
java.lang.Throwable
- if the sub task processing throwsprivate IteratingCallback.Action batch()
private IteratingCallback.Action flush()
private int getQueueSize()
public void succeeded()
IteratingCallback
super.succeeded()
.succeeded
in interface Callback
succeeded
in class IteratingCallback
Callback.failed(Throwable)
private void succeedEntries()
public void onCompleteFailure(java.lang.Throwable failure)
IteratingCallback
onCompleteFailure
in class IteratingCallback
failure
- the throwable to indicate cause of failureIteratingCallback.onCompleteSuccess()
private void releaseAggregate()
void terminate(java.lang.Throwable cause)
protected void notifyCallbackSuccess(WriteCallback callback)
protected void notifyCallbackFailure(WriteCallback callback, java.lang.Throwable failure)
public long getMessagesOut()
public long getBytesOut()
public java.lang.String toString()
toString
in class IteratingCallback