diff options
author | gjoranv <gv@verizonmedia.com> | 2020-06-09 12:11:34 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2020-06-09 12:11:34 +0200 |
commit | e9b5925902db2eab3632663212502ccff3942f63 (patch) | |
tree | 0ccf6a47add0523d475fc1a82783530f3af93175 | |
parent | e7b2ad27182845a21c045c906b83014f1f7ffebb (diff) |
Add public ctor in FileDownloader that takes a downloadDirectory
+ Use it in the ApplicationPackageMaintainer
2 files changed, 6 insertions, 10 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ApplicationPackageMaintainer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ApplicationPackageMaintainer.java index 03abdba643d..9ab65be7dab 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ApplicationPackageMaintainer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ApplicationPackageMaintainer.java @@ -45,14 +45,13 @@ public class ApplicationPackageMaintainer extends ConfigServerMaintainer { distributeApplicationPackage = Flags.CONFIGSERVER_DISTRIBUTE_APPLICATION_PACKAGE.bindTo(flagSource); downloadDirectory = new File(Defaults.getDefaults().underVespaHome(configserverConfig.fileReferencesDir())); - if (distributeApplicationPackage.value()) assertDownloadDirectoryIsDefault(downloadDirectory); } @Override protected void maintain() { if (! distributeApplicationPackage.value()) return; - var fileDownloader = new FileDownloader(createConnectionPool(configserverConfig)); + var fileDownloader = new FileDownloader(createConnectionPool(configserverConfig), downloadDirectory); try { for (var applicationId : applicationRepository.listApplications()) { RemoteSession session = applicationRepository.getActiveSession(applicationId); @@ -76,11 +75,4 @@ public class ApplicationPackageMaintainer extends ConfigServerMaintainer { return ! fileReferencesOnDisk.contains(applicationPackageReference.value()); } - // Required to use FileDownloader because it has no public ctor that takes a directory. - private static void assertDownloadDirectoryIsDefault(File fileReferencesDir) { - if (fileReferencesDir != FileDownloader.defaultDownloadDirectory) throw new IllegalArgumentException( - "Files must be downloaded to the default download directory (" - + FileDownloader.defaultDownloadDirectory + "), not " + fileReferencesDir); - } - } 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 a68d2860874..739f24bb8a2 100644 --- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java @@ -34,7 +34,11 @@ public class FileDownloader { private final FileReferenceDownloader fileReferenceDownloader; public FileDownloader(ConnectionPool connectionPool) { - this(connectionPool, defaultDownloadDirectory , defaultDownloadDirectory , Duration.ofMinutes(15), Duration.ofSeconds(10)); + this(connectionPool, defaultDownloadDirectory ); + } + + public FileDownloader(ConnectionPool connectionPool, File downloadDirectory) { + this(connectionPool, downloadDirectory , downloadDirectory , Duration.ofMinutes(15), Duration.ofSeconds(10)); } FileDownloader(ConnectionPool connectionPool, File downloadDirectory, File tmpDirectory, Duration timeout, Duration sleepBetweenRetries) { |