Class StatisticsHandler.MinimumDataRateHandler.MinimumDataRateRequest
- All Implemented Interfaces:
Content.Source, Request, Attributes
- Enclosing class:
StatisticsHandler.MinimumDataRateHandler
-
Nested Class Summary
Nested classes/interfaces inherited from interface Attributes
Attributes.Layer, Attributes.Lazy, Attributes.Mapped, Attributes.SyntheticNested classes/interfaces inherited from interface Content.Source
Content.Source.FactoryNested classes/interfaces inherited from interface Request
Request.AttributesWrapper, Request.AuthenticationState, Request.Handler, Request.ServeAs, Request.Wrapper -
Field Summary
Fields inherited from interface Attributes
NULLFields inherited from interface Request
COOKIE_ATTRIBUTE, DEFAULT_LOCALES, LOG -
Method Summary
Modifier and TypeMethodDescriptionvoidDemands to invoke the given demand callback parameter when a chunk of content is available.read()Reads a chunk of content.Methods inherited from class Request.Wrapper
addFailureListener, addHttpStreamWrapper, addIdleTimeoutListener, asAttributeMap, clearAttributes, consumeAvailable, fail, getAttribute, getAttributeNameSet, getBeginNanoTime, getComponents, getConnectionMetaData, getContext, getHeaders, getHeadersNanoTime, getHttpURI, getId, getLength, getMethod, getSession, getTrailers, getTunnelSupport, getWrapped, isSecure, push, removeAttribute, setAttribute, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Attributes
equals, hashCodeMethods inherited from interface Content.Source
fail, rewind
-
Method Details
-
demand
Description copied from interface:RequestDemands to invoke the given demand callback parameter when a chunk of content is available.
See how to use this method idiomatically.
Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the
Runnablecallback and a call to this method. Invocations of the passedRunnableare serialized and a callback fordemandcall is not invoked until any previousdemandcallback has returned. Thus theRunnableshould not block waiting for a callback of a future demand call.The demand callback may be invoked spuriously: a subsequent call to
Content.Source.read()may returnnull.Calling this method establishes a pending demand, which is fulfilled when the demand callback is invoked.
Calling this method when there is already a pending demand results in an
IllegalStateExceptionto be thrown.If the invocation of the demand callback throws an exception, then
Content.Source.fail(Throwable)is called.- Specified by:
demandin interfaceContent.Source- Specified by:
demandin interfaceRequest- Overrides:
demandin classRequest.Wrapper- Parameters:
demandCallback- the demand callback to invoke when there is a content chunk available.- See Also:
-
read
Description copied from interface:RequestReads a chunk of content.
See how to use this method idiomatically.
The returned chunk could be:
null, to signal that there isn't a chunk of content available- an
Content.Chunkinstance with non nullContent.Chunk.getFailure(), to signal that there was a failure trying to produce a chunk of content, or that the content production has beenfailedexternally - a
Content.Chunkinstance, containing the chunk of content.
Once a read returns an
Content.Chunkinstance with non-nullContent.Chunk.getFailure()then if the failure islastfurther reads will continue to return the same failure chunk instance, otherwise furtherread()operations may return different non-failure chunks.Once a read returns a
last chunk, further reads will continue to return a last chunk (although the instance may be different).The content reader code must ultimately arrange for a call to
Retainable.release()on the returnedContent.Chunk.Additionally, prior to the ultimate call to
Retainable.release(), the reader code may make additional calls toRetainable.retain(), that must ultimately be matched by a correspondent number of calls toRetainable.release().Concurrent reads from different threads are not recommended, as they are inherently in a race condition.
Reads performed outside the invocation context of a
demand callbackare allowed. However, reads performed with a pending demand are inherently in a race condition (the thread that reads with the thread that invokes the demand callback).In addition, the returned
Content.Chunkmay be aTrailersinstance, in case of request content trailers.- Specified by:
readin interfaceContent.Source- Specified by:
readin interfaceRequest- Overrides:
readin classRequest.Wrapper- Returns:
- a chunk of content, possibly a failure instance, or
null - See Also:
-