diff options
author | Harald Musum <musum@verizonmedia.com> | 2020-10-14 14:53:48 +0200 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2020-10-14 14:53:48 +0200 |
commit | 69734747006ea6748796c3ad998a86a8ed208b71 (patch) | |
tree | c3beecd37a42355d8eca3da3edea2147cb687971 | |
parent | bb7814f7e0619a8b481969b407275b7b4c709385 (diff) |
Log more when downloading file fails
Include client info
4 files changed, 28 insertions, 18 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 31294faad05..9d35b4f0e32 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 @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.filedistribution; import com.google.inject.Inject; @@ -20,7 +20,6 @@ import com.yahoo.yolean.Exceptions; import java.io.File; import java.io.IOException; -import java.util.Optional; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.logging.Level; @@ -157,7 +156,11 @@ public class FileServer { boolean fileExists; try { - fileExists = hasFile(fileReference) || download(fileReference, downloadFromOtherSourceIfNotFound); + String client = request.target().toString(); + FileReferenceDownload fileReferenceDownload = new FileReferenceDownload(new FileReference(fileReference), + downloadFromOtherSourceIfNotFound, + client); + fileExists = hasFile(fileReference) || download(fileReferenceDownload); if (fileExists) startFileServing(fileReference, receiver); } catch (IllegalArgumentException e) { fileExists = false; @@ -173,21 +176,16 @@ public class FileServer { // downloadFromOtherSourceIfNotFound is true when the request comes from another config server. // This is to avoid config servers asking each other for a file that does not exist - private boolean download(String fileReference, boolean downloadFromOtherSourceIfNotFound) { - if (downloadFromOtherSourceIfNotFound) { + private boolean download(FileReferenceDownload fileReferenceDownload) { + if (fileReferenceDownload.downloadFromOtherSourceIfNotFound()) { log.log(Level.FINE, "File not found, downloading from another source"); - return download(fileReference).isPresent(); + return downloader.getFile(fileReferenceDownload).isPresent(); } else { log.log(Level.FINE, "File not found, will not download from another source since request came from another config server"); return false; } } - private Optional<File> download(String fileReference) { - /* downloadFromOtherSourceIfNotFound should be false here, since this request is from a config server */ - return downloader.getFile(new FileReferenceDownload(new FileReference(fileReference), false)); - } - public FileDownloader downloader() { return downloader; } 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 55ee45482f9..3f6d6d0d257 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 @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.rpc; import com.google.inject.Inject; @@ -567,7 +567,9 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { Stream.of(fileReferenceStrings) .map(FileReference::new) .forEach(fileReference -> downloader.downloadIfNeeded( - new FileReferenceDownload(fileReference, false /* downloadFromOtherSourceIfNotFound */))); + new FileReferenceDownload(fileReference, + false, /* downloadFromOtherSourceIfNotFound */ + req.target().toString()))); req.returnValues().add(new Int32Value(0)); }); } diff --git a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java index f7b951e89d8..7470ac0952d 100644 --- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java @@ -5,6 +5,7 @@ import com.yahoo.config.FileReference; import java.util.logging.Level; import com.yahoo.vespa.config.ConnectionPool; import com.yahoo.vespa.defaults.Defaults; +import com.yahoo.yolean.Exceptions; import java.io.File; import java.time.Duration; @@ -55,7 +56,8 @@ public class FileDownloader implements AutoCloseable { try { return getFutureFile(fileReferenceDownload).get(timeout.toMillis(), TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.WARNING, "Failed downloading '" + fileReferenceDownload.fileReference().value() + "', removing from download queue: " + e.getMessage()); + log.log(Level.WARNING, "Failed downloading '" + fileReferenceDownload + + "', removing from download queue: " + Exceptions.toMessageString(e)); fileReferenceDownloader.failedDownloading(fileReferenceDownload.fileReference()); return Optional.empty(); } diff --git a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownload.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownload.java index fe501484faf..31e6eb5daab 100644 --- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownload.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownload.java @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.filedistribution; @@ -15,15 +15,17 @@ public class FileReferenceDownload { // If a config server wants to download from another config server (because it does not have the // file itself) we set this flag to true to avoid an eternal loop private final boolean downloadFromOtherSourceIfNotFound; + private final String client; public FileReferenceDownload(FileReference fileReference) { - this(fileReference, true); + this(fileReference, true, "unknown"); } - public FileReferenceDownload(FileReference fileReference, boolean downloadFromOtherSourceIfNotFound) { + public FileReferenceDownload(FileReference fileReference, boolean downloadFromOtherSourceIfNotFound, String client) { this.fileReference = fileReference; this.future = new CompletableFuture<>(); this.downloadFromOtherSourceIfNotFound = downloadFromOtherSourceIfNotFound; + this.client = client; } FileReference fileReference() { @@ -34,7 +36,13 @@ public class FileReferenceDownload { return future; } - boolean downloadFromOtherSourceIfNotFound() { + public boolean downloadFromOtherSourceIfNotFound() { return downloadFromOtherSourceIfNotFound; } + + @Override + public String toString() { + return fileReference + ", client: " + client; + } + } |