aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/main/java/com/yahoo/container/core/config/FileAcquirerBundleInstaller.java
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2020-04-17 21:40:16 +0200
committergjoranv <gv@verizonmedia.com>2020-04-17 21:40:16 +0200
commit46073355dcb33c08af3aad5cf54daaf1e9716628 (patch)
treeb311511da83d113b33f3aed665904612543383e2 /container-core/src/main/java/com/yahoo/container/core/config/FileAcquirerBundleInstaller.java
parent4341860afe9a86af5046eba47b42b0343a6369b6 (diff)
Wait instead of calling waitFor twice when bundle is not readable
Diffstat (limited to 'container-core/src/main/java/com/yahoo/container/core/config/FileAcquirerBundleInstaller.java')
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/config/FileAcquirerBundleInstaller.java30
1 files changed, 14 insertions, 16 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/FileAcquirerBundleInstaller.java b/container-core/src/main/java/com/yahoo/container/core/config/FileAcquirerBundleInstaller.java
index 599546c497b..72951e67b4e 100644
--- a/container-core/src/main/java/com/yahoo/container/core/config/FileAcquirerBundleInstaller.java
+++ b/container-core/src/main/java/com/yahoo/container/core/config/FileAcquirerBundleInstaller.java
@@ -26,26 +26,24 @@ public class FileAcquirerBundleInstaller implements BundleInstaller {
@Override
public List<Bundle> installBundles(FileReference reference, Osgi osgi) throws InterruptedException {
- File file = acquireFile(reference);
-
- // Retrying is added in case FileAcquirer returns right before the file is actually ready.
- // This happened on rare occasions due to a (fixed) bug in file distribution.
- int retries = 0;
- while (notReadable(file) && retries < 1) {
- log.warning("Unable to open bundle file with reference '" + reference + "'. Retrying.");
- file = acquireFile(reference);
- retries++;
- }
+ File file = fileAcquirer.waitFor(reference, 7, TimeUnit.DAYS);
if (notReadable(file)) {
- com.yahoo.protect.Process.logAndDie("Shutting down - unable to read bundle file with reference '" + reference
- + "' and path " + file.getAbsolutePath());
+ // Wait a few sec in case FileAcquirer returns right before the file is actually ready.
+ // This happened on rare occasions due to a (fixed) bug in file distribution.
+ log.warning("Unable to open bundle file with reference '" + reference + "'. Waiting for up to 5 sec.");
+ int retries = 0;
+ while (notReadable(file) && retries < 10) {
+ Thread.sleep(500);
+ retries++;
+ }
+ if (notReadable(file)) {
+ com.yahoo.protect.Process.logAndDie("Shutting down - unable to read bundle file with reference '" + reference
+ + "' and path " + file.getAbsolutePath());
+ }
}
- return osgi.install(file.getAbsolutePath());
- }
- private File acquireFile(FileReference reference) throws InterruptedException {
- return fileAcquirer.waitFor(reference, 7, TimeUnit.DAYS);
+ return osgi.install(file.getAbsolutePath());
}
private static boolean notReadable(File file) {