aboutsummaryrefslogtreecommitdiffstats
path: root/filedistribution
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2021-03-17 11:55:33 +0100
committerHarald Musum <musum@verizonmedia.com>2021-03-17 11:55:33 +0100
commit64685530be978ae20e45da5d39ad3b31cf2a45e3 (patch)
tree2158ea647c67a67d178926220e56ab2825028901 /filedistribution
parente91a0341b66180d8a0ac8f1a8f17b0fcd4e5a30f (diff)
Reduce timeout when downloading a file and backoff if it fails
Diffstat (limited to 'filedistribution')
-rw-r--r--filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java5
-rw-r--r--filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java6
2 files changed, 7 insertions, 4 deletions
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 beed82ad931..b1e43e4cee1 100644
--- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java
+++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.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;
import com.yahoo.config.FileReference;
@@ -39,7 +39,8 @@ public class FileDownloader implements AutoCloseable {
}
public FileDownloader(ConnectionPool connectionPool, File downloadDirectory) {
- this(connectionPool, downloadDirectory , downloadDirectory , Duration.ofMinutes(15), Duration.ofSeconds(10));
+ // TODO: Reduce timeout even more, timeout is so long that we might get starvation
+ this(connectionPool, downloadDirectory, downloadDirectory, Duration.ofMinutes(5), Duration.ofSeconds(10));
}
public FileDownloader(ConnectionPool connectionPool, File downloadDirectory, File tmpDirectory, Duration timeout, Duration sleepBetweenRetries) {
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 e77e8530f03..9f872ac7042 100644
--- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java
+++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.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;
import com.yahoo.concurrent.DaemonThreadFactory;
@@ -69,7 +69,9 @@ public class FileReferenceDownloader {
downloadStarted = true;
} else {
retryCount++;
- Thread.sleep(sleepBetweenRetries.toMillis());
+ long sleepTime = Math.min(sleepBetweenRetries.toMillis() * retryCount,
+ Math.max(0, Duration.between(Instant.now(), end).toMillis()));
+ Thread.sleep(sleepTime);
}
}
catch (InterruptedException e) { /* ignored */}