aboutsummaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2017-11-23 08:45:52 +0100
committerHarald Musum <musum@oath.com>2017-11-23 08:45:52 +0100
commiteef3f7c477de9033584da18f830694211f1c180f (patch)
treeec0cfbe9e0556b4b9770e37b23bc80f125bc89e6 /configserver
parent0f3ec8f7dc2629b22f542fbbfdf51254cc537041 (diff)
Add support for downloading from another config server
If a request for a file reference cannot be fulfilled, ask another config server for the file. Handle connection errors when downloading files. Fixed bundle issues.
Diffstat (limited to 'configserver')
-rw-r--r--configserver/pom.xml5
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java8
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java4
3 files changed, 15 insertions, 2 deletions
diff --git a/configserver/pom.xml b/configserver/pom.xml
index 4ebb76bd5fe..30d92dc7650 100644
--- a/configserver/pom.xml
+++ b/configserver/pom.xml
@@ -126,6 +126,11 @@
</dependency>
<dependency>
<groupId>com.yahoo.vespa</groupId>
+ <artifactId>filedistribution</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
<artifactId>filedistributionmanager</artifactId>
<version>${project.version}</version>
</dependency>
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 a504cd120ee..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
@@ -4,7 +4,10 @@ package com.yahoo.vespa.config.server.filedistribution;
import com.google.inject.Inject;
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.vespa.config.JRTConnectionPool;
+import com.yahoo.vespa.filedistribution.FileDownloader;
import java.io.File;
import java.io.IOException;
@@ -16,6 +19,7 @@ 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 = new FileDownloader(new JRTConnectionPool(ConfigSourceSet.createDefault()));
public static class ReplayStatus {
private final int code;
@@ -86,4 +90,8 @@ public class FileServer {
// TODO remove once verified in system tests.
log.info("Done serving reference '" + reference.toString() + "' with file '" + file.getAbsolutePath() + "'");
}
+
+ public void download(FileReference fileReference) {
+ downloader.getFile(fileReference);
+ }
}
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 7c5adb3b932..d17cdf722ea 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
@@ -21,7 +21,6 @@ import com.yahoo.jrt.StringValue;
import com.yahoo.jrt.Supervisor;
import com.yahoo.jrt.Target;
import com.yahoo.jrt.Transport;
-import com.yahoo.jrt.Value;
import com.yahoo.log.LogLevel;
import com.yahoo.vespa.config.ErrorCode;
import com.yahoo.vespa.config.JRTMethods;
@@ -249,7 +248,6 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener {
}
for (int i = 0; i < responsesSent; i++) {
-
try {
completionService.take();
} catch (InterruptedException e) {
@@ -469,6 +467,8 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener {
: FileApiErrorCodes.NOT_FOUND;
if (result == FileApiErrorCodes.OK) {
fileServer.startFileServing(fileReference, new FileReceiver(request.target()));
+ } else {
+ fileServer.download(new FileReference(fileReference));
}
} catch (IllegalArgumentException e) {
result = FileApiErrorCodes.NOT_FOUND;