diff options
author | Haakon Dybdahl <dybdahl@yahoo-inc.com> | 2017-01-26 08:35:10 +0100 |
---|---|---|
committer | Haakon Dybdahl <dybdahl@yahoo-inc.com> | 2017-01-26 08:52:05 +0100 |
commit | e24984c67d03d9fc4de679ddecc769684aff697b (patch) | |
tree | 4c32c489ada17411f88ea1618d1f8bb1afaf3992 /vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java | |
parent | 5014f2a78843fe25490df4b5bbaab8478275113e (diff) |
Make document API use max 40% of threads, and feeding use max 40%.
Diffstat (limited to 'vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java')
-rw-r--r-- | vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java index f6a6ed05e57..86468806d99 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.inject.Inject; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.yahoo.container.handler.ThreadpoolConfig; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.LoggingRequestHandler; @@ -53,16 +54,23 @@ public class RestApi extends LoggingRequestHandler { private final OperationHandler operationHandler; private SingleDocumentParser singleDocumentParser; private ObjectMapper mapper = new ObjectMapper(); - private AtomicInteger threadsAvailableForApi = new AtomicInteger(200 /*max concurrent requests */); + private AtomicInteger threadsAvailableForApi; @Inject public RestApi(Executor executor, AccessLog accessLog, DocumentmanagerConfig documentManagerConfig, - LoadTypeConfig loadTypeConfig) { + LoadTypeConfig loadTypeConfig, ThreadpoolConfig threadpoolConfig) { super(executor, accessLog); MessageBusParams params = new MessageBusParams(new LoadTypeSet(loadTypeConfig)); params.setDocumentmanagerConfig(documentManagerConfig); this.operationHandler = new OperationHandlerImpl(new MessageBusDocumentAccess(params)); this.singleDocumentParser = new SingleDocumentParser(new DocumentTypeManager(documentManagerConfig)); + // 40% of the threads can be blocked before we deny requests. + if (threadpoolConfig != null) { + threadsAvailableForApi = new AtomicInteger(Math.max((int) (0.4 * threadpoolConfig.maxthreads()), 1)); + } else { + log.warning("No config for threadpool, using 200 for max blocking threads for document rest API."); + threadsAvailableForApi = new AtomicInteger(200); + } } // For testing and development @@ -73,7 +81,7 @@ public class RestApi extends LoggingRequestHandler { int threadsAvailable) { super(executor, accessLog); this.operationHandler = operationHandler; - this.threadsAvailableForApi.set(threadsAvailable); + this.threadsAvailableForApi = new AtomicInteger(threadsAvailable); } @Override |