diff options
15 files changed, 45 insertions, 235 deletions
diff --git a/container-core/pom.xml b/container-core/pom.xml index 910781f4e7d..7e4198bad0d 100644 --- a/container-core/pom.xml +++ b/container-core/pom.xml @@ -240,12 +240,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>hosted-zone-api</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> diff --git a/container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java b/container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java index 3ae28c2816d..99637e08b77 100644 --- a/container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java +++ b/container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java @@ -142,7 +142,6 @@ public class HandlersConfigurerTestWrapper { // Needed by e.g. SearchHandler bind(Linguistics.class).to(SimpleLinguistics.class).in(Scopes.SINGLETON); bind(Embedder.class).to(Embedder.FailingEmbedder.class).in(Scopes.SINGLETON); - bind(ai.vespa.cloud.ZoneInfo.class).to(MockZoneInfo.class); bind(ContainerThreadPool.class).to(SimpleContainerThreadpool.class); bind(Metric.class).to(MockMetric.class); } diff --git a/container-core/src/main/java/com/yahoo/container/core/config/testutil/MockZoneInfo.java b/container-core/src/main/java/com/yahoo/container/core/config/testutil/MockZoneInfo.java deleted file mode 100644 index 11c14f8e581..00000000000 --- a/container-core/src/main/java/com/yahoo/container/core/config/testutil/MockZoneInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.core.config.testutil; - -import ai.vespa.cloud.ZoneInfo; - -/** - * A ZoneInfo subclass which can be created (for injection) with an emopty constructor - * - * @author bratseth - */ -public class MockZoneInfo extends ZoneInfo { - - public MockZoneInfo() { - super(ZoneInfo.defaultInfo().application(), ZoneInfo.defaultInfo().zone()); - } - -} diff --git a/container-disc/src/main/java/com/yahoo/container/jdisc/ZoneInfoProvider.java b/container-disc/src/main/java/com/yahoo/container/jdisc/ZoneInfoProvider.java index 864d44886cb..30a4c740ff0 100644 --- a/container-disc/src/main/java/com/yahoo/container/jdisc/ZoneInfoProvider.java +++ b/container-disc/src/main/java/com/yahoo/container/jdisc/ZoneInfoProvider.java @@ -1,12 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.container.jdisc; -import ai.vespa.cloud.ApplicationId; import ai.vespa.cloud.Environment; import ai.vespa.cloud.Zone; import ai.vespa.cloud.ZoneInfo; import com.google.inject.Inject; -import com.yahoo.cloud.config.ApplicationIdConfig; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.AbstractComponent; import com.yahoo.container.di.componentgraph.Provider; @@ -22,11 +20,8 @@ public class ZoneInfoProvider extends AbstractComponent implements Provider<Zone private final ZoneInfo instance; @Inject - public ZoneInfoProvider(ConfigserverConfig csConfig, ApplicationIdConfig applicationIdConfig) { - this.instance = new ZoneInfo(new ApplicationId(applicationIdConfig.tenant(), - applicationIdConfig.application(), - applicationIdConfig.instance()), - new Zone(Environment.valueOf(csConfig.environment()), csConfig.region())); + public ZoneInfoProvider(ConfigserverConfig csConfig) { + this.instance = new ZoneInfo(new Zone(Environment.valueOf(csConfig.environment()), csConfig.region())); } @Override diff --git a/container-search/abi-spec.json b/container-search/abi-spec.json index 6ed01c2a998..9e3d165b81d 100644 --- a/container-search/abi-spec.json +++ b/container-search/abi-spec.json @@ -1867,8 +1867,6 @@ "public com.yahoo.search.query.profile.compiled.CompiledQueryProfile getQueryProfile()", "public com.yahoo.search.Query$Builder setEmbedder(com.yahoo.language.process.Embedder)", "public com.yahoo.language.process.Embedder getEmbedder()", - "public com.yahoo.search.Query$Builder setZoneInfo(ai.vespa.cloud.ZoneInfo)", - "public ai.vespa.cloud.ZoneInfo getZoneInfo()", "public com.yahoo.search.Query build()" ], "fields": [] @@ -4326,7 +4324,6 @@ "public" ], "methods": [ - "public void <init>(com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.language.process.Embedder, com.yahoo.search.searchchain.ExecutionFactory, ai.vespa.cloud.ZoneInfo)", "public void <init>(com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.language.process.Embedder, com.yahoo.search.searchchain.ExecutionFactory)", "public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.language.process.Embedder, com.yahoo.search.searchchain.ExecutionFactory)", "public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.container.logging.AccessLog, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.search.searchchain.ExecutionFactory)", @@ -6637,7 +6634,7 @@ "public" ], "methods": [ - "public void <init>(java.util.Map, ai.vespa.cloud.ZoneInfo)", + "public void <init>(java.util.Map)", "public java.lang.Object get(com.yahoo.processing.request.CompoundName, java.util.Map, com.yahoo.processing.request.Properties)", "public void set(com.yahoo.processing.request.CompoundName, java.lang.Object, java.util.Map)", "public java.util.Map listProperties(com.yahoo.processing.request.CompoundName, java.util.Map, com.yahoo.processing.request.Properties)" diff --git a/container-search/pom.xml b/container-search/pom.xml index 67400208db1..6417d164019 100644 --- a/container-search/pom.xml +++ b/container-search/pom.xml @@ -50,12 +50,6 @@ </dependency> <dependency> <groupId>com.yahoo.vespa</groupId> - <artifactId>hosted-zone-api</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> <artifactId>config-lib</artifactId> <version>${project.version}</version> <scope>provided</scope> diff --git a/container-search/src/main/java/com/yahoo/search/Query.java b/container-search/src/main/java/com/yahoo/search/Query.java index 786a0d0e04f..ddb8a392730 100644 --- a/container-search/src/main/java/com/yahoo/search/Query.java +++ b/container-search/src/main/java/com/yahoo/search/Query.java @@ -1,9 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search; -import ai.vespa.cloud.Environment; -import ai.vespa.cloud.Zone; -import ai.vespa.cloud.ZoneInfo; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.yahoo.collections.Tuple2; @@ -337,30 +334,22 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { public Query(HttpRequest request, Map<String, String> requestMap, CompiledQueryProfile queryProfile) { super(new QueryPropertyAliases(propertyAliases)); this.httpRequest = request; - init(requestMap, queryProfile, Embedder.throwsOnUse, ZoneInfo.defaultInfo()); + init(requestMap, queryProfile, Embedder.throwsOnUse); } // TODO: Deprecate most constructors above here private Query(Builder builder) { - this(builder.getRequest(), - builder.getRequestMap(), - builder.getQueryProfile(), - builder.getEmbedder(), - builder.getZoneInfo()); + this(builder.getRequest(), builder.getRequestMap(), builder.getQueryProfile(), builder.getEmbedder()); } - private Query(HttpRequest request, Map<String, String> requestMap, CompiledQueryProfile queryProfile, Embedder embedder, - ZoneInfo zoneInfo) { + private Query(HttpRequest request, Map<String, String> requestMap, CompiledQueryProfile queryProfile, Embedder embedder) { super(new QueryPropertyAliases(propertyAliases)); this.httpRequest = request; - init(requestMap, queryProfile, embedder, zoneInfo); + init(requestMap, queryProfile, embedder); } - private void init(Map<String, String> requestMap, - CompiledQueryProfile queryProfile, - Embedder embedder, - ZoneInfo zoneInfo) { + private void init(Map<String, String> requestMap, CompiledQueryProfile queryProfile, Embedder embedder) { startTime = httpRequest.getJDiscRequest().creationTime(TimeUnit.MILLISECONDS); if (queryProfile != null) { // Move all request parameters to the query profile just to validate that the parameter settings are legal @@ -372,7 +361,7 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { // Create the full chain properties().chain(new QueryProperties(this, queryProfile.getRegistry(), embedder)). chain(new ModelObjectMap()). - chain(new RequestContextProperties(requestMap, zoneInfo)). + chain(new RequestContextProperties(requestMap)). chain(queryProfileProperties). chain(new DefaultProperties()); @@ -1142,7 +1131,6 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { private Map<String, String> requestMap = null; private CompiledQueryProfile queryProfile = null; private Embedder embedder = Embedder.throwsOnUse; - private ZoneInfo zoneInfo = ZoneInfo.defaultInfo(); public Builder setRequest(String query) { request = HttpRequest.createTestRequest(query, com.yahoo.jdisc.http.HttpRequest.Method.GET); @@ -1187,13 +1175,6 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { public Embedder getEmbedder() { return embedder; } - public Builder setZoneInfo(ZoneInfo zoneInfo) { - this.zoneInfo = zoneInfo; - return this; - } - - public ZoneInfo getZoneInfo() { return zoneInfo; } - /** Creates a new query from this builder. No properties are required to before calling this. */ public Query build() { return new Query(this); } diff --git a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java index 8925c647ad2..739058ade71 100644 --- a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java +++ b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java @@ -1,8 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.handler; -import ai.vespa.cloud.Environment; -import ai.vespa.cloud.Zone; import com.google.inject.Inject; import com.yahoo.collections.Tuple2; import com.yahoo.component.ComponentSpecification; @@ -55,7 +53,6 @@ import com.yahoo.statistics.Statistics; import com.yahoo.vespa.configdefinition.SpecialtokensConfig; import com.yahoo.yolean.Exceptions; import com.yahoo.yolean.trace.TraceNode; -import ai.vespa.cloud.ZoneInfo; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -73,7 +70,6 @@ import java.util.logging.Logger; * Handles search request. * * @author Steinar Knutsen - * @author bratseth */ public class SearchHandler extends LoggingRequestHandler { @@ -107,46 +103,22 @@ public class SearchHandler extends LoggingRequestHandler { private final ExecutionFactory executionFactory; private final AtomicLong numRequestsLeftToTrace; - private final ZoneInfo zoneInfo; - private final static RequestHandlerSpec REQUEST_HANDLER_SPEC = RequestHandlerSpec.builder() .withAclMapping(SearchHandler.aclRequestMapper()).build(); - @Inject public SearchHandler(Metric metric, ContainerThreadPool threadpool, CompiledQueryProfileRegistry queryProfileRegistry, ContainerHttpConfig config, Embedder embedder, - ExecutionFactory executionFactory, - ZoneInfo zoneInfo) { - this(metric, threadpool.executor(), queryProfileRegistry, embedder, executionFactory, - config.numQueriesToTraceOnDebugAfterConstruction(), - config.hostResponseHeaderKey().equals("") ? Optional.empty() : Optional.of(config.hostResponseHeaderKey()), - zoneInfo); - } - - /** - * @deprecated Use the @Inject annotated constructor instead. - */ - @Deprecated // Vespa 8 - public SearchHandler(Metric metric, - ContainerThreadPool threadpool, - CompiledQueryProfileRegistry queryProfileRegistry, - ContainerHttpConfig config, - Embedder embedder, ExecutionFactory executionFactory) { this(metric, threadpool.executor(), queryProfileRegistry, embedder, executionFactory, - config.numQueriesToTraceOnDebugAfterConstruction(), - config.hostResponseHeaderKey().equals("") ? Optional.empty() : Optional.of(config.hostResponseHeaderKey()), - ZoneInfo.defaultInfo()); + config.numQueriesToTraceOnDebugAfterConstruction(), + config.hostResponseHeaderKey().equals("") ? Optional.empty() : Optional.of(config.hostResponseHeaderKey())); } - /** - * @deprecated Use the @Inject annotated constructor instead. - */ - @Deprecated // Vespa 8 + @Deprecated public SearchHandler(Statistics statistics, Metric metric, ContainerThreadPool threadpool, @@ -156,8 +128,7 @@ public class SearchHandler extends LoggingRequestHandler { ExecutionFactory executionFactory) { this(metric, threadpool.executor(), queryProfileRegistry, embedder, executionFactory, config.numQueriesToTraceOnDebugAfterConstruction(), - config.hostResponseHeaderKey().equals("") ? Optional.empty() : Optional.of(config.hostResponseHeaderKey()), - ZoneInfo.defaultInfo()); + config.hostResponseHeaderKey().equals("") ? Optional.empty() : Optional.of(config.hostResponseHeaderKey())); } /** @@ -187,9 +158,8 @@ public class SearchHandler extends LoggingRequestHandler { ExecutionFactory executionFactory) { this(metric, executor, queryProfileRegistry, Embedder.throwsOnUse, executionFactory, containerHttpConfig.numQueriesToTraceOnDebugAfterConstruction(), - containerHttpConfig.hostResponseHeaderKey().equals("") ? Optional.empty() - : Optional.of(containerHttpConfig.hostResponseHeaderKey()), - ZoneInfo.defaultInfo()); + containerHttpConfig.hostResponseHeaderKey().equals("") ? + Optional.empty() : Optional.of(containerHttpConfig.hostResponseHeaderKey())); } /** @@ -206,9 +176,8 @@ public class SearchHandler extends LoggingRequestHandler { this(metric, executor, QueryProfileConfigurer.createFromConfig(queryProfileConfig).compile(), Embedder.throwsOnUse, executionFactory, containerHttpConfig.numQueriesToTraceOnDebugAfterConstruction(), - containerHttpConfig.hostResponseHeaderKey().equals("") ? Optional.empty() - : Optional.of( containerHttpConfig.hostResponseHeaderKey()), - ZoneInfo.defaultInfo()); + containerHttpConfig.hostResponseHeaderKey().equals("") ? + Optional.empty() : Optional.of( containerHttpConfig.hostResponseHeaderKey())); } /** @@ -223,8 +192,7 @@ public class SearchHandler extends LoggingRequestHandler { ExecutionFactory executionFactory, Optional<String> hostResponseHeaderKey) { this(metric, executor, queryProfileRegistry, Embedder.throwsOnUse, - executionFactory, 0, hostResponseHeaderKey, - ZoneInfo.defaultInfo()); + executionFactory, 0, hostResponseHeaderKey); } private SearchHandler(Metric metric, @@ -233,8 +201,7 @@ public class SearchHandler extends LoggingRequestHandler { Embedder embedder, ExecutionFactory executionFactory, long numQueriesToTraceOnDebugAfterStartup, - Optional<String> hostResponseHeaderKey, - ZoneInfo zoneInfo) { + Optional<String> hostResponseHeaderKey) { super(executor, metric, true); log.log(Level.FINE, () -> "SearchHandler.init " + System.identityHashCode(this)); this.queryProfileRegistry = queryProfileRegistry; @@ -246,7 +213,6 @@ public class SearchHandler extends LoggingRequestHandler { this.hostResponseHeaderKey = hostResponseHeaderKey; this.numRequestsLeftToTrace = new AtomicLong(numQueriesToTraceOnDebugAfterStartup); metric.set(SEARCH_CONNECTIONS, 0.0d, null); - this.zoneInfo = zoneInfo; } /** @deprecated use the other constructor */ @@ -342,7 +308,6 @@ public class SearchHandler extends LoggingRequestHandler { .setRequestMap(requestMap) .setQueryProfile(queryProfile) .setEmbedder(embedder) - .setZoneInfo(zoneInfo) .build(); boolean benchmarking = VespaHeaders.benchmarkOutput(request); diff --git a/container-search/src/main/java/com/yahoo/search/query/properties/RequestContextProperties.java b/container-search/src/main/java/com/yahoo/search/query/properties/RequestContextProperties.java index 46aafcb11e3..06d827faf68 100644 --- a/container-search/src/main/java/com/yahoo/search/query/properties/RequestContextProperties.java +++ b/container-search/src/main/java/com/yahoo/search/query/properties/RequestContextProperties.java @@ -1,17 +1,13 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.query.properties; -import ai.vespa.cloud.ZoneInfo; import com.yahoo.processing.request.CompoundName; import com.yahoo.search.query.Properties; -import java.util.Collections; -import java.util.HashMap; import java.util.Map; /** - * Turns get(name) into get(name, context) using the request given at construction time - * and the zone info. + * Turns get(name) into get(name, request) using the request given at construction time. * This is used to allow the query's request to be supplied to all property requests * without forcing users of the query.properties() to supply this explicitly. * @@ -19,36 +15,27 @@ import java.util.Map; */ public class RequestContextProperties extends Properties { - private final Map<String, String> context; - - public RequestContextProperties(Map<String, String> properties, ZoneInfo zoneInfo) { - if (zoneInfo == ZoneInfo.defaultInfo()) { - context = properties; - } - else { - Map<String, String> context = new HashMap<>(properties); - context.putIfAbsent("environment", zoneInfo.zone().environment().name()); - context.putIfAbsent("region", zoneInfo.zone().region()); - context.putIfAbsent("instance", zoneInfo.application().instance()); - this.context = Collections.unmodifiableMap(context); - } + private final Map<String, String> requestMap; + + public RequestContextProperties(Map<String, String> properties) { + this.requestMap = properties; } @Override public Object get(CompoundName name, Map<String,String> context, com.yahoo.processing.request.Properties substitution) { - return super.get(name, context == null ? this.context : context, substitution); + return super.get(name, context == null ? requestMap : context, substitution); } @Override public void set(CompoundName name, Object value, Map<String,String> context) { - super.set(name, value, context == null ? this.context : context); + super.set(name, value, context == null ? requestMap : context); } @Override public Map<String, Object> listProperties(CompoundName path, Map<String,String> context, com.yahoo.processing.request.Properties substitution) { - return super.listProperties(path, context == null ? this.context : context, substitution); + return super.listProperties(path, context == null ? requestMap : context, substitution); } } diff --git a/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java b/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java index e1987aa50ca..a6ae5f2b1b9 100644 --- a/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java +++ b/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java @@ -186,7 +186,7 @@ public class SearchHandlerTest { RequestHandlerTestDriver.MockResponseHandler responseHandler = newDriver.sendRequest( "http://localhost/search/?yql=select%20*%20from%20foo%20where%20bar%20%3E%201453501295%27%3B"); responseHandler.readAll(); - assertEquals(400, responseHandler.getStatus()); + assertThat(responseHandler.getStatus(), is(400)); assertEquals(Request.RequestType.READ, responseHandler.getResponse().getRequestType()); } } diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java index 3542e1413eb..231020c4fa5 100644 --- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java @@ -1,11 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.query.profile.test; -import ai.vespa.cloud.ApplicationId; -import ai.vespa.cloud.Environment; -import ai.vespa.cloud.Zone; -import ai.vespa.cloud.ZoneInfo; -import com.yahoo.jdisc.application.Application; import com.yahoo.jdisc.http.HttpRequest.Method; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.processing.request.CompoundName; @@ -1336,53 +1331,6 @@ public class QueryProfileVariantsTestCase { assertEquals("yahoo/alerts", cAlert.get("vertical.custid", toMap("entry=alert", "intl=us", "lang=en-US"))); } - @Test - public void testZoneInfoInContext() { - QueryProfileRegistry registry = new QueryProfileRegistry(); - QueryProfile profile = new QueryProfile("test"); - profile.setDimensions(new String[] { "environment", "region", "instance" }); - profile.set("value", "default", registry); - profile.set("value", "prod-region1-instance1", - toMap("environment=prod", "region=region1", "instance=instance1"), - registry); - profile.set("value", "prod-instance2", - toMap("environment=prod", "instance=instance2"), - registry); - profile.set("value", "prod-region3", - toMap("environment=prod", "region=region3"), - registry); - profile.set("value", "dev", - toMap("environment=dev"), - registry); - registry.register(profile); - - CompiledQueryProfileRegistry cRegistry = registry.compile(); - CompiledQueryProfile cTest = cRegistry.findQueryProfile("test"); - - assertValueForZone("default", ZoneInfo.defaultInfo(), cTest); - assertValueForZone("prod-region1-instance1", - new ZoneInfo(new ApplicationId("tenant1", "application1", "instance1"), - new Zone(Environment.prod, "region1")), - cTest); - assertValueForZone("prod-instance2", - new ZoneInfo(new ApplicationId("tenant2", "application2", "instance2"), - new Zone(Environment.prod, "region1")), - cTest); - assertValueForZone("prod-region3", - new ZoneInfo(new ApplicationId("tenant3", "application3", "instance3"), - new Zone(Environment.prod, "region3")), - cTest); - assertValueForZone("dev", - new ZoneInfo(new ApplicationId("tenant4", "application4", "instance4"), - new Zone(Environment.dev, "region4")), - cTest); - } - - private void assertValueForZone(String expected, ZoneInfo zoneInfo, CompiledQueryProfile cTest) { - assertEquals(expected, - new Query.Builder().setQueryProfile(cTest).setZoneInfo(zoneInfo).build().properties().get("value")); - } - private void assertGet(String expectedValue, String parameter, String[] dimensionValues, QueryProfile profile, CompiledQueryProfile cprofile) { Map<String,String> context=toMap(profile,dimensionValues); assertEquals("Looking up '" + parameter + "' for '" + Arrays.toString(dimensionValues) + "'",expectedValue,cprofile.get(parameter,context)); diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java index d6e99ec3a44..a642d14b368 100644 --- a/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java @@ -5,7 +5,6 @@ import com.yahoo.config.search.IntConfig; import com.yahoo.config.search.StringConfig; import com.yahoo.container.core.config.HandlersConfigurerDi; import com.yahoo.container.core.config.testutil.HandlersConfigurerTestWrapper; -import com.yahoo.lang.MutableInteger; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.Searcher; @@ -39,7 +38,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertThat; @@ -131,7 +129,7 @@ public class SearchChainConfigurerTestCase { @Test public void testConfigurableSearcher() { - HandlersConfigurerTestWrapper configurer = new HandlersConfigurerTestWrapper("dir:" + testDir); + HandlersConfigurerTestWrapper configurer=new HandlersConfigurerTestWrapper("dir:" + testDir); SearchChain configurable = getSearchChainRegistryFrom(configurer).getComponent("configurable"); assertNotNull(configurable); @@ -139,8 +137,9 @@ public class SearchChainConfigurerTestCase { Searcher s = configurable.searchers().get(0); assertThat(s, instanceOf(ConfigurableSearcher.class)); ConfigurableSearcher searcher = (ConfigurableSearcher)s; - assertEquals("Value from int.cfg file", 7, searcher.intConfig.intVal()); - assertEquals("Value from string.cfg file", "com.yahoo.search.searchchain.config.test", searcher.stringConfig.stringVal()); + assertThat("Value from int.cfg file", searcher.intConfig.intVal(), is(7)); + assertThat("Value from string.cfg file", searcher.stringConfig.stringVal(), + is("com.yahoo.search.searchchain.config.test")); configurer.shutdown(); } @@ -343,7 +342,7 @@ public class SearchChainConfigurerTestCase { if (append) { Pattern p = Pattern.compile("^[a-z]+" + "\\[\\d+\\]\\.id (.+)"); BufferedReader reader = new BufferedReader(new InputStreamReader( - new FileInputStream(componentsFile), StandardCharsets.UTF_8)); + new FileInputStream(new File(componentsFile)), StandardCharsets.UTF_8)); while ((line = reader.readLine()) != null) { Matcher m = p.matcher(line); if (m.matches() && !m.group(1).equals(HandlersConfigurerDi.RegistriesHack.class.getName())) { @@ -354,7 +353,7 @@ public class SearchChainConfigurerTestCase { reader.close(); } BufferedReader reader = new BufferedReader(new InputStreamReader( - new FileInputStream(configFile), StandardCharsets.UTF_8)); + new FileInputStream(new File(configFile)), StandardCharsets.UTF_8)); Pattern component = Pattern.compile("^" + componentType + "\\[\\d+\\]\\.id (.+)"); while ((line = reader.readLine()) != null) { Matcher m = component.matcher(line); @@ -367,22 +366,13 @@ public class SearchChainConfigurerTestCase { buf.append("components[").append(i++).append("].id ").append(HandlersConfigurerDi.RegistriesHack.class.getName()).append("\n"); if (componentType.equals("components")) - i = addStandardComponents(i, buf); + buf.append("components[").append(i++).append("].id ").append(ExecutionFactory.class.getName()).append("\n"); buf.insert(0, "components["+i+"]\n"); - Writer writer = new OutputStreamWriter(new FileOutputStream(componentsFile), StandardCharsets.UTF_8); + Writer writer = new OutputStreamWriter(new FileOutputStream(new File(componentsFile)), StandardCharsets.UTF_8); writer.write(buf.toString()); writer.flush(); writer.close(); } - private static int addStandardComponents(int i, StringBuilder builder) { - addComponent(ExecutionFactory.class.getName(), i++, builder); - return i; - } - - private static void addComponent(String component, int i, StringBuilder builder) { - builder.append("components[").append(i).append("].id ").append(component).append("\n"); - } - } diff --git a/hosted-zone-api/abi-spec.json b/hosted-zone-api/abi-spec.json index 11375d97972..b1b8eb84705 100644 --- a/hosted-zone-api/abi-spec.json +++ b/hosted-zone-api/abi-spec.json @@ -105,11 +105,8 @@ "public" ], "methods": [ - "public void <init>(ai.vespa.cloud.ApplicationId, ai.vespa.cloud.Zone)", "public void <init>(ai.vespa.cloud.Zone)", - "public ai.vespa.cloud.ApplicationId application()", - "public ai.vespa.cloud.Zone zone()", - "public static ai.vespa.cloud.ZoneInfo defaultInfo()" + "public ai.vespa.cloud.Zone zone()" ], "fields": [] } diff --git a/hosted-zone-api/src/main/java/ai/vespa/cloud/ZoneInfo.java b/hosted-zone-api/src/main/java/ai/vespa/cloud/ZoneInfo.java index e4b69caa940..d9af2421ab9 100644 --- a/hosted-zone-api/src/main/java/ai/vespa/cloud/ZoneInfo.java +++ b/hosted-zone-api/src/main/java/ai/vespa/cloud/ZoneInfo.java @@ -4,9 +4,9 @@ package ai.vespa.cloud; import java.util.Objects; /** - * Provides information about the zone context in which this container is running. + * Provides information about the zone in which this container is running. * This is available and can be injected when running in a cloud environment. - * If you don't need any other information than what's present here this should be preferred + * If you don't need any other information than the zone this should be preferred * to SystemInfo as it will never change at runtime and therefore does not * cause unnecessary reconstruction. * @@ -14,30 +14,14 @@ import java.util.Objects; */ public class ZoneInfo { - private static final ZoneInfo defaultInfo = new ZoneInfo(new ApplicationId("default", "default", "default"), - new Zone(Environment.prod, "default")); - - private final ApplicationId application; private final Zone zone; - public ZoneInfo(ApplicationId application, Zone zone) { - this.application = Objects.requireNonNull(application, "Application cannot be null!"); - this.zone = Objects.requireNonNull(zone, "Zone cannot be null!"); - } - - /** @deprecated pass an application id */ - @Deprecated // Remove on Vespa 8 public ZoneInfo(Zone zone) { - this(new ApplicationId("default", "default", "default"), zone); + Objects.requireNonNull(zone, "Zone cannot be null!"); + this.zone = zone; } - /** Returns the application this is running as part of */ - public ApplicationId application() { return application; } - /** Returns the zone this is running in */ public Zone zone() { return zone; } - /** Returns the info instance used when no zone info is available because we're not running in a cloud context */ - public static ZoneInfo defaultInfo() { return defaultInfo; } - } diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/ContainerBuilder.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/ContainerBuilder.java index eb602737c8f..db7d7e82ffb 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/ContainerBuilder.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/ContainerBuilder.java @@ -8,11 +8,8 @@ import com.google.inject.Module; import com.yahoo.jdisc.Container; import com.yahoo.jdisc.handler.RequestHandler; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.concurrent.ThreadFactory; /** * <p>This is the inactive, mutable {@link Container}. Because it requires references to the application internals, it @@ -41,8 +38,8 @@ public class ContainerBuilder { bind(ContainerBuilder.class).toInstance(ContainerBuilder.this); } }); - this.serverBindings.put(BindingSet.DEFAULT, new BindingRepository<>()); - this.clientBindings.put(BindingSet.DEFAULT, new BindingRepository<>()); + this.serverBindings.put(BindingSet.DEFAULT, new BindingRepository<RequestHandler>()); + this.clientBindings.put(BindingSet.DEFAULT, new BindingRepository<RequestHandler>()); } public void setAppContext(Object ctx) { @@ -133,5 +130,4 @@ public class ContainerBuilder { } return lst; } - } |