diff options
author | Harald Musum <musum@verizonmedia.com> | 2021-03-17 11:55:33 +0100 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2021-03-17 11:55:33 +0100 |
commit | 64685530be978ae20e45da5d39ad3b31cf2a45e3 (patch) | |
tree | 2158ea647c67a67d178926220e56ab2825028901 /filedistribution/src/main | |
parent | e91a0341b66180d8a0ac8f1a8f17b0fcd4e5a30f (diff) |
Reduce timeout when downloading a file and backoff if it fails
Diffstat (limited to 'filedistribution/src/main')
-rw-r--r-- | filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java | 5 | ||||
-rw-r--r-- | filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java | 6 |
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 */} |