diff options
author | Håkon Hallingstad <hakon@oath.com> | 2017-12-19 10:01:48 +0100 |
---|---|---|
committer | Håkon Hallingstad <hakon@oath.com> | 2017-12-19 10:01:48 +0100 |
commit | eec73cc55e16555eb4aada336eecfc757a184456 (patch) | |
tree | 88cbd95ee3f75fd15d6c3d9233ca3eb4ec3d887f /node-admin | |
parent | b5e9f98990add503bc2d58022a162269f78f93b0 (diff) |
Add pause between retries to config server
Diffstat (limited to 'node-admin')
2 files changed, 15 insertions, 0 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutor.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutor.java index 3576f37eb9a..b1d49fba137 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutor.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutor.java @@ -48,6 +48,7 @@ public class ConfigServerHttpRequestExecutor { private final ObjectMapper mapper = new ObjectMapper(); private final CloseableHttpClient client; private final List<URI> configServerHosts; + private int pauseBetweenRetriesMs = 10_000; @Override public void finalize() throws Throwable { @@ -60,6 +61,10 @@ public class ConfigServerHttpRequestExecutor { super.finalize(); } + public void eliminatePauseBetweenRetriesForTesting() { + pauseBetweenRetriesMs = 0; + } + public static ConfigServerHttpRequestExecutor create(Collection<URI> configServerUris) { PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(getConnectionSocketFactoryRegistry()); cm.setMaxTotal(200); // Increase max total connections to 200, which should be enough @@ -110,6 +115,15 @@ public class ConfigServerHttpRequestExecutor { Exception lastException = null; for (int loopRetry = 0; loopRetry < MAX_LOOPS; loopRetry++) { for (URI configServer : configServerHosts) { + if (lastException != null) { + try { + // Avoid overloading the config server + Thread.sleep(pauseBetweenRetriesMs); + } catch (InterruptedException e) { + // Ignore + } + } + final CloseableHttpResponse response; try { response = client.execute(requestFactory.createRequest(configServer)); diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/noderepository/NodeRepositoryImplTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/noderepository/NodeRepositoryImplTest.java index 45f5de3d1a5..dfc591d63d5 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/noderepository/NodeRepositoryImplTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/noderepository/NodeRepositoryImplTest.java @@ -58,6 +58,7 @@ public class NodeRepositoryImplTest { final int port = findRandomOpenPort(); requestExecutor = ConfigServerHttpRequestExecutor.create( Collections.singleton(URI.create("http://127.0.0.1:" + port))); + requestExecutor.eliminatePauseBetweenRetriesForTesting(); container = JDisc.fromServicesXml(ContainerConfig.servicesXmlV2(port), Networking.enable); } |