diff options
8 files changed, 68 insertions, 23 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/producer/AbstractConfigProducer.java b/config-model/src/main/java/com/yahoo/config/model/producer/AbstractConfigProducer.java index 6c665affd1e..4096eeb0168 100644 --- a/config-model/src/main/java/com/yahoo/config/model/producer/AbstractConfigProducer.java +++ b/config-model/src/main/java/com/yahoo/config/model/producer/AbstractConfigProducer.java @@ -5,6 +5,7 @@ import com.google.common.annotations.Beta; import com.yahoo.config.ConfigInstance; import com.yahoo.config.subscription.ConfigInstanceUtil; import com.yahoo.config.model.ApplicationConfigProducerRoot; +import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.log.LogLevel; import com.yahoo.text.Utf8; @@ -34,7 +35,6 @@ public abstract class AbstractConfigProducer<CHILD extends AbstractConfigProduce private static final long serialVersionUID = 1L; public static final Logger log = Logger.getLogger(AbstractConfigProducer.class.getPackage().toString()); private final String subId; - private final boolean hostedVespa; private String configId = null; private List<Service> descendantServices = new ArrayList<>(); @@ -45,11 +45,14 @@ public abstract class AbstractConfigProducer<CHILD extends AbstractConfigProduce private final FreezableMap<String, CHILD> childrenBySubId = new FreezableMap<>(LinkedHashMap.class); - private static boolean isHostedVespa(AbstractConfigProducer parent) { - return (parent != null) - && (parent.getRoot() != null) - && (parent.getRoot().getDeployState() != null) - && parent.getRoot().getDeployState().isHosted(); + protected static boolean stateIsHosted(DeployState deployState) { + return (deployState != null) && deployState.isHosted(); + } + + protected static DeployState deployStateFrom(AbstractConfigProducer parent) { + if (parent == null) return null; + if (parent.getRoot() == null) return null; + return parent.getRoot().getDeployState(); } /** @@ -60,8 +63,7 @@ public abstract class AbstractConfigProducer<CHILD extends AbstractConfigProduce * @param subId The fragment of the config id for the producer */ public AbstractConfigProducer(AbstractConfigProducer parent, String subId) { - this(subId, isHostedVespa(parent)); - + this(subId); if (parent != null) { parent.addChild(this); } @@ -69,9 +71,6 @@ public abstract class AbstractConfigProducer<CHILD extends AbstractConfigProduce protected final void setParent(AbstractConfigProducer parent) { this.parent = parent; } public final String getSubId() { return subId; } - - /** Whether this is hosted Vespa: NOTE: This cannot be trusted to be correct :-/ */ - public final boolean isHostedVespa() { return hostedVespa; } /** * Create an config producer with a configId only. Used e.g. to create root nodes, and producers @@ -80,15 +79,10 @@ public abstract class AbstractConfigProducer<CHILD extends AbstractConfigProduce * @param subId The sub configId. Note that this can be prefixed when calling addChild with this producer as arg. */ public AbstractConfigProducer(String subId) { - this(subId, false); - } - - private AbstractConfigProducer(String subId, boolean hostedVespa) { if (subId.indexOf('/') != -1) { throw new IllegalArgumentException("A subId might not contain '/' : '" + subId + "'"); } this.subId = subId; - this.hostedVespa = hostedVespa; } /** 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 19c64d7903d..b1cc6257a7a 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,6 +39,7 @@ public class Admin extends AbstractConfigProducer implements Serializable { private static final long serialVersionUID = 1L; + private final DeployState deployState; private final Monitoring monitoring; private final Metrics metrics; private final Map<String, MetricsConsumer> legacyMetricsConsumers; @@ -72,6 +73,7 @@ public class Admin extends AbstractConfigProducer implements Serializable { boolean multitenant, FileDistributionConfigProducer fileDistributionConfigProducer) { super(parent, "admin"); + this.deployState = deployStateFrom(parent); this.monitoring = monitoring; this.metrics = metrics; this.legacyMetricsConsumers = legacyMetricsConsumers; @@ -138,6 +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(). 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 5925ec978bb..5b07a966a82 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 @@ -3,6 +3,7 @@ package com.yahoo.vespa.model.container; import com.yahoo.component.ComponentId; import com.yahoo.component.ComponentSpecification; +import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.model.producer.AbstractConfigProducer; import com.yahoo.container.ComponentsConfig; import com.yahoo.container.QrConfig; @@ -55,6 +56,8 @@ public class Container extends AbstractService implements private final AbstractConfigProducer parent; private final String name; + private final DeployState deployState; + private String clusterName = null; private boolean rpcServerEnabled = true; @@ -93,6 +96,7 @@ public class Container extends AbstractService implements super(parent, name); this.name = name; this.parent = parent; + this.deployState = deployStateFrom(parent); this.portOverrides = Collections.unmodifiableList(new ArrayList<>(portOverrides)); this.retired = retired; this.index = index; @@ -309,6 +313,10 @@ public class Container extends AbstractService implements } } + private boolean isHostedVespa() { + return stateIsHosted(deployState); + } + /** Returns the jvm arguments this should start with */ @Override public String getJvmArgs() { 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 4684cf5c2f0..d7ce3a9a975 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 @@ -12,7 +12,9 @@ import com.yahoo.config.application.api.ComponentInfo; import com.yahoo.config.docproc.DocprocConfig; import com.yahoo.config.docproc.SchemamappingConfig; import com.yahoo.config.model.ApplicationConfigProducerRoot; +import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.model.producer.AbstractConfigProducer; +import com.yahoo.config.model.producer.AbstractConfigProducerRoot; import com.yahoo.config.provision.Zone; import com.yahoo.container.BundlesConfig; import com.yahoo.container.ComponentsConfig; @@ -82,6 +84,7 @@ import com.yahoo.vespaclient.config.FeederConfig; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; + import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; @@ -171,6 +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 Map<String, String> concreteDocumentTypes = new LinkedHashMap<>(); private MetricDefaultsConfig.Factory.Enum defaultMetricConsumerFactory; @@ -203,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; - this.zone = getRoot() != null ? getRoot().getDeployState().zone() : Zone.defaultZone(); + this.zone = (deployState != null) ? deployState.zone() : Zone.defaultZone(); componentGroup = new ComponentGroup<>(this, "component"); restApiGroup = new ConfigProducerGroup<>(this, "rest-api"); servletGroup = new ConfigProducerGroup<>(this, "servlet"); @@ -232,6 +237,8 @@ public final class ContainerCluster addJaxProviders(); } + public DeployState getDeployState() { return deployState; } + public void setZone(Zone zone) { this.zone = zone; } @@ -763,6 +770,10 @@ public final class ContainerCluster this.defaultMetricConsumerFactory = defaultMetricConsumerFactory; } + public boolean isHostedVespa() { + return stateIsHosted(deployState); + } + @Override public void getConfig(RoutingProviderConfig.Builder builder) { builder.enabled(isHostedVespa()); 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 7da7abe0546..ccb4e271102 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,6 +7,7 @@ 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; @@ -23,12 +24,13 @@ 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 String symlinkName; public AccessLogComponent(AccessLogType logType, String clusterName) { this(logType, String.format("logs/vespa/qrs/%s.%s.%s", capitalize(logType.name()), clusterName, "%Y%m%d%H%M%S"), - null, null, null, + null, null, null, null, capitalize(logType.name()) + "." + clusterName); } @@ -41,6 +43,7 @@ public final class AccessLogComponent extends SimpleComponent implements AccessL String rotationInterval, RotateScheme.Enum rotationScheme, Boolean compressOnRotation, + DeployState deployState, String symlinkName) { super(new ComponentModel(accessLogClass(logType), null, "container-core", null)); @@ -48,6 +51,7 @@ public final class AccessLogComponent extends SimpleComponent implements AccessL this.rotationInterval = rotationInterval; this.rotationScheme = rotationScheme; this.compression = compressOnRotation; + this.deployState = deployState; this.symlinkName = symlinkName; if (fileNamePattern == null) @@ -72,6 +76,10 @@ 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) 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 1b15a49462e..a1dba16124e 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,6 +7,7 @@ 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; @@ -45,9 +46,11 @@ public class AccessLogBuilder { private static class DomBuilder extends VespaDomBuilder.DomConfigProducerBuilder<AccessLogComponent> { private final AccessLogType accessLogType; + private final DeployState deployState; - public DomBuilder(AccessLogType accessLogType) { + public DomBuilder(AccessLogType accessLogType, DeployState deployState) { this.accessLogType = accessLogType; + this.deployState = deployState; } @Override @@ -58,6 +61,7 @@ public class AccessLogBuilder { rotationInterval(spec), rotationScheme(spec), compressOnRotation(spec), + deployState, symlinkName(spec)); } @@ -88,16 +92,16 @@ public class AccessLogBuilder { getOptionalAttribute(accessLogSpec, "type"). map(AccessLogTypeLiteral::fromAttributeValue). orElse(AccessLogTypeLiteral.VESPA); - + DeployState deployState = cluster.getDeployState(); switch (typeLiteral) { case DISABLED: return Optional.empty(); case VESPA: - return Optional.of(new DomBuilder(AccessLogType.queryAccessLog).build(cluster, accessLogSpec)); + return Optional.of(new DomBuilder(AccessLogType.queryAccessLog, deployState).build(cluster, accessLogSpec)); case YAPACHE: - return Optional.of(new DomBuilder(AccessLogType.yApacheAccessLog).build(cluster, accessLogSpec)); + return Optional.of(new DomBuilder(AccessLogType.yApacheAccessLog, deployState).build(cluster, accessLogSpec)); case JSON: - return Optional.of(new DomBuilder(AccessLogType.jsonAccessLog).build(cluster, accessLogSpec)); + return Optional.of(new DomBuilder(AccessLogType.jsonAccessLog, deployState).build(cluster, accessLogSpec)); default: throw new InconsistentSchemaAndCodeError(); } 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 a8e89af0a42..fabd7a0cc1a 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,6 +16,7 @@ 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,6 +65,7 @@ public class ContentCluster extends AbstractConfigProducer implements StorDistri // TODO: Make private private String documentSelection; ContentSearchCluster search; + private final DeployState deployState; private final Map<String, NewDocumentType> documentDefinitions; private final Set<NewDocumentType> globallyDistributedDocuments; // Experimental flag (TODO: remove when feature is enabled by default) @@ -488,6 +490,7 @@ public class ContentCluster extends AbstractConfigProducer implements StorDistri Redundancy redundancy, Zone zone) { super(parent, clusterName); + this.deployState = deployStateFrom(parent); this.clusterName = clusterName; this.documentDefinitions = documentDefinitions; this.globallyDistributedDocuments = globallyDistributedDocuments; @@ -631,6 +634,10 @@ public class ContentCluster extends AbstractConfigProducer implements StorDistri } } + public boolean isHostedVespa() { + return stateIsHosted(deployState); + } + @Override public void validate() throws Exception { super.validate(); 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 e8f0c0de30a..924c282d2e5 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 @@ -2,6 +2,7 @@ package com.yahoo.vespa.model.search; import com.yahoo.cloud.config.filedistribution.FiledistributorrpcConfig; +import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.model.producer.AbstractConfigProducer; import com.yahoo.metrics.MetricsmanagerConfig; import com.yahoo.searchlib.TranslogserverConfig; @@ -49,6 +50,7 @@ public class SearchNode extends AbstractService implements TranslogserverConfig.Producer { private static final long serialVersionUID = 1L; + private final DeployState deployState; private final boolean flushOnShutdown; private NodeSpec nodeSpec; private int distributionKey; @@ -103,6 +105,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.nodeSpec = nodeSpec; this.clusterName = clusterName; this.flushOnShutdown = flushOnShutdown; @@ -233,6 +236,10 @@ public class SearchNode extends AbstractService implements } } + private boolean isHostedVespa() { + return stateIsHosted(deployState); + } + @Override public void getConfig(ProtonConfig.Builder builder) { builder. |