diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2019-05-16 10:08:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-16 10:08:53 +0200 |
commit | 1ec30a3c7f3d6d831fdf9d1714d39d81a8a5ed47 (patch) | |
tree | 0c742ef7243741cddf0e2496a70f24ca47e5dad7 | |
parent | dac7c521fda1504e5a0ea415f760d9fdf1fbdf25 (diff) | |
parent | 155e12e4c35a0c456a3bdf45c040be3f34b1ab30 (diff) |
Merge pull request #9415 from vespa-engine/bjorncs/configserver-preps
Bjorncs/configserver preps
-rw-r--r-- | config/src/main/java/com/yahoo/vespa/config/JRTMethods.java | 16 | ||||
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java | 22 |
2 files changed, 20 insertions, 18 deletions
diff --git a/config/src/main/java/com/yahoo/vespa/config/JRTMethods.java b/config/src/main/java/com/yahoo/vespa/config/JRTMethods.java index be9aa8f5f85..1f9bd66972f 100644 --- a/config/src/main/java/com/yahoo/vespa/config/JRTMethods.java +++ b/config/src/main/java/com/yahoo/vespa/config/JRTMethods.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.config; import com.yahoo.jrt.Method; +import com.yahoo.jrt.MethodHandler; import com.yahoo.jrt.Request; /** @@ -12,10 +13,19 @@ public class JRTMethods { public static final String configV3getConfigMethodName = "config.v3.getConfig"; private static final String configV3GetConfigRequestTypes = "s"; private static final String configV3GetConfigResponseTypes = "sx"; + public static Method createConfigV3GetConfigMethod(Object handler, String handlerMethod) { - return new Method(configV3getConfigMethodName, configV3GetConfigRequestTypes, configV3GetConfigResponseTypes, - handler, handlerMethod) - .methodDesc("get config v3") + return addDescriptions( + new Method(configV3getConfigMethodName, configV3GetConfigRequestTypes, configV3GetConfigResponseTypes, handler, handlerMethod)); + } + + public static Method createConfigV3GetConfigMethod(MethodHandler methodHandler) { + return addDescriptions( + new Method(configV3getConfigMethodName, configV3GetConfigRequestTypes, configV3GetConfigResponseTypes, methodHandler)); + } + + private static Method addDescriptions(Method method) { + return method.methodDesc("get config v3") .paramDesc(0, "request", "config request") .returnDesc(0, "response", "config response") .returnDesc(1, "payload", "config response payload"); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java index 1df72522310..14c48687a40 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java @@ -79,8 +79,9 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { static final int TRACELEVEL_DEBUG = 9; private static final String THREADPOOL_NAME = "rpcserver worker pool"; private static final long SHUTDOWN_TIMEOUT = 60; + private static final int JRT_RPC_TRANSPORT_THREADS = 4; - private final Supervisor supervisor = new Supervisor(new Transport()); + private final Supervisor supervisor = new Supervisor(new Transport(JRT_RPC_TRANSPORT_THREADS)); private Spec spec; private final boolean useRequestVersion; private final boolean hostedVespa; @@ -144,11 +145,9 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { } /** - * Called by reflection from RPC. * Handles RPC method "config.v3.getConfig" requests. * Uses the template pattern to call methods in classes that extend RpcServer. */ - @SuppressWarnings({"UnusedDeclaration"}) public final void getConfigV3(Request req) { if (log.isLoggable(LogLevel.SPAM)) { log.log(LogLevel.SPAM, getConfigMethodName); @@ -158,21 +157,17 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { } /** - * Called by reflection from RPC. * Returns 0 if server is alive. */ - @SuppressWarnings("UnusedDeclaration") public final void ping(Request req) { req.returnValues().add(new Int32Value(0)); } /** - * Called by reflection from RPC. * Returns a String with statistics data for the server. * * @param req a Request */ - @SuppressWarnings("UnusedDeclaration") public void printStatistics(Request req) { req.returnValues().add(new StringValue("Delayed responses queue size: " + delayedConfigResponses.size())); } @@ -211,16 +206,15 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { */ private void setUpHandlers() { // The getConfig method in this class will handle RPC calls for getting config - getSupervisor().addMethod(JRTMethods.createConfigV3GetConfigMethod(this, getConfigMethodName)); - getSupervisor().addMethod(new Method("ping", "", "i", this, "ping") + getSupervisor().addMethod(JRTMethods.createConfigV3GetConfigMethod(this::getConfigV3)); + getSupervisor().addMethod(new Method("ping", "", "i", this::ping) .methodDesc("ping") .returnDesc(0, "ret code", "return code, 0 is OK")); - getSupervisor().addMethod(new Method("printStatistics", "", "s", this, "printStatistics") + getSupervisor().addMethod(new Method("printStatistics", "", "s", this::printStatistics) .methodDesc("printStatistics") .returnDesc(0, "statistics", "Statistics for server")); - getSupervisor().addMethod(new Method("filedistribution.serveFile", "si", "is", this, "serveFile")); - getSupervisor().addMethod(new Method("filedistribution.setFileReferencesToDownload", "S", "i", - this, "setFileReferencesToDownload") + getSupervisor().addMethod(new Method("filedistribution.serveFile", "si", "is", this::serveFile)); + getSupervisor().addMethod(new Method("filedistribution.setFileReferencesToDownload", "S", "i", this::setFileReferencesToDownload) .methodDesc("set which file references to download") .paramDesc(0, "file references", "file reference to download") .returnDesc(0, "ret", "0 if success, 1 otherwise")); @@ -547,14 +541,12 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { } } - @SuppressWarnings("UnusedDeclaration") public final void serveFile(Request request) { request.detach(); FileServer.Receiver receiver = new ChunkedFileReceiver(request.target()); fileServer.serveFile(request.parameters().get(0).asString(), request.parameters().get(1).asInt32() == 0, request, receiver); } - @SuppressWarnings({"UnusedDeclaration"}) public final void setFileReferencesToDownload(Request req) { String[] fileReferenceStrings = req.parameters().get(0).asStringArray(); Stream.of(fileReferenceStrings) |