summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2018-04-12 12:54:23 +0000
committerArne Juul <arnej@yahoo-inc.com>2018-04-12 13:37:39 +0000
commit65b6b13547ee0778fa66cc24619b44cabed9e3d3 (patch)
tree966aab798f2062bf019c0836a6d28ffb7dec2f10 /config-model
parent09cef777222924cc70dd4270ba2bc7cfac396a00 (diff)
refactor, saving just the state we need to
* avoid caching DeployState since we want to free those resources after the model is completely built.
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/Admin.java10
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainer.java2
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/Container.java10
-rwxr-xr-xconfig-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java13
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/component/AccessLogComponent.java17
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/xml/AccessLogBuilder.java13
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java9
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java10
8 files changed, 32 insertions, 52 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/Admin.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/Admin.java
index b1cc6257a7a..3330910a797 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/Admin.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/Admin.java
@@ -39,7 +39,7 @@ public class Admin extends AbstractConfigProducer implements Serializable {
private static final long serialVersionUID = 1L;
- private final DeployState deployState;
+ private final boolean isHostedVespa;
private final Monitoring monitoring;
private final Metrics metrics;
private final Map<String, MetricsConsumer> legacyMetricsConsumers;
@@ -73,7 +73,7 @@ public class Admin extends AbstractConfigProducer implements Serializable {
boolean multitenant,
FileDistributionConfigProducer fileDistributionConfigProducer) {
super(parent, "admin");
- this.deployState = deployStateFrom(parent);
+ this.isHostedVespa = stateIsHosted(deployStateFrom(parent));
this.monitoring = monitoring;
this.metrics = metrics;
this.legacyMetricsConsumers = legacyMetricsConsumers;
@@ -140,14 +140,10 @@ public class Admin extends AbstractConfigProducer implements Serializable {
return zooKeepersConfigProvider;
}
- public boolean isHostedVespa() {
- return stateIsHosted(deployState);
- }
-
public void getConfig(LogdConfig.Builder builder) {
builder.
logserver(new LogdConfig.Logserver.Builder().
- use(!isHostedVespa()).
+ use(!isHostedVespa).
host(logserver.getHostName()).
port(logserver.getRelativePort(1)));
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainer.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainer.java
index 4233d9a6f61..31e2c2e7a3b 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainer.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainer.java
@@ -70,7 +70,7 @@ public class ClusterControllerContainer extends Container implements
addBundle("file:" + getDefaults().underVespaHome("lib/jars/zkfacade-jar-with-dependencies.jar"));
log.log(LogLevel.DEBUG, "Adding access log for cluster controller ...");
- addComponent(new AccessLogComponent(AccessLogComponent.AccessLogType.queryAccessLog, "controller", deployStateFrom(parent)));
+ addComponent(new AccessLogComponent(AccessLogComponent.AccessLogType.queryAccessLog, "controller", stateIsHosted(deployStateFrom(parent))));
}
@Override
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java b/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
index 5b07a966a82..063c295e33c 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
@@ -56,7 +56,7 @@ public class Container extends AbstractService implements
private final AbstractConfigProducer parent;
private final String name;
- private final DeployState deployState;
+ private final boolean isHostedVespa;
private String clusterName = null;
private boolean rpcServerEnabled = true;
@@ -96,7 +96,7 @@ public class Container extends AbstractService implements
super(parent, name);
this.name = name;
this.parent = parent;
- this.deployState = deployStateFrom(parent);
+ this.isHostedVespa = stateIsHosted(deployStateFrom(parent));
this.portOverrides = Collections.unmodifiableList(new ArrayList<>(portOverrides));
this.retired = retired;
this.index = index;
@@ -313,15 +313,11 @@ public class Container extends AbstractService implements
}
}
- private boolean isHostedVespa() {
- return stateIsHosted(deployState);
- }
-
/** Returns the jvm arguments this should start with */
@Override
public String getJvmArgs() {
String jvmArgs = super.getJvmArgs();
- return isHostedVespa() && hasDocproc()
+ return isHostedVespa && hasDocproc()
? ("".equals(jvmArgs) ? defaultHostedJVMArgs : defaultHostedJVMArgs + " " + jvmArgs)
: jvmArgs;
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java
index 2106906ecc1..da0566934f7 100755
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java
@@ -174,7 +174,7 @@ public final class ContainerCluster
private final ConfigProducerGroup<RestApi> restApiGroup;
private final ConfigProducerGroup<Servlet> servletGroup;
private final ContainerClusterVerifier clusterVerifier;
- private final DeployState deployState;
+ private final boolean isHostedVespa;
private Map<String, String> concreteDocumentTypes = new LinkedHashMap<>();
private MetricDefaultsConfig.Factory.Enum defaultMetricConsumerFactory;
@@ -207,8 +207,9 @@ public final class ContainerCluster
public ContainerCluster(AbstractConfigProducer<?> parent, String subId, String name, ContainerClusterVerifier verifier) {
super(parent, subId);
this.clusterVerifier = verifier;
- this.deployState = deployStateFrom(parent);
this.name = name;
+ DeployState deployState = deployStateFrom(parent);
+ this.isHostedVespa = stateIsHosted(deployState);
this.zone = (deployState != null) ? deployState.zone() : Zone.defaultZone();
componentGroup = new ComponentGroup<>(this, "component");
restApiGroup = new ConfigProducerGroup<>(this, "rest-api");
@@ -237,8 +238,6 @@ public final class ContainerCluster
addJaxProviders();
}
- public DeployState getDeployState() { return deployState; }
-
public void setZone(Zone zone) {
this.zone = zone;
}
@@ -709,7 +708,7 @@ public final class ContainerCluster
}
public void addDefaultSearchAccessLog() {
- addComponent(new AccessLogComponent(AccessLogComponent.AccessLogType.queryAccessLog, getName(), getDeployState()));
+ addComponent(new AccessLogComponent(AccessLogComponent.AccessLogType.queryAccessLog, getName(), isHostedVespa));
}
@Override
@@ -771,12 +770,12 @@ public final class ContainerCluster
}
public boolean isHostedVespa() {
- return stateIsHosted(deployState);
+ return isHostedVespa;
}
@Override
public void getConfig(RoutingProviderConfig.Builder builder) {
- builder.enabled(isHostedVespa());
+ builder.enabled(isHostedVespa);
}
public Map<String, String> concreteDocumentTypes() { return concreteDocumentTypes; }
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/component/AccessLogComponent.java b/config-model/src/main/java/com/yahoo/vespa/model/container/component/AccessLogComponent.java
index 5114218d147..06f8c38d9a9 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/component/AccessLogComponent.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/component/AccessLogComponent.java
@@ -7,7 +7,6 @@ import com.yahoo.container.logging.YApacheAccessLog;
import com.yahoo.container.logging.JSONAccessLog;
import com.yahoo.osgi.provider.model.ComponentModel;
import edu.umd.cs.findbugs.annotations.Nullable;
-import com.yahoo.config.model.deploy.DeployState;
import static com.yahoo.container.core.AccessLogConfig.FileHandler.RotateScheme;
@@ -24,14 +23,14 @@ public final class AccessLogComponent extends SimpleComponent implements AccessL
private final String rotationInterval;
private final RotateScheme.Enum rotationScheme;
private final Boolean compression;
- private final DeployState deployState;
+ private final boolean isHostedVespa;
private final String symlinkName;
- public AccessLogComponent(AccessLogType logType, String clusterName, DeployState deployState)
+ public AccessLogComponent(AccessLogType logType, String clusterName, boolean isHostedVespa)
{
this(logType,
String.format("logs/vespa/qrs/%s.%s.%s", capitalize(logType.name()), clusterName, "%Y%m%d%H%M%S"),
- null, null, null, deployState,
+ null, null, null, isHostedVespa,
capitalize(logType.name()) + "." + clusterName);
}
@@ -44,7 +43,7 @@ public final class AccessLogComponent extends SimpleComponent implements AccessL
String rotationInterval,
RotateScheme.Enum rotationScheme,
Boolean compressOnRotation,
- DeployState deployState,
+ boolean isHostedVespa,
String symlinkName)
{
super(new ComponentModel(accessLogClass(logType), null, "container-core", null));
@@ -52,7 +51,7 @@ public final class AccessLogComponent extends SimpleComponent implements AccessL
this.rotationInterval = rotationInterval;
this.rotationScheme = rotationScheme;
this.compression = compressOnRotation;
- this.deployState = deployState;
+ this.isHostedVespa = isHostedVespa;
this.symlinkName = symlinkName;
if (fileNamePattern == null)
@@ -77,10 +76,6 @@ public final class AccessLogComponent extends SimpleComponent implements AccessL
builder.fileHandler(fileHandlerConfig());
}
- private boolean isHostedVespa() {
- return stateIsHosted(deployState);
- }
-
private AccessLogConfig.FileHandler.Builder fileHandlerConfig() {
AccessLogConfig.FileHandler.Builder builder = new AccessLogConfig.FileHandler.Builder();
if (fileNamePattern != null)
@@ -93,7 +88,7 @@ public final class AccessLogComponent extends SimpleComponent implements AccessL
builder.symlink(symlinkName);
if (compression != null) {
builder.compressOnRotation(compression);
- } else if (isHostedVespa()) {
+ } else if (isHostedVespa) {
builder.compressOnRotation(true);
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/AccessLogBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/AccessLogBuilder.java
index 4f51933d8bb..199dbfede42 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/AccessLogBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/AccessLogBuilder.java
@@ -7,7 +7,6 @@ import com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder;
import com.yahoo.vespa.model.container.ContainerCluster;
import com.yahoo.vespa.model.container.component.AccessLogComponent;
import com.yahoo.vespa.model.container.component.AccessLogComponent.AccessLogType;
-import com.yahoo.config.model.deploy.DeployState;
import org.w3c.dom.Element;
import java.util.Optional;
@@ -46,11 +45,11 @@ public class AccessLogBuilder {
private static class DomBuilder extends VespaDomBuilder.DomConfigProducerBuilder<AccessLogComponent> {
private final AccessLogType accessLogType;
- private final DeployState deployState;
+ private final boolean isHostedVespa;
- public DomBuilder(AccessLogType accessLogType, DeployState deployState) {
+ public DomBuilder(AccessLogType accessLogType, boolean isHostedVespa) {
this.accessLogType = accessLogType;
- this.deployState = deployState;
+ this.isHostedVespa = isHostedVespa;
}
@Override
@@ -61,7 +60,7 @@ public class AccessLogBuilder {
rotationInterval(spec),
rotationScheme(spec),
compressOnRotation(spec),
- deployState,
+ isHostedVespa,
symlinkName(spec));
}
@@ -111,7 +110,7 @@ public class AccessLogBuilder {
if (logType == null) {
return Optional.empty();
}
- DeployState deployState = cluster.getDeployState();
- return Optional.of(new DomBuilder(logType, deployState).build(cluster, accessLogSpec));
+ boolean hosted = cluster.isHostedVespa();
+ return Optional.of(new DomBuilder(logType, hosted).build(cluster, accessLogSpec));
}
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
index 9378c8c27f9..9f92fff854c 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
@@ -16,7 +16,6 @@ import com.yahoo.vespa.config.content.core.StorDistributormanagerConfig;
import com.yahoo.documentmodel.NewDocumentType;
import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol;
import com.yahoo.metrics.MetricsmanagerConfig;
-import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.HostResource;
import com.yahoo.vespa.model.Service;
@@ -64,7 +63,7 @@ public class ContentCluster extends AbstractConfigProducer implements StorDistri
// TODO: Make private
private String documentSelection;
ContentSearchCluster search;
- private final DeployState deployState;
+ private final boolean isHostedVespa;
private final Map<String, NewDocumentType> documentDefinitions;
private final Set<NewDocumentType> globallyDistributedDocuments;
// Experimental flag (TODO: remove when feature is enabled by default)
@@ -485,7 +484,7 @@ public class ContentCluster extends AbstractConfigProducer implements StorDistri
Redundancy redundancy,
Zone zone) {
super(parent, clusterName);
- this.deployState = deployStateFrom(parent);
+ this.isHostedVespa = stateIsHosted(deployStateFrom(parent));
this.clusterName = clusterName;
this.documentDefinitions = documentDefinitions;
this.globallyDistributedDocuments = globallyDistributedDocuments;
@@ -626,13 +625,13 @@ public class ContentCluster extends AbstractConfigProducer implements StorDistri
}
public boolean isHostedVespa() {
- return stateIsHosted(deployState);
+ return isHostedVespa;
}
@Override
public void validate() throws Exception {
super.validate();
- if (search.usesHierarchicDistribution() && ! isHostedVespa()) {
+ if (search.usesHierarchicDistribution() && ! isHostedVespa) {
// validate manually configured groups
new IndexedHierarchicDistributionValidator(search.getClusterName(), rootGroup, redundancy, search.getIndexed().getTuning().dispatch.policy).validate();
if (search.getIndexed().useMultilevelDispatchSetup()) {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java
index 547ff354b41..b0767ce0987 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchNode.java
@@ -49,7 +49,7 @@ public class SearchNode extends AbstractService implements
TranslogserverConfig.Producer {
private static final long serialVersionUID = 1L;
- private final DeployState deployState;
+ private final boolean isHostedVespa;
private final boolean flushOnShutdown;
private NodeSpec nodeSpec;
private int distributionKey;
@@ -104,7 +104,7 @@ public class SearchNode extends AbstractService implements
private SearchNode(AbstractConfigProducer parent, String name, NodeSpec nodeSpec, String clusterName, boolean flushOnShutdown, Optional<Tuning> tuning) {
super(parent, name);
- this.deployState = deployStateFrom(parent);
+ this.isHostedVespa = stateIsHosted(deployStateFrom(parent));
this.nodeSpec = nodeSpec;
this.clusterName = clusterName;
this.flushOnShutdown = flushOnShutdown;
@@ -235,10 +235,6 @@ public class SearchNode extends AbstractService implements
}
}
- private boolean isHostedVespa() {
- return stateIsHosted(deployState);
- }
-
@Override
public void getConfig(ProtonConfig.Builder builder) {
builder.
@@ -253,7 +249,7 @@ public class SearchNode extends AbstractService implements
slobrokconfigid(getClusterConfigId()).
routingconfigid(getClusterConfigId()).
distributionkey(getDistributionKey());
- if (isHostedVespa()) {
+ if (isHostedVespa) {
// 4 days, 1 hour, 1 minute due to failed nodes can be in failed for 4 days and we want at least one hour more
// to make sure the node failer has done its work
builder.pruneremoveddocumentsage(4 * 24 * 3600 + 3600 + 60);