Top Inners Fields Constructors Methods
org.eclipse.jetty.websocket.core.internal

public Class FrameFlusher

extends IteratingCallback
Class Inheritance
Known Direct Subclasses
org.eclipse.jetty.websocket.core.WebSocketConnection.Flusher
Imports
java.nio.ByteBuffer, java.nio.channels.ClosedChannelException, java.util.ArrayDeque, .ArrayList, .Deque, .Iterator, .List, .Objects, java.util.concurrent.TimeUnit, java.util.concurrent.atomic.LongAdder, org.eclipse.jetty.io.ByteBufferPool, .EndPoint, .RetainableByteBuffer, org.eclipse.jetty.util.BufferUtil, .Callback, .IteratingCallback, .StaticException, .TypeUtil, org.eclipse.jetty.util.thread.AutoLock, .Scheduler, org.eclipse.jetty.websocket.core.CloseStatus, .Frame, .OpCode, org.eclipse.jetty.websocket.core.exception.WebSocketException, .WebSocketWriteTimeoutException, org.slf4j.Logger, .LoggerFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private RetainableByteBuffer
private final ByteBufferPool
private final List<ByteBuffer>
private final int
private final LongAdder
private boolean
private static final Throwable
private Throwable
private final EndPoint
private final List<FrameFlusher.Entry>
private final List<FrameFlusher.Entry>
public static final Frame
private boolean
private final Generator
private long
private final AutoLock
private static final Logger
private final int
private final LongAdder
private final List<FrameFlusher.Entry>
private final Deque<FrameFlusher.Entry>
private List<RetainableByteBuffer>
private final Scheduler
private boolean

Constructor Summary

AccessConstructor and Description
public
FrameFlusher(ByteBufferPool bufferPool, Scheduler scheduler, Generator generator, EndPoint endPoint, int bufferSize, int maxGather)

Method Summary

Modifier and TypeMethod and Description
private RetainableByteBuffer
acquireBuffer(int capacity)

public boolean

Returns:

returns true if the frame was enqueued and iterate needs to be called, returns false if the FrameFlusher was closed
enqueue
(Frame
The frame to queue
frame
,
Callback
The callback to call once the frame is sent
callback
,
boolean
True if batch mode is to be used
batch
)

Enqueue a Frame to be written to the endpoint.

public long
public long
public long
private int
public boolean
protected void
protected void
public void
public void
onCompleteFailure(Throwable
the throwable to indicate cause of failure
failure
)

Overrides org.eclipse.jetty.util.IteratingCallback.onCompleteFailure.

Invoked when the overall task has completed with a failure.

protected IteratingCallback.Action
process()

Implements abstract org.eclipse.jetty.util.IteratingCallback.process.

Method called by iterate() to process the asynchronous sub-task.

private void
public void
setIdleTimeout(long idleTimeout)

public void
setUseDirectByteBuffers(boolean useDirectByteBuffers)

public void
public String
toString()

Overrides org.eclipse.jetty.util.IteratingCallback.toString.

Returns a string representation of the object.

Inherited from org.eclipse.jetty.util.IteratingCallback:
abortclosefailedisAbortedisClosedisFailedisSucceedediterateonCompleteSuccessresetsucceeded

Field Detail

batchBufferback to summary
private RetainableByteBuffer batchBuffer
bufferPoolback to summary
private final ByteBufferPool bufferPool
buffersback to summary
private final List<ByteBuffer> buffers
bufferSizeback to summary
private final int bufferSize
bytesOutback to summary
private final LongAdder bytesOut
canEnqueueback to summary
private boolean canEnqueue
CLOSED_CHANNELback to summary
private static final Throwable CLOSED_CHANNEL
closedCauseback to summary
private Throwable closedCause
endPointback to summary
private final EndPoint endPoint
entriesback to summary
private final List<FrameFlusher.Entry> entries
failedEntriesback to summary
private final List<FrameFlusher.Entry> failedEntries
FLUSH_FRAMEback to summary
public static final Frame FLUSH_FRAME
flushedback to summary
private boolean flushed
generatorback to summary
private final Generator generator
idleTimeoutback to summary
private long idleTimeout
lockback to summary
private final AutoLock lock
LOGback to summary
private static final Logger LOG
maxGatherback to summary
private final int maxGather
messagesOutback to summary
private final LongAdder messagesOut
previousEntriesback to summary
private final List<FrameFlusher.Entry> previousEntries
queueback to summary
private final Deque<FrameFlusher.Entry> queue
releasableBuffersback to summary
private List<RetainableByteBuffer> releasableBuffers
timeoutSchedulerback to summary
private final Scheduler timeoutScheduler
useDirectByteBuffersback to summary
private boolean useDirectByteBuffers

Constructor Detail

FrameFlusherback to summary
public FrameFlusher(ByteBufferPool bufferPool, Scheduler scheduler, Generator generator, EndPoint endPoint, int bufferSize, int maxGather)

Method Detail

acquireBufferback to summary
private RetainableByteBuffer acquireBuffer(int capacity)
enqueueback to summary
public boolean enqueue(Frame frame, Callback callback, boolean batch)

Enqueue a Frame to be written to the endpoint.

Parameters
frame:Frame

The frame to queue

callback:Callback

The callback to call once the frame is sent

batch:boolean

True if batch mode is to be used

Returns:boolean

returns true if the frame was enqueued and iterate needs to be called, returns false if the FrameFlusher was closed

getBytesOutback to summary
public long getBytesOut()
getIdleTimeoutback to summary
public long getIdleTimeout()
getMessagesOutback to summary
public long getMessagesOut()
getQueueSizeback to summary
private int getQueueSize()
isUseDirectByteBuffersback to summary
public boolean isUseDirectByteBuffers()
notifyCallbackFailureback to summary
protected void notifyCallbackFailure(Callback callback, Throwable failure)
notifyCallbackSuccessback to summary
protected void notifyCallbackSuccess(Callback callback)
onCloseback to summary
public void onClose(Throwable cause)
onCompleteFailureback to summary
public void onCompleteFailure(Throwable failure)

Overrides org.eclipse.jetty.util.IteratingCallback.onCompleteFailure.

Doc from org.eclipse.jetty.util.IteratingCallback.onCompleteFailure.

Invoked when the overall task has completed with a failure.

Parameters
failure:Throwable

the throwable to indicate cause of failure

Annotations
@Override
processback to summary
protected IteratingCallback.Action process() throws Throwable

Implements abstract org.eclipse.jetty.util.IteratingCallback.process.

Doc from org.eclipse.jetty.util.IteratingCallback.process.

Method called by iterate() to process the asynchronous sub-task.

Implementations must initiate the asynchronous execution of the sub-task (if any) and return an appropriate action:

  • Action#IDLE when no sub tasks are available for execution but the overall job is not completed yet
  • Action#SCHEDULED when the sub task asynchronous execution has been started
  • Action#SUCCEEDED when the overall job is completed
Returns:IteratingCallback.Action

the appropriate Action

Annotations
@Override
Exceptions
Throwable:
if the sub-task processing throws
releaseAggregateback to summary
private void releaseAggregate()
setIdleTimeoutback to summary
public void setIdleTimeout(long idleTimeout)
setUseDirectByteBuffersback to summary
public void setUseDirectByteBuffers(boolean useDirectByteBuffers)
timeoutExpiredback to summary
public void timeoutExpired()
toStringback to summary
public String toString()

Overrides org.eclipse.jetty.util.IteratingCallback.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.eclipse.jetty.websocket.core.internal back to summary

private Class FrameFlusher.Entry

extends FrameEntry
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final long
Inherited from org.eclipse.jetty.websocket.core.internal.FrameEntry:
batchcallbackframe

Constructor Summary

AccessConstructor and Description
private
Entry(Frame frame, Callback callback, boolean batch)

Method Summary

Modifier and TypeMethod and Description
private long
public String
toString()

Overrides org.eclipse.jetty.websocket.core.internal.FrameEntry.toString.

Returns a string representation of the object.

Field Detail

timeOfCreationback to summary
private final long timeOfCreation

Constructor Detail

Entryback to summary
private Entry(Frame frame, Callback callback, boolean batch)

Method Detail

getTimeOfCreationback to summary
private long getTimeOfCreation()
toStringback to summary
public String toString()

Overrides org.eclipse.jetty.websocket.core.internal.FrameEntry.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override