summaryrefslogtreecommitdiffstats
path: root/fileacquirer
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-04-12 14:03:32 +0200
committerHarald Musum <musum@oath.com>2018-04-12 14:03:32 +0200
commit74d79c0f474783c75e4f47d95eb676855a3dec52 (patch)
treecc8c7cbafea7a956719e885da093cbd6d90ebb7a /fileacquirer
parent96ac820857ad7ea6ab27e599ed7a227f1cd48a17 (diff)
Use shorter timeout when getting files
If something goes wrong in config proxy or config server when getting a file, it is be better to retry to make sure someone is actually trying to download the file than waiting the whole timeout for a response that will not come.
Diffstat (limited to 'fileacquirer')
-rw-r--r--fileacquirer/src/main/java/com/yahoo/filedistribution/fileacquirer/FileAcquirerImpl.java20
1 files changed, 10 insertions, 10 deletions
diff --git a/fileacquirer/src/main/java/com/yahoo/filedistribution/fileacquirer/FileAcquirerImpl.java b/fileacquirer/src/main/java/com/yahoo/filedistribution/fileacquirer/FileAcquirerImpl.java
index 7627e9f04fb..fca4b206fc9 100644
--- a/fileacquirer/src/main/java/com/yahoo/filedistribution/fileacquirer/FileAcquirerImpl.java
+++ b/fileacquirer/src/main/java/com/yahoo/filedistribution/fileacquirer/FileAcquirerImpl.java
@@ -125,6 +125,7 @@ class FileAcquirerImpl implements FileAcquirer {
supervisor.transport().shutdown().join();
}
+
/**
* Returns the path to a file or directory corresponding to the
* given file reference. File references are produced by the
@@ -133,7 +134,7 @@ class FileAcquirerImpl implements FileAcquirer {
* @throws TimeoutException if the file or directory could not be
* retrieved in time.
* @throws FileReferenceDoesNotExistException if the file is no
- * longer available(due to reloading of config).
+ * longer available (due to reloading of config).
*/
public File waitFor(FileReference fileReference, long timeout, TimeUnit timeUnit)
throws InterruptedException {
@@ -146,28 +147,27 @@ class FileAcquirerImpl implements FileAcquirer {
Request request = new Request("waitFor");
request.parameters().add(new StringValue(fileReference.value()));
- log.log(LogLevel.DEBUG, "InvokeSync waitFor " + fileReference + " with waiting time " + timeout + " " + timeUnit.name().toLowerCase());
- target.invokeSync(request, timer.timeLeft(TimeUnit.SECONDS));
+ double rpcTimeout = Math.min(timer.timeLeft(TimeUnit.SECONDS), 60.0);
+ log.log(LogLevel.DEBUG, "InvokeSync waitFor " + fileReference + " with " + rpcTimeout + " seconds timeout");
+ target.invokeSync(request, rpcTimeout);
if (request.checkReturnTypes("s")) {
return new File(request.returnValues().get(0).asString());
} else if (!request.isError()) {
- throw new RuntimeException("Invalid answer from config proxy: " + request.returnValues());
+ throw new RuntimeException("Invalid response: " + request.returnValues());
} else if (temporaryError(request.errorCode())) {
- log.log(LogLevel.INFO, "Retrying waitFor: " + request.errorCode() + " -- " + request.errorMessage());
+ log.log(LogLevel.INFO, "Retrying waitFor for " + fileReference + ": " + request.errorCode() + " -- " + request.errorMessage());
Thread.sleep(1000);
} else {
if (request.errorCode() == FileDistributionErrorCode.fileReferenceDoesNotExists)
throw new FileReferenceDoesNotExistException(fileReference.value());
else if (request.errorCode() == FileDistributionErrorCode.fileReferenceRemoved)
throw new FileReferenceRemovedException(fileReference.value());
- else {
- throw new RuntimeException("Wait for blocking failed:" +
- request.errorMessage() +
- " (" + request.errorCode() + ")");
- }
+ else
+ throw new RuntimeException("Wait for " + fileReference + " failed:" + request.errorMessage() + " (" + request.errorCode() + ")");
}
} while ( timer.isTimeLeft() );
throw new TimeoutException("Timed out waiting for " + fileReference + " after " + timeout + " " + timeUnit.name().toLowerCase());
}
+
}