summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-09-11 14:41:51 +0200
committerJon Bratseth <bratseth@oath.com>2018-09-11 14:41:51 +0200
commit94d17a924f45b7f5fe76038f081de9638e1dcedd (patch)
treef6df21eb7a2390e5bec9176e7e5a0ca219e04f97 /config-model
parent029ed1bba2c00771d914f98d3aa38a64822473c7 (diff)
Refactor
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/RankingConstant.java23
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java7
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java13
3 files changed, 19 insertions, 24 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstant.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstant.java
index a2bdc6834c9..97d911d5822 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstant.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstant.java
@@ -1,14 +1,21 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition;
+import com.yahoo.config.FileReference;
import com.yahoo.tensor.TensorType;
+import com.yahoo.vespa.model.AbstractService;
+import com.yahoo.vespa.model.utils.FileSender;
+import java.util.Collection;
import java.util.Objects;
/**
- * Represents a global ranking constant
+ * A global ranking constant distributed using file distribution.
+ * Ranking constants must be sent to some services to be useful - this is done
+ * by calling the sentTo method during the prepare phase of building models.
*
* @author arnej
+ * @author bratseth
*/
public class RankingConstant {
@@ -49,14 +56,16 @@ public class RankingConstant {
this.pathType = PathType.URI;
}
- /**
- * Set the internally generated reference to this file used to identify this instance of the file for
- * file distribution.
- */
- public void setFileReference(String fileReference) { this.fileReference = fileReference; }
-
public void setType(TensorType tensorType) { this.tensorType = tensorType; }
+ /** Initiate sending of theis constant to some services over file distribution */
+ public void sendTo(Collection<? extends AbstractService> services) {
+ FileReference reference = (pathType == RankingConstant.PathType.FILE)
+ ? FileSender.sendFileToServices(path, services)
+ : FileSender.sendUriToServices(path, services);
+ this.fileReference = reference.value();
+ }
+
public String getName() { return name; }
public String getFileName() { return path; }
public String getUri() { return path; }
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java
index 5ac1418c0c7..e354c52092f 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java
@@ -40,12 +40,7 @@ public class RankingConstants {
/** Initiate sending of these constants to some services over file distribution */
public void sendTo(Collection<? extends AbstractService> services) {
- for (RankingConstant constant : constants.values()) {
- FileReference reference = (constant.getPathType() == RankingConstant.PathType.FILE)
- ? FileSender.sendFileToServices(constant.getFileName(), services)
- : FileSender.sendUriToServices(constant.getUri(), services);
- constant.setFileReference(reference.value());
- }
+ constants.values().forEach(constant -> constant.sendTo(services));
}
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java
index 83da5d96418..fbbf029d5f1 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java
@@ -1,16 +1,13 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.search;
-import com.yahoo.config.FileReference;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.config.model.producer.UserConfigRepo;
import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig;
import com.yahoo.search.config.IndexInfoConfig;
-import com.yahoo.searchdefinition.RankingConstant;
import com.yahoo.vespa.config.search.AttributesConfig;
import com.yahoo.vespa.config.search.RankProfilesConfig;
import com.yahoo.vespa.configdefinition.IlscriptsConfig;
-import com.yahoo.vespa.model.utils.FileSender;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -36,14 +33,8 @@ public abstract class AbstractSearchCluster extends AbstractConfigProducer
protected List<SearchDefinitionSpec> localSDS = new LinkedList<>();
public void prepareToDistributeFiles(List<SearchNode> backends) {
- for (SearchDefinitionSpec sds : localSDS) {
- for (RankingConstant constant : sds.getSearchDefinition().getSearch().rankingConstants().asMap().values()) {
- FileReference reference = (constant.getPathType() == RankingConstant.PathType.FILE)
- ? FileSender.sendFileToServices(constant.getFileName(), backends)
- : FileSender.sendUriToServices(constant.getUri(), backends);
- constant.setFileReference(reference.value());
- }
- }
+ for (SearchDefinitionSpec sds : localSDS)
+ sds.getSearchDefinition().getSearch().rankingConstants().sendTo(backends);
}
public static final class IndexingMode {