Package com.yahoo.container.jdisc
Class ThreadedRequestHandler
- java.lang.Object
-
- com.yahoo.jdisc.AbstractResource
-
- com.yahoo.jdisc.handler.AbstractRequestHandler
-
- com.yahoo.container.jdisc.ThreadedRequestHandler
-
- All Implemented Interfaces:
com.yahoo.jdisc.handler.RequestHandler
,com.yahoo.jdisc.SharedResource
- Direct Known Subclasses:
ThreadedHttpRequestHandler
public abstract class ThreadedRequestHandler extends com.yahoo.jdisc.handler.AbstractRequestHandler
A request handler which assigns a worker thread to handle each request. This is mean to be subclasses by handlers who does work by executing each request in a separate thread.Note that this means that subclass handlers are synchronous - the request io can continue after completion of the worker thread.
- Author:
- Simon Thoresen Hult
-
-
Field Summary
Fields Modifier and Type Field Description protected com.yahoo.jdisc.Metric
metric
-
Constructor Summary
Constructors Modifier Constructor Description protected
ThreadedRequestHandler(java.util.concurrent.Executor executor)
protected
ThreadedRequestHandler(java.util.concurrent.Executor executor, com.yahoo.jdisc.Metric metric)
protected
ThreadedRequestHandler(java.util.concurrent.Executor executor, com.yahoo.jdisc.Metric metric, boolean allowAsyncResponse)
Creates a threaded request handler
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.time.Duration
getTimeout()
protected abstract void
handleRequest(com.yahoo.jdisc.Request request, com.yahoo.jdisc.handler.BufferedContentChannel requestContent, com.yahoo.jdisc.handler.ResponseHandler responseHandler)
com.yahoo.jdisc.handler.ContentChannel
handleRequest(com.yahoo.jdisc.Request request, com.yahoo.jdisc.handler.ResponseHandler responseHandler)
Handles a request by assigning a worker thread to it.-
Methods inherited from class com.yahoo.jdisc.AbstractResource
currentState, destroy, refer, release, retainCount
-
-
-
-
Constructor Detail
-
ThreadedRequestHandler
protected ThreadedRequestHandler(java.util.concurrent.Executor executor)
-
ThreadedRequestHandler
@Inject protected ThreadedRequestHandler(java.util.concurrent.Executor executor, com.yahoo.jdisc.Metric metric)
-
ThreadedRequestHandler
@Inject protected ThreadedRequestHandler(java.util.concurrent.Executor executor, com.yahoo.jdisc.Metric metric, boolean allowAsyncResponse)
Creates a threaded request handler- Parameters:
executor
- the executor to use to execute requestsmetric
- the metric object to which event in this are to be collectedallowAsyncResponse
- true to allow the response header to be created asynchronously. If false (default), this will create an error response if the response header is not returned by the subclass of this before handleRequest returns.
-
-
Method Detail
-
handleRequest
public final com.yahoo.jdisc.handler.ContentChannel handleRequest(com.yahoo.jdisc.Request request, com.yahoo.jdisc.handler.ResponseHandler responseHandler)
Handles a request by assigning a worker thread to it.- Throws:
com.yahoo.jdisc.handler.OverloadException
- if thread pool has no available thread
-
getTimeout
public java.time.Duration getTimeout()
-
handleRequest
protected abstract void handleRequest(com.yahoo.jdisc.Request request, com.yahoo.jdisc.handler.BufferedContentChannel requestContent, com.yahoo.jdisc.handler.ResponseHandler responseHandler)
-
-