summaryrefslogtreecommitdiffstats
path: root/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java
diff options
context:
space:
mode:
Diffstat (limited to 'configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java20
1 files changed, 11 insertions, 9 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;
}