diff options
author | Harald Musum <musum@verizonmedia.com> | 2021-03-26 11:02:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-26 11:02:51 +0100 |
commit | 41ef5c4bc5f62ac5a10f5e4dbb22be185d0a1153 (patch) | |
tree | 3b54a5492caa64150e5118f22fda7aadf5b1c04c /config-model | |
parent | 326d62a79c51ff7332bf8dca205f66862330f453 (diff) | |
parent | b3f4e58c29c07f66d09069866f929b4e5fdc0381 (diff) |
Merge pull request #17193 from vespa-engine/hmusum/jvmOmitStackTraceInFastThrow
Add feature flag that can be used to disable OmitStackTraceInFastThro…
Diffstat (limited to 'config-model')
11 files changed, 126 insertions, 55 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java index 64fc6d1dc16..1402f728c73 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java @@ -60,6 +60,7 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea private int metricsProxyMaxHeapSizeInMb = 256; private int maxActivationInhibitedOutOfSyncGroups = 0; private List<TenantSecretStore> tenantSecretStores = Collections.emptyList(); + private String jvmOmitStackTraceInFastThrowOption; @Override public ModelContext.FeatureFlags featureFlags() { return this; } @Override public boolean multitenant() { return multitenant; } @@ -100,6 +101,7 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea @Override public int metricsProxyMaxHeapSizeInMb(ClusterSpec.Type type) { return metricsProxyMaxHeapSizeInMb; } @Override public int maxActivationInhibitedOutOfSyncGroups() { return maxActivationInhibitedOutOfSyncGroups; } @Override public List<TenantSecretStore> tenantSecretStores() { return tenantSecretStores; } + @Override public String jvmOmitStackTraceInFastThrowOption(ClusterSpec.Type type) { return jvmOmitStackTraceInFastThrowOption; } public TestProperties setFeedConcurrency(double feedConcurrency) { this.feedConcurrency = feedConcurrency; @@ -241,6 +243,11 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea return this; } + public TestProperties setJvmOmitStackTraceInFastThrowOption(String value) { + this.jvmOmitStackTraceInFastThrowOption = value; + return this; + } + public static class Spec implements ConfigServerSpec { private final String hostName; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/LogserverContainer.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/LogserverContainer.java index c2bc2494613..dbf41a4f206 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/LogserverContainer.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/LogserverContainer.java @@ -1,8 +1,11 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.admin; +import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.api.container.ContainerServiceType; +import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.model.producer.AbstractConfigProducer; +import com.yahoo.config.provision.ClusterSpec; import com.yahoo.vespa.model.container.Container; import com.yahoo.vespa.model.container.component.AccessLogComponent; import com.yahoo.vespa.model.container.component.AccessLogComponent.AccessLogType; @@ -14,8 +17,8 @@ import com.yahoo.vespa.model.container.component.AccessLogComponent.CompressionT */ public class LogserverContainer extends Container { - public LogserverContainer(AbstractConfigProducer<?> parent, boolean isHostedVespa) { - super(parent, "" + 0, 0, isHostedVespa); + public LogserverContainer(AbstractConfigProducer<?> parent, DeployState deployState) { + super(parent, "" + 0, 0, deployState); LogserverContainerCluster cluster = (LogserverContainerCluster) parent; addComponent(new AccessLogComponent( cluster, AccessLogType.jsonAccessLog, CompressionType.GZIP, cluster.getName(), true)); @@ -31,4 +34,9 @@ public class LogserverContainer extends Container { return ""; } + @Override + protected String jvmOmitStackTraceInFastThrowOption(ModelContext.FeatureFlags featureFlags) { + return featureFlags.jvmOmitStackTraceInFastThrowOption(ClusterSpec.Type.admin); + } + } 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 f1717625d10..60991a59a75 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 @@ -3,9 +3,11 @@ package com.yahoo.vespa.model.admin.clustercontroller; import com.yahoo.cloud.config.ZookeeperServerConfig; import com.yahoo.component.ComponentSpecification; +import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.api.container.ContainerServiceType; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.model.producer.AbstractConfigProducer; +import com.yahoo.config.provision.ClusterSpec; import com.yahoo.container.bundle.BundleInstantiationSpecification; import com.yahoo.container.core.documentapi.DocumentAccessProvider; import com.yahoo.container.di.config.PlatformBundlesConfig; @@ -46,7 +48,7 @@ public class ClusterControllerContainer extends Container implements boolean runStandaloneZooKeeper, DeployState deployState, boolean retired) { - super(parent, "" + index, retired, index, deployState.isHosted()); + super(parent, "" + index, retired, index, deployState); addHandler("clustercontroller-status", "com.yahoo.vespa.clustercontroller.apps.clustercontroller.StatusHandler", "/clustercontroller-status/*", @@ -84,6 +86,11 @@ public class ClusterControllerContainer extends Container implements return ContainerServiceType.CLUSTERCONTROLLER_CONTAINER; } + @Override + protected String jvmOmitStackTraceInFastThrowOption(ModelContext.FeatureFlags featureFlags) { + return featureFlags.jvmOmitStackTraceInFastThrowOption(ClusterSpec.Type.admin); + } + private void configureZooKeeperServer(boolean runStandaloneZooKeeper) { if (runStandaloneZooKeeper) ContainerModelBuilder.addReconfigurableZooKeeperServerComponents(this); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainer.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainer.java index 89182ca28ff..29ed27675ca 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainer.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainer.java @@ -1,4 +1,4 @@ -// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.admin.metricsproxy; @@ -15,6 +15,7 @@ import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.api.container.ContainerServiceType; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.provision.ClusterMembership; +import com.yahoo.config.provision.ClusterSpec; import com.yahoo.search.config.QrStartConfig; import com.yahoo.vespa.model.HostResource; import com.yahoo.vespa.model.PortAllocBridge; @@ -50,7 +51,7 @@ public class MetricsProxyContainer extends Container implements public MetricsProxyContainer(MetricsProxyContainerCluster cluster, HostResource host, int index, DeployState deployState) { - super(cluster, host.getHostname(), index, deployState.isHosted()); + super(cluster, host.getHostname(), index, deployState); this.isHostedVespa = deployState.isHosted(); this.clusterMembership = host.spec().membership(); this.featureFlags = deployState.featureFlags(); @@ -74,6 +75,11 @@ public class MetricsProxyContainer extends Container implements } @Override + protected String jvmOmitStackTraceInFastThrowOption(ModelContext.FeatureFlags featureFlags) { + return featureFlags.jvmOmitStackTraceInFastThrowOption(ClusterSpec.Type.admin); + } + + @Override public int getWantedPort() { return BASEPORT; } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java index a28475c94f3..2e04007e6d2 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV4Builder.java @@ -105,7 +105,7 @@ public class DomAdminV4Builder extends DomAdminBuilderBase { ContainerModel logserverClusterModel = new ContainerModel(context.withParent(admin).withId(logServerCluster.getSubId())); logserverClusterModel.setCluster(logServerCluster); - LogserverContainer container = new LogserverContainer(logServerCluster, deployState.isHosted()); + LogserverContainer container = new LogserverContainer(logServerCluster, deployState); container.setHostResource(hostResource); container.initService(deployState.getDeployLogger()); logServerCluster.addContainer(container); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java index fddfcabeb0e..523002afa25 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainer.java @@ -2,8 +2,11 @@ package com.yahoo.vespa.model.container; import com.yahoo.cloud.config.ZookeeperServerConfig; +import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.api.container.ContainerServiceType; +import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.model.producer.AbstractConfigProducer; +import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.NodeResources; import com.yahoo.container.bundle.BundleInstantiationSpecification; import com.yahoo.osgi.provider.model.ComponentModel; @@ -24,13 +27,13 @@ public final class ApplicationContainer extends Container implements private final boolean isHostedVespa; - public ApplicationContainer(AbstractConfigProducer<?> parent, String name, int index, boolean isHostedVespa) { - this(parent, name, false, index, isHostedVespa); + public ApplicationContainer(AbstractConfigProducer<?> parent, String name, int index, DeployState deployState) { + this(parent, name, false, index, deployState); } - public ApplicationContainer(AbstractConfigProducer<?> parent, String name, boolean retired, int index, boolean isHostedVespa) { - super(parent, name, retired, index, isHostedVespa); - this.isHostedVespa = isHostedVespa; + public ApplicationContainer(AbstractConfigProducer<?> parent, String name, boolean retired, int index, DeployState deployState) { + super(parent, name, retired, index, deployState); + this.isHostedVespa = deployState.isHosted(); addComponent(getFS4ResourcePool()); // TODO Remove when FS4 based search protocol is gone } @@ -81,4 +84,9 @@ public final class ApplicationContainer extends Container implements builder.myid(index()); } + @Override + protected String jvmOmitStackTraceInFastThrowOption(ModelContext.FeatureFlags featureFlags) { + return featureFlags.jvmOmitStackTraceInFastThrowOption(ClusterSpec.Type.container); + } + } 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 d075e661149..cd596038137 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 @@ -1,10 +1,12 @@ // Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.container; -import com.yahoo.component.ComponentId; import com.yahoo.config.application.api.DeployLogger; +import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.api.container.ContainerServiceType; +import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.model.producer.AbstractConfigProducer; +import com.yahoo.config.provision.ClusterSpec; import com.yahoo.container.ComponentsConfig; import com.yahoo.container.QrConfig; import com.yahoo.container.core.ContainerHttpConfig; @@ -78,23 +80,29 @@ public abstract class Container extends AbstractService implements private final JettyHttpServer defaultHttpServer; - protected Container(AbstractConfigProducer<?> parent, String name, int index, boolean isHostedVespa) { - this(parent, name, false, index, isHostedVespa); + protected Container(AbstractConfigProducer<?> parent, String name, int index, DeployState deployState) { + this(parent, name, false, index, deployState); } - protected Container(AbstractConfigProducer<?> parent, String name, boolean retired, int index, boolean isHostedVespa) { + protected Container(AbstractConfigProducer<?> parent, String name, boolean retired, int index, DeployState deployState) { super(parent, name); this.name = name; this.parent = parent; this.retired = retired; this.index = index; - this.defaultHttpServer = new JettyHttpServer("DefaultHttpServer", containerClusterOrNull(parent), isHostedVespa); + this.defaultHttpServer = new JettyHttpServer("DefaultHttpServer", containerClusterOrNull(parent), deployState.isHosted()); if (getHttp() == null) { addChild(defaultHttpServer); } addBuiltinHandlers(); addChild(new SimpleComponent("com.yahoo.container.jdisc.ConfiguredApplication$ApplicationContext")); + + appendJvmOptions(jvmOmitStackTraceInFastThrowOption(deployState.featureFlags())); + } + + protected String jvmOmitStackTraceInFastThrowOption(ModelContext.FeatureFlags featureFlags) { + return featureFlags.jvmOmitStackTraceInFastThrowOption(ClusterSpec.Type.container); } void setOwner(ContainerCluster<?> owner) { this.owner = owner; } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java index 1cee722feaf..d03246b4e8c 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java @@ -1,8 +1,7 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.container.xml; import com.google.common.collect.ImmutableList; -import com.yahoo.component.ComponentId; import com.yahoo.component.Version; import com.yahoo.config.application.Xml; import com.yahoo.config.application.api.ApplicationPackage; @@ -598,13 +597,13 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { private void addNodes(ApplicationContainerCluster cluster, Element spec, ConfigModelContext context) { if (standaloneBuilder) - addStandaloneNode(cluster); + addStandaloneNode(cluster, context.getDeployState()); else addNodesFromXml(cluster, spec, context); } - private void addStandaloneNode(ApplicationContainerCluster cluster) { - ApplicationContainer container = new ApplicationContainer(cluster, "standalone", cluster.getContainers().size(), cluster.isHostedVespa()); + private void addStandaloneNode(ApplicationContainerCluster cluster, DeployState deployState) { + ApplicationContainer container = new ApplicationContainer(cluster, "standalone", cluster.getContainers().size(), deployState); cluster.addContainers(Collections.singleton(container)); } @@ -769,7 +768,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { false, !deployState.getProperties().isBootstrap()); var hosts = hostSystem.allocateHosts(clusterSpec, capacity, log); - return createNodesFromHosts(log, hosts, cluster); + return createNodesFromHosts(log, hosts, cluster, context.getDeployState()); } else { return singleHostContainerCluster(cluster, hostSystem.getHost(Container.SINGLENODE_CONTAINER_SERVICESPEC), context); @@ -777,7 +776,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { } private List<ApplicationContainer> singleHostContainerCluster(ApplicationContainerCluster cluster, HostResource host, ConfigModelContext context) { - ApplicationContainer node = new ApplicationContainer(cluster, "container.0", 0, cluster.isHostedVespa()); + ApplicationContainer node = new ApplicationContainer(cluster, "container.0", 0, context.getDeployState()); node.setHostResource(host); node.initService(context.getDeployLogger()); return List.of(node); @@ -790,7 +789,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { ClusterSpec.Id.from(cluster.getName()), log, hasZooKeeper(containerElement)); - return createNodesFromHosts(context.getDeployLogger(), hosts, cluster); + return createNodesFromHosts(context.getDeployLogger(), hosts, cluster, context.getDeployState()); } private List<ApplicationContainer> createNodesFromNodeType(ApplicationContainerCluster cluster, Element nodesElement, ConfigModelContext context) { @@ -802,7 +801,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { Map<HostResource, ClusterMembership> hosts = cluster.getRoot().hostSystem().allocateHosts(clusterSpec, Capacity.fromRequiredNodeType(type), log); - return createNodesFromHosts(context.getDeployLogger(), hosts, cluster); + return createNodesFromHosts(context.getDeployLogger(), hosts, cluster, context.getDeployState()); } private List<ApplicationContainer> createNodesFromContentServiceReference(ApplicationContainerCluster cluster, Element nodesElement, ConfigModelContext context) { @@ -820,14 +819,17 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { referenceId, cluster.getRoot().hostSystem(), context.getDeployLogger()); - return createNodesFromHosts(context.getDeployLogger(), hosts, cluster); + return createNodesFromHosts(context.getDeployLogger(), hosts, cluster, context.getDeployState()); } - private List<ApplicationContainer> createNodesFromHosts(DeployLogger deployLogger, Map<HostResource, ClusterMembership> hosts, ApplicationContainerCluster cluster) { + private List<ApplicationContainer> createNodesFromHosts(DeployLogger deployLogger, + Map<HostResource, ClusterMembership> hosts, + ApplicationContainerCluster cluster, + DeployState deployState) { List<ApplicationContainer> nodes = new ArrayList<>(); for (Map.Entry<HostResource, ClusterMembership> entry : hosts.entrySet()) { String id = "container." + entry.getValue().index(); - ApplicationContainer container = new ApplicationContainer(cluster, id, entry.getValue().retired(), entry.getValue().index(), cluster.isHostedVespa()); + ApplicationContainer container = new ApplicationContainer(cluster, id, entry.getValue().retired(), entry.getValue().index(), deployState); container.setHostResource(entry.getKey()); container.initService(deployLogger); nodes.add(container); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerServiceBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerServiceBuilder.java index 3fae9d52929..78469bdf51c 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerServiceBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerServiceBuilder.java @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.container.xml; import com.yahoo.config.model.deploy.DeployState; @@ -22,7 +22,7 @@ public class ContainerServiceBuilder extends VespaDomBuilder.DomConfigProducerBu @Override protected ApplicationContainer doBuild(DeployState deployState, AbstractConfigProducer<?> parent, Element nodeElem) { - return new ApplicationContainer(parent, id, index, deployState.isHosted()); + return new ApplicationContainer(parent, id, index, deployState); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java b/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java index b93f4405333..2bd9cb09aa6 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java @@ -299,7 +299,7 @@ public class Content extends ConfigModel { if (!processedHosts.contains(host)) { String containerName = String.valueOf(searchNode.getDistributionKey()); ApplicationContainer docprocService = new ApplicationContainer(indexingCluster, containerName, index, - modelContext.getDeployState().isHosted()); + modelContext.getDeployState()); index++; docprocService.useDynamicPorts(); docprocService.setHostResource(host); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java index 23c37666257..46026a5528c 100755 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java @@ -76,7 +76,7 @@ public class ContainerClusterTest { .zone(new Zone(SystemName.cd, Environment.test, RegionName.from("some-region"))) .build(); MockRoot root = new MockRoot("foo", state); - ContainerCluster cluster = new ApplicationContainerCluster(root, "container0", "container1", state); + ContainerCluster<?> cluster = new ApplicationContainerCluster(root, "container0", "container1", state); ConfigserverConfig.Builder builder = new ConfigserverConfig.Builder(); cluster.getConfig(builder); ConfigserverConfig config = new ConfigserverConfig(builder); @@ -101,10 +101,14 @@ public class ContainerClusterTest { } private MockRoot createRoot(boolean isHosted) { DeployState state = new DeployState.Builder().properties(new TestProperties().setHostedVespa(isHosted)).build(); - return new MockRoot("foo", state); + return createRoot(state); + } + private MockRoot createRoot(DeployState deployState) { + return new MockRoot("foo", deployState); } - private void verifyHeapSizeAsPercentageOfPhysicalMemory(boolean isHosted, boolean isCombinedCluster, + private void verifyHeapSizeAsPercentageOfPhysicalMemory(boolean isHosted, + boolean isCombinedCluster, Integer explicitMemoryPercentage, int expectedMemoryPercentage) { ContainerCluster<?> cluster = createContainerCluster(createRoot(isHosted), isCombinedCluster, explicitMemoryPercentage); @@ -147,7 +151,7 @@ public class ContainerClusterTest { if (hasDocProc) { cluster.setDocproc(new ContainerDocproc(cluster, null)); } - addContainer(root.deployLogger(), cluster, "c1", "host-c1"); + addContainer(root, cluster, "c1", "host-c1"); assertEquals(1, cluster.getContainers().size()); ApplicationContainer container = cluster.getContainers().get(0); verifyJvmArgs(isHosted, hasDocProc, "", container.getJvmOptions()); @@ -205,10 +209,28 @@ public class ContainerClusterTest { } @Test - public void requireThatWeCanhandleNull() { + public void requireThatJvmOmitStackTraceInFastThrowOptionWorks() { + // Empty option if option not set in property + MockRoot root = createRoot(new DeployState.Builder().build()); + ApplicationContainerCluster cluster = createContainerCluster(root, false); + addContainer(root, cluster, "c1", "host-c1"); + ApplicationContainer container = cluster.getContainers().get(0); + assertEquals("", container.getJvmOptions()); + + String jvmOption = "-XX:-foo"; + DeployState deployState = new DeployState.Builder().properties(new TestProperties().setJvmOmitStackTraceInFastThrowOption(jvmOption)).build(); + root = createRoot(deployState); + cluster = createContainerCluster(root, false); + addContainer(root, cluster, "c1", "host-c1"); + container = cluster.getContainers().get(0); + assertEquals(jvmOption, container.getJvmOptions()); + } + + @Test + public void requireThatWeCanHandleNull() { MockRoot root = createRoot(false); ApplicationContainerCluster cluster = createContainerCluster(root, false); - addContainer(root.deployLogger(), cluster, "c1", "host-c1"); + addContainer(root, cluster, "c1", "host-c1"); Container container = cluster.getContainers().get(0); container.setJvmOptions(""); String empty = container.getJvmOptions(); @@ -220,7 +242,7 @@ public class ContainerClusterTest { public void requireThatPoolAndQueueCanNotBeControlledByPropertiesWhenNoFlavor() { MockRoot root = new MockRoot("foo"); ApplicationContainerCluster cluster = createContainerCluster(root, false); - addContainer(root.deployLogger(), cluster, "c1", "host-c1"); + addContainer(root, cluster, "c1", "host-c1"); root.freezeModelTopology(); ThreadpoolConfig threadpoolConfig = root.getConfig(ThreadpoolConfig.class, "container0/component/default-threadpool"); @@ -232,7 +254,7 @@ public class ContainerClusterTest { public void requireThatDefaultThreadPoolConfigIsSane() { MockRoot root = new MockRoot("foo"); ApplicationContainerCluster cluster = createContainerCluster(root, false); - addContainer(root.deployLogger(), cluster, "c1", "host-c1"); + addContainer(root, cluster, "c1", "host-c1"); root.freezeModelTopology(); ThreadpoolConfig threadpoolConfig = root.getConfig(ThreadpoolConfig.class, "container0/component/default-threadpool"); @@ -244,7 +266,7 @@ public class ContainerClusterTest { public void container_cluster_has_default_threadpool_provider() { MockRoot root = new MockRoot("foo"); ApplicationContainerCluster cluster = createContainerCluster(root, false); - addContainer(root.deployLogger(), cluster, "c1", "host-c1"); + addContainer(root, cluster, "c1", "host-c1"); root.freezeModelTopology(); ComponentId expectedComponentId = new ComponentId("default-threadpool"); @@ -267,7 +289,7 @@ public class ContainerClusterTest { HostResource hostResource = new HostResource( new Host(null, "host-c1"), hostProvisioner.allocateHost("host-c1")); - addContainerWithHostResource(root.deployLogger(), cluster, "c1", hostResource); + addContainerWithHostResource(root, cluster, "c1", hostResource); root.freezeModelTopology(); ThreadpoolConfig threadpoolConfig = root.getConfig(ThreadpoolConfig.class, "container0/component/default-threadpool"); @@ -288,7 +310,7 @@ public class ContainerClusterTest { HostResource hostResource = new HostResource( new Host(null, "host-c1"), hostProvisioner.allocateHost("host-c1")); - addContainerWithHostResource(root.deployLogger(), cluster, "c1", hostResource); + addContainerWithHostResource(root, cluster, "c1", hostResource); root.freezeModelTopology(); ServerConfig cfg = root.getConfig(ServerConfig.class, "container0/c1/DefaultHttpServer"); @@ -316,8 +338,8 @@ public class ContainerClusterTest { DeployState state = new DeployState.Builder().build(); MockRoot root = new MockRoot("foo", state); var cluster = new ApplicationContainerCluster(root, "container", "search-cluster", state); - addContainer(root.deployLogger(), cluster, "c1", "host-c1"); - addContainer(root.deployLogger(), cluster, "c2", "host-c2"); + addContainer(root, cluster, "c1", "host-c1"); + addContainer(root, cluster, "c2", "host-c2"); CuratorConfig.Builder configBuilder = new CuratorConfig.Builder(); cluster.getConfig(configBuilder); CuratorConfig config = configBuilder.build(); @@ -331,9 +353,9 @@ public class ContainerClusterTest { DeployState state = new DeployState.Builder().build(); MockRoot root = new MockRoot("foo", state); var cluster = new ApplicationContainerCluster(root, "container", "search-cluster", state); - addContainer(root.deployLogger(), cluster, "c1", "host-c1"); - addContainer(root.deployLogger(), cluster, "c2", "host-c2"); - addContainer(root.deployLogger(), cluster, "c3", "host-c3"); + addContainer(root, cluster, "c1", "host-c1"); + addContainer(root, cluster, "c2", "host-c2"); + addContainer(root, cluster, "c3", "host-c3"); // Only myid is set for container ZookeeperServerConfig.Builder configBuilder = new ZookeeperServerConfig.Builder(); @@ -368,14 +390,17 @@ public class ContainerClusterTest { } - private static void addContainer(DeployLogger deployLogger, ApplicationContainerCluster cluster, String name, String hostName) { - addContainerWithHostResource(deployLogger, cluster, name, new HostResource(new Host(null, hostName))); + private static void addContainer(MockRoot root, ApplicationContainerCluster cluster, String name, String hostName) { + addContainerWithHostResource(root, cluster, name, new HostResource(new Host(null, hostName))); } - private static void addContainerWithHostResource(DeployLogger deployLogger, ApplicationContainerCluster cluster, String name, HostResource hostResource) { - ApplicationContainer container = new ApplicationContainer(cluster, name, 0, cluster.isHostedVespa()); + private static void addContainerWithHostResource(MockRoot root, + ApplicationContainerCluster cluster, + String name, + HostResource hostResource) { + ApplicationContainer container = new ApplicationContainer(cluster, name, 0, root.getDeployState()); container.setHostResource(hostResource); - container.initService(deployLogger); + container.initService(root.deployLogger()); cluster.addContainer(container); } @@ -393,8 +418,8 @@ public class ContainerClusterTest { DeployState deployState = DeployState.createTestState(); MockRoot root = new MockRoot("foo", deployState); ApplicationContainerCluster cluster = new ApplicationContainerCluster(root, "subId", "name", deployState); - addContainer(deployState.getDeployLogger(), cluster, "c1", "host-c1"); - addContainer(deployState.getDeployLogger(), cluster, "c2", "host-c2"); + addContainer(root, cluster, "c1", "host-c1"); + addContainer(root, cluster, "c2", "host-c2"); return cluster; } |