diff options
author | Harald Musum <musum@yahooinc.com> | 2021-10-19 09:43:21 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2021-10-19 09:43:21 +0200 |
commit | 257815cd36c1f70292e5e2f4b1d6c8a742645a55 (patch) | |
tree | 682e944a9410aef61b83ebfbc41b58cfc93df61b /filedistribution/src | |
parent | 3ecfc6bcaf1735f4d7fe27639dd147c26f9b1517 (diff) |
Fewer retries of starting download of file reference
Not much point in trying many times, as we switch server if we fail,
so retrying more than 5 times is probably no point.
Diffstat (limited to 'filedistribution/src')
-rw-r--r-- | filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java | 29 |
1 files changed, 9 insertions, 20 deletions
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 c88501943ae..740bf23796f 100644 --- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java @@ -11,7 +11,6 @@ import com.yahoo.vespa.config.ConnectionPool; import java.io.File; import java.time.Duration; -import java.time.Instant; import java.util.Optional; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -52,27 +51,17 @@ public class FileReferenceDownloader { private void waitUntilDownloadStarted(FileReferenceDownload fileReferenceDownload) { FileReference fileReference = fileReferenceDownload.fileReference(); - Instant end = Instant.now().plus(downloadTimeout); - boolean downloadStarted = false; int retryCount = 0; do { - try { - if (startDownloadRpc(fileReferenceDownload, retryCount)) { - downloadStarted = true; - } else { - retryCount++; - long sleepTime = Math.min(sleepBetweenRetries.toMillis() * retryCount, - Math.max(0, Duration.between(Instant.now(), end).toMillis())); - Thread.sleep(sleepTime); - } - } - catch (InterruptedException e) { /* ignored */} - } while (Instant.now().isBefore(end) && !downloadStarted); + if (startDownloadRpc(fileReferenceDownload, retryCount)) + return; - if ( !downloadStarted) { - fileReferenceDownload.future().completeExceptionally(new RuntimeException("Failed getting file reference '" + fileReference.value() + "'")); - downloads.remove(fileReference); - } + try { Thread.sleep(sleepBetweenRetries.toMillis()); } catch (InterruptedException e) { /* ignored */} + retryCount++; + } while (retryCount < 5); + + fileReferenceDownload.future().completeExceptionally(new RuntimeException("Failed getting " + fileReference)); + downloads.remove(fileReference); } Future<Optional<File>> startDownload(FileReferenceDownload fileReferenceDownload) { @@ -99,7 +88,7 @@ public class FileReferenceDownloader { double timeoutSecs = (double) rpcTimeout.getSeconds(); timeoutSecs += retryCount * 10.0; connection.invokeSync(request, timeoutSecs); - Level logLevel = (retryCount > 5 ? Level.INFO : Level.FINE); + Level logLevel = (retryCount > 3 ? Level.INFO : Level.FINE); if (validateResponse(request)) { log.log(Level.FINE, () -> "Request callback, OK. Req: " + request + "\nSpec: " + connection + ", retry count " + retryCount); if (request.returnValues().get(0).asInt32() == 0) { |