Top Description Inners Fields Constructors Methods
org.eclipse.jetty.ee10.servlet

pack-priv Class AsyncContentProducer

extends Object
implements ContentProducer
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.ee10.servlet.ContentProducer
Imports
java.util.concurrent.TimeUnit, java.util.concurrent.locks.Condition, org.eclipse.jetty.http.BadMessageException, .HttpStatus, .Trailers, org.eclipse.jetty.io.Content, org.eclipse.jetty.util.NanoTime, .StaticException, org.eclipse.jetty.util.thread.AutoLock, org.slf4j.Logger, .LoggerFactory

Non-blocking ContentProducer implementation. Calling ContentProducer#nextChunk() will never block but will return null when there is no available content.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
AsyncContentProducer.LockedSemaphore

A semaphore that assumes working under the same locked scope.

Field Summary

Modifier and TypeField and Description
private long
private Content.Chunk
private long
pack-priv final AutoLock
private final ServletChannel
private static final Logger
private static final Content.Chunk

Constructor Summary

AccessConstructor and Description
pack-priv
AsyncContentProducer(ServletChannel
The ServletChannel to produce input from.
servletChannel
,
AutoLock
The lock of the HttpInput, shared with this instance
lock
)

Method Summary

Modifier and TypeMethod and Description
private void
public int
available()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.available.

Get the byte count that can immediately be read from this ContentProducer instance or the underlying Content.Source.

public void
checkMinDataRate()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.checkMinDataRate.

Check if the current data rate consumption is above the minimal rate.

public boolean
consumeAvailable()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.consumeAvailable.

Fail all content currently available in this ContentProducer instance as well as in the underlying Content.Source.

private boolean
private boolean
public long
getBytesArrived()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.getBytesArrived.

Get the byte count produced by the underlying Content.Source.

pack-priv ServletChannel
public boolean
hasChunk()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.hasChunk.

Check if this ContentProducer instance contains some content chunk without querying the underlying Content.Source.

public boolean
isError()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.isError.

Check if the underlying Content.Source reached an error content.

public boolean
isReady()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.isReady.

Check if this ContentProducer instance has some content that can be read without blocking.

pack-priv boolean
pack-priv AsyncContentProducer.LockedSemaphore
public Content.Chunk
nextChunk()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.nextChunk.

Get the next content chunk that can be read from or that describes the terminal condition that was reached (error, eof).

public boolean
onContentProducible()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.onContentProducible.

Wake up the thread that is waiting for the next content.

private Content.Chunk
private Content.Chunk
public void
reclaim(Content.Chunk chunk)

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.reclaim.

Free up the content by calling Content.Chunk#release() on it and updating this instance's internal state.

public void
recycle()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.recycle.

A recycled ContentProducer will only produce special content with a non-null error until reopen() is called.

public void
reopen()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.reopen.

Reset all internal state, making this is instance logically equivalent to a freshly allocated one.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_bytesArrivedback to summary
private long _bytesArrived
_chunkback to summary
private Content.Chunk _chunk
_firstByteNanoTimeback to summary
private long _firstByteNanoTime
_lockback to summary
pack-priv final AutoLock _lock
_servletChannelback to summary
private final ServletChannel _servletChannel
LOGback to summary
private static final Logger LOG
RECYCLED_ERROR_CHUNKback to summary
private static final Content.Chunk RECYCLED_ERROR_CHUNK

Constructor Detail

AsyncContentProducerback to summary
pack-priv AsyncContentProducer(ServletChannel servletChannel, AutoLock lock)
Parameters
servletChannel:ServletChannel

The ServletChannel to produce input from.

lock:AutoLock

The lock of the HttpInput, shared with this instance

Method Detail

assertLockedback to summary
private void assertLocked()
availableback to summary
public int available()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.available.

Doc from org.eclipse.jetty.ee10.servlet.ContentProducer.available.

Get the byte count that can immediately be read from this ContentProducer instance or the underlying Content.Source. This call is always non-blocking. Doesn't change state.

Returns:int

the available byte count.

Annotations
@Override
checkMinDataRateback to summary
public void checkMinDataRate()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.checkMinDataRate.

Doc from org.eclipse.jetty.ee10.servlet.ContentProducer.checkMinDataRate.

Check if the current data rate consumption is above the minimal rate. Abort the channel, fail the content currently available and throw a BadMessageException(REQUEST_TIMEOUT_408) if the check fails.

Annotations
@Override
consumeAvailableback to summary
public boolean consumeAvailable()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.consumeAvailable.

Doc from org.eclipse.jetty.ee10.servlet.ContentProducer.consumeAvailable.

Fail all content currently available in this ContentProducer instance as well as in the underlying Content.Source. This call is always non-blocking. Doesn't change state.

Returns:boolean

true if EOF was reached.

Annotations
@Override
consumeAvailableChunksback to summary
private boolean consumeAvailableChunks()
consumeCurrentChunkback to summary
private boolean consumeCurrentChunk()
getBytesArrivedback to summary
public long getBytesArrived()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.getBytesArrived.

Doc from org.eclipse.jetty.ee10.servlet.ContentProducer.getBytesArrived.

Get the byte count produced by the underlying Content.Source. This call is always non-blocking. Doesn't change state.

Returns:long

the byte count produced by the underlying Content.Source.

Annotations
@Override
getServletChannelback to summary
pack-priv ServletChannel getServletChannel()
hasChunkback to summary
public boolean hasChunk()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.hasChunk.

Doc from org.eclipse.jetty.ee10.servlet.ContentProducer.hasChunk.

Check if this ContentProducer instance contains some content chunk without querying the underlying Content.Source. This call is always non-blocking. Doesn't change state. Doesn't query the HttpChannel.

Returns:boolean

true if this ContentProducer instance contains content, false otherwise.

Annotations
@Override
isErrorback to summary
public boolean isError()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.isError.

Doc from org.eclipse.jetty.ee10.servlet.ContentProducer.isError.

Check if the underlying Content.Source reached an error content. This call is always non-blocking. Doesn't change state. Doesn't query the HttpChannel.

Returns:boolean

true if the underlying Content.Source reached an error content, false otherwise.

Annotations
@Override
isReadyback to summary
public boolean isReady()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.isReady.

Doc from org.eclipse.jetty.ee10.servlet.ContentProducer.isReady.

Check if this ContentProducer instance has some content that can be read without blocking. If there is some, the next call to nextChunk() will not block. If there isn't any and the implementation does not block, this method will trigger a jakarta.servlet.ReadListener callback once some content is available. This call is always non-blocking.

Returns:boolean

true if some content is immediately available, false otherwise.

Annotations
@Override
isUnreadyback to summary
pack-priv boolean isUnready()
newLockedSemaphoreback to summary
pack-priv AsyncContentProducer.LockedSemaphore newLockedSemaphore()
nextChunkback to summary
public Content.Chunk nextChunk()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.nextChunk.

Doc from org.eclipse.jetty.ee10.servlet.ContentProducer.nextChunk.

Get the next content chunk that can be read from or that describes the terminal condition that was reached (error, eof). This call may or may not block until some content is available, depending on the implementation. After this call, state can be either of UNREADY or IDLE.

Returns:Content.Chunk

the next content chunk that can be read from or null if the implementation does not block and has no available content.

Annotations
@Override
onContentProducibleback to summary
public boolean onContentProducible()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.onContentProducible.

Doc from org.eclipse.jetty.ee10.servlet.ContentProducer.onContentProducible.

Wake up the thread that is waiting for the next content. After this call, state can be READY.

Returns:boolean

true if the thread has to be rescheduled, false otherwise.

Annotations
@Override
produceChunkback to summary
private Content.Chunk produceChunk()
readChunkback to summary
private Content.Chunk readChunk()
reclaimback to summary
public void reclaim(Content.Chunk chunk)

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.reclaim.

Doc from org.eclipse.jetty.ee10.servlet.ContentProducer.reclaim.

Free up the content by calling Content.Chunk#release() on it and updating this instance's internal state.

Annotations
@Override
recycleback to summary
public void recycle()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.recycle.

Doc from org.eclipse.jetty.ee10.servlet.ContentProducer.recycle.

A recycled ContentProducer will only produce special content with a non-null error until reopen() is called.

Annotations
@Override
reopenback to summary
public void reopen()

Implements org.eclipse.jetty.ee10.servlet.ContentProducer.reopen.

Doc from org.eclipse.jetty.ee10.servlet.ContentProducer.reopen.

Reset all internal state, making this is instance logically equivalent to a freshly allocated one.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.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.ee10.servlet back to summary

pack-priv Class AsyncContentProducer.LockedSemaphore

extends Object
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.ee10.servlet.AsyncContentProducer.LockedSemaphore

A semaphore that assumes working under the same locked scope.

Field Summary

Modifier and TypeField and Description
private final Condition
private int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv void
pack-priv void
pack-priv void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_conditionback to summary
private final Condition _condition
_permitsback to summary
private int _permits

Constructor Detail

LockedSemaphoreback to summary
private LockedSemaphore()

Method Detail

acquireback to summary
pack-priv void acquire() throws InterruptedException
assertLockedback to summary
pack-priv void assertLocked()
drainPermitsback to summary
pack-priv void drainPermits()
releaseback to summary
pack-priv void release()
toStringback to summary
public String toString()

Overrides java.lang.Object.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