public abstract class AsynchronousSectionedRenderer<RESPONSE extends com.yahoo.processing.Response> extends AsynchronousRenderer<RESPONSE>
This API assumes all data should be rendered. Choosing which data should be rendered is the responsibility of the processing chains.
Constructor and Description |
---|
AsynchronousSectionedRenderer()
Create an renderer instance not yet associated with any request
processing or network for easy subclassing.
|
AsynchronousSectionedRenderer(Executor executor)
Create an renderer using the specified executor instead of the default one which should be used for production.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
beginList(com.yahoo.processing.response.DataList<?> list)
Invoked at the beginning of each data list, including the implicit,
outermost one in the response.
|
abstract void |
beginResponse(OutputStream stream)
Invoked once at the beginning of rendering a response.
|
protected boolean |
clientClosed()
Returns whether the client this is rendering to has closed the connection
|
abstract void |
data(com.yahoo.processing.response.Data data)
Invoked for each leaf node in the data tree
|
void |
deconstruct() |
abstract void |
endList(com.yahoo.processing.response.DataList<?> list)
Invoked at the end of each data list, including the implicit, outermost
one in the response.
|
abstract void |
endResponse()
Invoked once at the end of rendering a response.
|
com.yahoo.processing.execution.Execution |
getExecution()
The outermost execution which was run to create the response to render.
|
int |
getRecursionLevel()
How deep into the tree of nested data lists the callback currently is.
|
com.yahoo.processing.Response |
getResponse()
The response render callbacks are generated from.
|
void |
init()
Do per instance initialization.
|
protected void |
onClientClosed()
This hook is called once when the renderer detects that the client has closed the connection
|
com.google.common.util.concurrent.ListenableFuture<Boolean> |
render(OutputStream stream,
RESPONSE response,
com.yahoo.processing.execution.Execution execution,
com.yahoo.processing.Request request)
Render this response using the renderer's own threads and return a future indicating whether the rendering
was successful.
|
com.google.common.util.concurrent.ListenableFuture<Boolean> |
renderBeforeHandover(OutputStream stream,
RESPONSE response,
com.yahoo.processing.execution.Execution execution,
com.yahoo.processing.Request request)
Initiate rendering before handover to rendering threads.
|
void |
setNetworkWiring(com.yahoo.jdisc.handler.ContentChannel channel,
com.yahoo.jdisc.handler.CompletionHandler completionHandler)
For internal use: Expose JDisc wiring to ensure asynchronous cleanup.
|
clone, getEncoding, getMimeType
public AsynchronousSectionedRenderer()
public AsynchronousSectionedRenderer(Executor executor)
executor
- the executor to use or null to use the default executor suitable for productionpublic abstract void beginResponse(OutputStream stream) throws IOException
stream
- the stream to render to in this and all subsequent calls.IOException
- passed on from the streampublic abstract void beginList(com.yahoo.processing.response.DataList<?> list) throws IOException
list
- the data list which now will be renderedIOException
- passed on from the streampublic abstract void data(com.yahoo.processing.response.Data data) throws IOException
data
- the leaf node to renderIOException
- passed on from the streampublic abstract void endList(com.yahoo.processing.response.DataList<?> list) throws IOException
list
- the data list which now has no more data items to renderIOException
- passed on from the streampublic abstract void endResponse() throws IOException
IOException
- passed on from the streampublic final com.google.common.util.concurrent.ListenableFuture<Boolean> render(OutputStream stream, RESPONSE response, com.yahoo.processing.execution.Execution execution, com.yahoo.processing.Request request)
Render this response using the renderer's own threads and return a future indicating whether the rendering was successful. The data list tree will be traversed asynchronously, and the pertinent methods will be called as data becomes available.
If rendering fails, the exception causing this will be wrapped in an ExecutionException and thrown from blocked calls to Future.get()
render
in class Renderer<RESPONSE extends com.yahoo.processing.Response>
stream
- a stream API bridge to JDiscresponse
- the response to renderexecution
- the execution which created this responserequest
- the request matching the responsepublic void deconstruct()
deconstruct
in class com.yahoo.component.AbstractComponent
public final com.google.common.util.concurrent.ListenableFuture<Boolean> renderBeforeHandover(OutputStream stream, RESPONSE response, com.yahoo.processing.execution.Execution execution, com.yahoo.processing.Request request)
public com.yahoo.processing.execution.Execution getExecution()
public com.yahoo.processing.Response getResponse()
protected boolean clientClosed()
protected void onClientClosed()
public int getRecursionLevel()
public final void setNetworkWiring(com.yahoo.jdisc.handler.ContentChannel channel, com.yahoo.jdisc.handler.CompletionHandler completionHandler)
setNetworkWiring
in class AsynchronousRenderer<RESPONSE extends com.yahoo.processing.Response>
channel
- the channel to the client receiving the responsecompletionHandler
- the JDisc completion handler which will be invoked at the end
of the renderingIllegalStateException
- if attempted invoked more than onceCopyright © 2018. All rights reserved.