use of com.yahoo.jdisc.handler.OverloadException in project vespa by vespa-engine.
the class ThreadedRequestHandler method handleRequest.
/**
* Handles a request by assigning a worker thread to it.
*
* @throws OverloadException if thread pool has no available thread
*/
@Override
public final ContentChannel handleRequest(Request request, ResponseHandler responseHandler) {
metric.add("handled.requests", 1, contextFor(request.getBindingMatch()));
if (request.getTimeout(TimeUnit.SECONDS) == null) {
Duration timeout = getTimeout();
if (timeout != null) {
request.setTimeout(timeout.getSeconds(), TimeUnit.SECONDS);
}
}
BufferedContentChannel content = new BufferedContentChannel();
final RequestTask command = new RequestTask(request, content, responseHandler);
try {
executor.execute(command);
} catch (RejectedExecutionException e) {
command.failOnOverload();
throw new OverloadException("No available threads for " + getClass().getSimpleName(), e);
} finally {
logRejectedRequests();
}
return content;
}
use of com.yahoo.jdisc.handler.OverloadException in project vespa by vespa-engine.
the class JDiscHttpServlet method dispatchHttpRequest.
private void dispatchHttpRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
AccessLogEntry accessLogEntry = new AccessLogEntry();
AccessLogRequestLog.populateAccessLogEntryFromHttpServletRequest(request, accessLogEntry);
request.setAttribute(ATTRIBUTE_NAME_ACCESS_LOG_ENTRY, accessLogEntry);
try {
switch(request.getDispatcherType()) {
case REQUEST:
new HttpRequestDispatch(context, accessLogEntry, getMetricContext(request), request, response).dispatch();
break;
default:
if (log.isLoggable(Level.INFO)) {
log.info("Unexpected " + request.getDispatcherType() + "; " + formatAttributes(request));
}
break;
}
} catch (OverloadException e) {
// nop
} catch (RuntimeException e) {
throw new ExceptionWrapper(e);
}
}
Aggregations