public abstract class ThreadedRequestHandler
extends com.yahoo.jdisc.handler.AbstractRequestHandler
Note that this means that subclass handlers are synchronous - the request io can continue after completion of the worker thread.
Modifier and Type | Class and Description |
---|---|
private static class |
ThreadedRequestHandler.NullRequestMetric |
private class |
ThreadedRequestHandler.RequestTask |
Modifier and Type | Field and Description |
---|---|
private boolean |
allowAsyncResponse |
private static long |
currentFailureIntervalStartedMillis |
private Executor |
executor |
private Map<String,com.yahoo.jdisc.Metric.Context> |
handlerContexts |
private static Logger |
log |
protected com.yahoo.jdisc.Metric |
metric |
private static int |
numRejectedRequests |
private static Object |
rejectedExecutionsLock |
private static Duration |
TIMEOUT |
Modifier | Constructor and Description |
---|---|
protected |
ThreadedRequestHandler(Executor executor) |
protected |
ThreadedRequestHandler(Executor executor,
com.yahoo.jdisc.Metric metric) |
protected |
ThreadedRequestHandler(Executor executor,
com.yahoo.jdisc.Metric metric,
boolean allowAsyncResponse)
Creates a threaded request handler
|
Modifier and Type | Method and Description |
---|---|
private com.yahoo.jdisc.Metric.Context |
contextFor(com.yahoo.jdisc.application.BindingMatch match) |
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.
|
private void |
incrementRejectedRequests() |
private void |
logRejectedRequests() |
currentState, destroy, refer, release, retainCount
private static final Logger log
private static final Duration TIMEOUT
private final Executor executor
protected final com.yahoo.jdisc.Metric metric
private final boolean allowAsyncResponse
private static final Object rejectedExecutionsLock
private static volatile int numRejectedRequests
private static long currentFailureIntervalStartedMillis
protected ThreadedRequestHandler(Executor executor)
@Inject protected ThreadedRequestHandler(Executor executor, com.yahoo.jdisc.Metric metric)
@Inject protected ThreadedRequestHandler(Executor executor, com.yahoo.jdisc.Metric metric, boolean allowAsyncResponse)
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.private com.yahoo.jdisc.Metric.Context contextFor(com.yahoo.jdisc.application.BindingMatch match)
public final com.yahoo.jdisc.handler.ContentChannel handleRequest(com.yahoo.jdisc.Request request, com.yahoo.jdisc.handler.ResponseHandler responseHandler)
com.yahoo.jdisc.handler.OverloadException
- if thread pool has no available threadpublic Duration getTimeout()
private void logRejectedRequests()
private void incrementRejectedRequests()
protected abstract void handleRequest(com.yahoo.jdisc.Request request, com.yahoo.jdisc.handler.BufferedContentChannel requestContent, com.yahoo.jdisc.handler.ResponseHandler responseHandler)
Copyright © 2017. All rights reserved.