diff options
4 files changed, 21 insertions, 8 deletions
diff --git a/config-lib/src/main/java/com/yahoo/config/PathNode.java b/config-lib/src/main/java/com/yahoo/config/PathNode.java index b63dad4d1a7..9d73b5e23c2 100644 --- a/config-lib/src/main/java/com/yahoo/config/PathNode.java +++ b/config-lib/src/main/java/com/yahoo/config/PathNode.java @@ -14,7 +14,6 @@ import java.util.Map; * Represents a 'path' in a {@link ConfigInstance}, usually a filename. * * @author gjoranv - * @since 5.1.30 */ public class PathNode extends LeafNode<Path> { diff --git a/container-core/src/main/java/com/yahoo/container/core/BundleLoaderProperties.java b/container-core/src/main/java/com/yahoo/container/core/BundleLoaderProperties.java index c94dc30fd6f..ee12c7d4c9f 100644 --- a/container-core/src/main/java/com/yahoo/container/core/BundleLoaderProperties.java +++ b/container-core/src/main/java/com/yahoo/container/core/BundleLoaderProperties.java @@ -3,12 +3,13 @@ package com.yahoo.container.core; /** * @author gjoranv - * @since 5.46 */ public interface BundleLoaderProperties { + // TODO: This should be removed. The prefix is used to separate the bundles in BundlesConfig // into those that are transferred with filedistribution and those that are preinstalled // on disk. Instead, the model should have put them in two different configs. I.e. create a new // config 'preinstalled-bundles.def'. - public static final String DISK_BUNDLE_PREFIX = "file:"; + String DISK_BUNDLE_PREFIX = "file:"; + } diff --git a/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java b/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java index eceb41f9739..c0a68086212 100644 --- a/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java +++ b/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java @@ -95,7 +95,7 @@ public class BundleLoader { log.info("Installing bundle from disk with reference '" + reference.value() + "'"); File file = new File(referenceFileName); - if (!file.exists()) { + if ( ! file.exists()) { throw new IllegalArgumentException("Reference '" + reference.value() + "' not found on disk."); } diff --git a/model-evaluation/src/main/java/ai/vespa/models/evaluation/RankProfilesConfigImporter.java b/model-evaluation/src/main/java/ai/vespa/models/evaluation/RankProfilesConfigImporter.java index 98c80ace047..9af4022b170 100644 --- a/model-evaluation/src/main/java/ai/vespa/models/evaluation/RankProfilesConfigImporter.java +++ b/model-evaluation/src/main/java/ai/vespa/models/evaluation/RankProfilesConfigImporter.java @@ -15,6 +15,7 @@ import com.yahoo.tensor.TensorType; import com.yahoo.tensor.serialization.TypedBinaryFormat; import com.yahoo.vespa.config.search.RankProfilesConfig; import com.yahoo.vespa.config.search.core.RankingConstantsConfig; +import com.yahoo.vespa.defaults.Defaults; import java.io.File; import java.io.IOException; @@ -121,16 +122,28 @@ class RankProfilesConfigImporter { private Tensor readTensorFromFile(String name, TensorType type, String fileReference) { try { + // TODO: Only allow these two fallbacks in testing mode if (fileReference.isEmpty()) { // this may be the case in unit tests log.warning("Got empty file reference for constant '" + name + "', using an empty tensor"); return Tensor.from(type, "{}"); } - if ( ! new File(fileReference).exists()) { // this may be the case in unit tests - log.warning("Got empty file reference for constant '" + name + "', using an empty tensor"); + File dir = new File(Defaults.getDefaults().underVespaHome("var/db/vespa/filedistribution"), fileReference); + if ( ! dir.exists()) { // this may be the case in unit tests + log.warning("Got reference to nonexisting file " + dir + "e for constant '" + name + + "', using an empty tensor"); return Tensor.from(type, "{}"); } - return TypedBinaryFormat.decode(Optional.of(type), - GrowableByteBuffer.wrap(IOUtils.readFileBytes(new File(fileReference)))); + + // TODO: Move these 2 lines to FileReference + dir = new File(Defaults.getDefaults().underVespaHome("var/db/vespa/filedistribution"), fileReference); + File file = dir.listFiles()[0]; // directory contains one file having the original name + + if (file.getName().endsWith(".tbf")) + return TypedBinaryFormat.decode(Optional.of(type), + GrowableByteBuffer.wrap(IOUtils.readFileBytes(file))); + else + throw new IllegalArgumentException("Constant files on other formats than .tbf are not supported, got " + + file + " for constant " + name); // TODO: Support json and json.lz4 } catch (IOException e) { |