diff options
author | Harald Musum <musum@verizonmedia.com> | 2020-10-15 07:39:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-15 07:39:49 +0200 |
commit | 63097163bfe4f2868ee936c7e14fbf505e6ff242 (patch) | |
tree | 827263dce595e96ace811bbd45de30139c7f33e1 | |
parent | f07e7cde693a73d99d6d3d27dc3aa65e44d1958b (diff) |
Revert "Log more when downloading file fails"
4 files changed, 18 insertions, 28 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 9d35b4f0e32..31294faad05 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 Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2017 Yahoo Holdings. 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,6 +20,7 @@ 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; @@ -156,11 +157,7 @@ public class FileServer { boolean fileExists; try { - String client = request.target().toString(); - FileReferenceDownload fileReferenceDownload = new FileReferenceDownload(new FileReference(fileReference), - downloadFromOtherSourceIfNotFound, - client); - fileExists = hasFile(fileReference) || download(fileReferenceDownload); + fileExists = hasFile(fileReference) || download(fileReference, downloadFromOtherSourceIfNotFound); if (fileExists) startFileServing(fileReference, receiver); } catch (IllegalArgumentException e) { fileExists = false; @@ -176,16 +173,21 @@ 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(FileReferenceDownload fileReferenceDownload) { - if (fileReferenceDownload.downloadFromOtherSourceIfNotFound()) { + private boolean download(String fileReference, boolean downloadFromOtherSourceIfNotFound) { + if (downloadFromOtherSourceIfNotFound) { log.log(Level.FINE, "File not found, downloading from another source"); - return downloader.getFile(fileReferenceDownload).isPresent(); + return download(fileReference).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 3f6d6d0d257..55ee45482f9 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 Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2017 Yahoo Holdings. 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,9 +567,7 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { Stream.of(fileReferenceStrings) .map(FileReference::new) .forEach(fileReference -> downloader.downloadIfNeeded( - new FileReferenceDownload(fileReference, - false, /* downloadFromOtherSourceIfNotFound */ - req.target().toString()))); + new FileReferenceDownload(fileReference, false /* downloadFromOtherSourceIfNotFound */))); 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 7470ac0952d..f7b951e89d8 100644 --- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java @@ -5,7 +5,6 @@ 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; @@ -56,8 +55,7 @@ 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 + - "', removing from download queue: " + Exceptions.toMessageString(e)); + log.log(Level.WARNING, "Failed downloading '" + fileReferenceDownload.fileReference().value() + "', removing from download queue: " + e.getMessage()); 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 31e6eb5daab..fe501484faf 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 Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.filedistribution; @@ -15,17 +15,15 @@ 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, "unknown"); + this(fileReference, true); } - public FileReferenceDownload(FileReference fileReference, boolean downloadFromOtherSourceIfNotFound, String client) { + public FileReferenceDownload(FileReference fileReference, boolean downloadFromOtherSourceIfNotFound) { this.fileReference = fileReference; this.future = new CompletableFuture<>(); this.downloadFromOtherSourceIfNotFound = downloadFromOtherSourceIfNotFound; - this.client = client; } FileReference fileReference() { @@ -36,13 +34,7 @@ public class FileReferenceDownload { return future; } - public boolean downloadFromOtherSourceIfNotFound() { + boolean downloadFromOtherSourceIfNotFound() { return downloadFromOtherSourceIfNotFound; } - - @Override - public String toString() { - return fileReference + ", client: " + client; - } - } |