diff options
author | Harald Musum <musum@yahoo-inc.com> | 2017-11-23 22:00:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-23 22:00:00 +0100 |
commit | 30f6004e1a9ed864eff6edc76ed6b761633e4461 (patch) | |
tree | 207468e06caa1c4240c9599616cf7b203f293130 | |
parent | e603b021de8b94ba2a70799b7f70da439bcc42b5 (diff) | |
parent | 480f78725c6b59861105fe138686120ea0a60851 (diff) |
Merge pull request #4262 from vespa-engine/revert-4260-hmusum/choose-new-connection-if-file-reference-not-found
Revert "Hmusum/choose new connection if file reference not found"
3 files changed, 10 insertions, 36 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java index 3561a5cba9a..9dc94c9fe93 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java @@ -2,29 +2,24 @@ package com.yahoo.vespa.config.server.filedistribution; import com.google.inject.Inject; -import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.FileReference; import com.yahoo.config.model.api.FileDistribution; import com.yahoo.config.subscription.ConfigSourceSet; import com.yahoo.io.IOUtils; -import com.yahoo.net.HostName; import com.yahoo.vespa.config.JRTConnectionPool; -import com.yahoo.vespa.config.server.ConfigServerSpec; import com.yahoo.vespa.filedistribution.FileDownloader; import java.io.File; import java.io.IOException; -import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.logging.Logger; -import java.util.stream.Collectors; public class FileServer { private static final Logger log = Logger.getLogger(FileServer.class.getName()); private final FileDirectory root; private final ExecutorService executor; - private final FileDownloader downloader; + private final FileDownloader downloader = new FileDownloader(new JRTConnectionPool(ConfigSourceSet.createDefault())); public static class ReplayStatus { private final int code; @@ -43,21 +38,15 @@ public class FileServer { } @Inject - public FileServer(ConfigserverConfig configserverConfig) { - this(createConnectionPool(ConfigServerSpec.fromConfig(configserverConfig)), FileDistribution.getDefaultFileDBPath()); + public FileServer() { + this(FileDistribution.getDefaultFileDBPath()); } - // For testing only public FileServer(File rootDir) { - this(new JRTConnectionPool(new ConfigSourceSet("tcp/localhost:19090")), rootDir); + this(rootDir, Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())); } - public FileServer(JRTConnectionPool jrtConnectionPool, File rootDir) { - this(jrtConnectionPool, rootDir, Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())); - } - - public FileServer(JRTConnectionPool jrtConnectionPool, File rootDir, ExecutorService executor) { - this.downloader = new FileDownloader(jrtConnectionPool); + public FileServer(File rootDir, ExecutorService executor) { this.root = new FileDirectory(rootDir); this.executor = executor; } @@ -105,14 +94,4 @@ public class FileServer { public void download(FileReference fileReference) { downloader.getFile(fileReference); } - - // Connection pool with all config servers except this one - private static JRTConnectionPool createConnectionPool(List<com.yahoo.config.model.api.ConfigServerSpec> configServerSpecs) { - return new JRTConnectionPool( - new ConfigSourceSet(configServerSpecs - .stream() - .filter(spec -> !spec.getHostName().equals(HostName.getLocalhost())) - .map(spec -> "tcp/" + spec.getHostName() + ":" + spec.getConfigServerPort()) - .collect(Collectors.toList()))); - } } diff --git a/configserver/src/main/resources/configserver-app/services.xml b/configserver/src/main/resources/configserver-app/services.xml index fbab854ae9e..635ce07e727 100644 --- a/configserver/src/main/resources/configserver-app/services.xml +++ b/configserver/src/main/resources/configserver-app/services.xml @@ -34,7 +34,6 @@ <component id="com.yahoo.config.provision.Zone" bundle="config-provisioning" /> <component id="com.yahoo.vespa.config.server.application.ApplicationConvergenceChecker" bundle="configserver" /> <component id="com.yahoo.vespa.config.server.application.HttpProxy" bundle="configserver" /> - <component id="com.yahoo.vespa.config.server.filedistribution.FileServer" bundle="configserver" /> <component id="com.yahoo.vespa.serviceview.ConfigServerLocation" bundle="configserver" /> diff --git a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java index cd07591c00c..08595662f36 100644 --- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java @@ -54,7 +54,6 @@ class FileReferenceDownloader { private final FileReceiver fileReceiver; FileReferenceDownloader(File downloadDirectory, ConnectionPool connectionPool, Duration timeout) { - log.log(LogLevel.DEBUG, "FileReferenceDownloader connection pool:\n" + connectionPool); this.connectionPool = connectionPool; this.downloadTimeout = timeout; readFromQueueExecutor.submit(this::readFromQueue); @@ -108,7 +107,8 @@ class FileReferenceDownloader { Thread.sleep(10); } catch (InterruptedException e) { /* ignore for now */} } else { - log.log(LogLevel.INFO, "Will download file reference '" + fileReferenceDownload.fileReference().value() + "'"); + log.log(LogLevel.INFO, "Polling queue, found file reference '" + + fileReferenceDownload.fileReference().value() + "' to download"); downloadExecutor.submit(() -> startDownload(fileReferenceDownload.fileReference(), downloadTimeout, fileReferenceDownload)); } } while (true); @@ -133,16 +133,12 @@ class FileReferenceDownloader { return true; } else { log.log(LogLevel.INFO, "File reference '" + fileReference.value() + "' not found for " + connection.getAddress()); - connectionPool.setNewCurrentConnection(); return false; } } else { - log.log(LogLevel.WARNING, "Request failed. Req: " + request + "\nSpec: " + connection.getAddress() + - ", error code: " + request.errorCode()); - if (request.isError() && request.errorCode() == ErrorCode.CONNECTION || request.errorCode() == ErrorCode.TIMEOUT) { - log.log(LogLevel.WARNING, "Setting error for connection " + connection.getAddress()); - connectionPool.setError(connection, request.errorCode()); - } + log.log(LogLevel.WARNING, "Request failed. Req: " + request + "\nSpec: " + connection.getAddress()); + if (request.isError() && request.errorCode() == ErrorCode.CONNECTION) + connection.setError(request.errorCode()); return false; } } |