diff options
77 files changed, 176 insertions, 1689 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b1934a8a08..3598d259144 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,6 @@ add_subdirectory(configutil) add_subdirectory(container-apache-http-client-bundle) add_subdirectory(container-core) add_subdirectory(container-disc) -add_subdirectory(container-jersey2) add_subdirectory(container-messagebus) add_subdirectory(container-search) add_subdirectory(container-search-gui) diff --git a/application/pom.xml b/application/pom.xml index c0bef61f57d..f671c16c5a6 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -83,12 +83,6 @@ <artifactId>junit</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>com.yahoo.vespa.container-test-jars</groupId> - <artifactId>jersey-resources</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> <!-- All dependencies that should be visible in test classpath, but not compile classpath, for user projects must be added in compile scope here. @@ -183,31 +177,6 @@ </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - <executions> - <execution> - <id>copy</id> - <phase>process-test-resources</phase> - <goals> - <goal>copy</goal> - </goals> - <configuration> - <artifactItems> - <artifactItem> - <groupId>com.yahoo.vespa.container-test-jars</groupId> - <artifactId>jersey-resources</artifactId> - <version>${project.version}</version> - <type>jar</type> - <outputDirectory>target/test-jars</outputDirectory> - <destFileName>jersey-resources.jar</destFileName> - </artifactItem> - </artifactItems> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <forkCount>2</forkCount> diff --git a/application/src/test/java/com/yahoo/application/container/jersey/JerseyTest.java b/application/src/test/java/com/yahoo/application/container/jersey/JerseyTest.java deleted file mode 100644 index 18e206c7add..00000000000 --- a/application/src/test/java/com/yahoo/application/container/jersey/JerseyTest.java +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.application.container.jersey; - -import com.yahoo.application.Networking; -import com.yahoo.application.container.JDisc; -import com.yahoo.application.container.ContainerTest; -import com.yahoo.application.container.jersey.resources.TestResource; -import com.yahoo.application.container.jersey.resources.nestedpackage1.NestedTestResource1; -import com.yahoo.application.container.jersey.resources.nestedpackage2.NestedTestResource2; -import com.yahoo.container.test.jars.jersey.resources.TestResourceBase; -import com.yahoo.osgi.maven.ProjectBundleClassPaths; -import com.yahoo.osgi.maven.ProjectBundleClassPaths.BundleClasspathMapping; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; -import org.junit.Ignore; -import org.junit.Test; - -import javax.ws.rs.core.UriBuilder; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import static java.util.Collections.emptyList; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -@Ignore // TODO: remove test -public class JerseyTest { - private final Path testJar = Paths.get("target/test-jars/jersey-resources.jar"); - private final String testClassesDirectory = "target/test-classes"; - private final String bundleSymbolicName = "myBundle"; - - private final Set<Class<? extends TestResourceBase>> classPathResources; - private final Set<Class<? extends TestResourceBase>> jarFileResources; - - public JerseyTest() { - classPathResources = new HashSet<>(); - classPathResources.add(TestResource.class); - classPathResources.add(NestedTestResource1.class); - classPathResources.add(NestedTestResource2.class); - - jarFileResources = new HashSet<>(); - jarFileResources.add(com.yahoo.container.test.jars.jersey.resources.TestResource.class); - jarFileResources.add(com.yahoo.container.test.jars.jersey.resources.nestedpackage1.NestedTestResource1.class); - jarFileResources.add(com.yahoo.container.test.jars.jersey.resources.nestedpackage2.NestedTestResource2.class); - } - - @Test - public void jersey_resources_on_classpath_can_be_invoked_from_application() throws Exception { - saveMainBundleClassPathMappings(testClassesDirectory); - - with_jersey_resources(emptyList(), httpGetter -> assertResourcesResponds(classPathResources, httpGetter)); - } - - @Test - public void jersey_resources_in_provided_dependencies_can_be_invoked_from_application() throws Exception { - BundleClasspathMapping providedDependency = - new BundleClasspathMapping(bundleSymbolicName, List.of(testClassesDirectory)); - - save(new ProjectBundleClassPaths(new BundleClasspathMapping("main", emptyList()), List.of(providedDependency))); - with_jersey_resources(emptyList(), httpGetter -> assertResourcesResponds(classPathResources, httpGetter)); - } - - @Test - public void jersey_resource_on_classpath_can_be_filtered_using_packages() throws Exception { - saveMainBundleClassPathMappings(testClassesDirectory); - - with_jersey_resources(Arrays.asList("com.yahoo.application.container.jersey.resources", - "com.yahoo.application.container.jersey.resources.nestedpackage1"), httpGetter -> { - Class<NestedTestResource2> nestedResource2 = NestedTestResource2.class; - assertDoesNotRespond(nestedResource2, httpGetter); - assertResourcesResponds(copySetExcept(classPathResources, nestedResource2), httpGetter); - }); - } - - @Test - public void jersey_resource_in_jar_can_be_invoked_from_application() throws Exception { - saveMainBundleJarClassPathMappings(testJar); - - with_jersey_resources(emptyList(), httpGetter -> assertResourcesResponds(jarFileResources, httpGetter)); - } - - @Test - public void jersey_resource_in_jar_can_be_filtered_using_packages() throws Exception { - saveMainBundleJarClassPathMappings(testJar); - - with_jersey_resources(Arrays.asList("com.yahoo.container.test.jars.jersey.resources", - "com.yahoo.container.test.jars.jersey.resources.nestedpackage1"), httpGetter -> { - Class<com.yahoo.container.test.jars.jersey.resources.nestedpackage2.NestedTestResource2> nestedResource2 = com.yahoo.container.test.jars.jersey.resources.nestedpackage2.NestedTestResource2.class; - - assertDoesNotRespond(nestedResource2, httpGetter); - assertResourcesResponds(copySetExcept(jarFileResources, nestedResource2), httpGetter); - }); - } - - private static <T> Set<T> copySetExcept(Set<T> in, T except) { - Set<T> ret = new HashSet<>(in); - ret.remove(except); - return ret; - } - - private interface ThrowingConsumer<T> { - void accept(T arg) throws Exception; - } - - private interface HttpGetter { - HttpResponse get(String path) throws Exception; - } - - @SuppressWarnings("try") // jdisc unreferenced inside try - private void with_jersey_resources(List<String> packagesToScan, ThrowingConsumer<HttpGetter> f) throws Exception { - StringBuilder packageElements = new StringBuilder(); - for (String p : packagesToScan) { - packageElements.append("<package>"); - packageElements.append(p); - packageElements.append("</package>"); - } - - try (JDisc jdisc = JDisc.fromServicesXml( - "<services>" + // - "<container version=\"1.0\" id=\"default\" jetty=\"true\">" + // - "<rest-api path=\"rest-api\" jersey2=\"true\">" + // - "<components bundle=\"" + bundleSymbolicName + "\">" + // - packageElements + // - "</components>" + // - "</rest-api>" + // - "<http>" + // - "<server id=\"mainServer\" port=\"0\" />" + // - "</http>" + // - "<accesslog type=\"disabled\" />" + - "</container>" + // - "</services>", // - Networking.enable)) { - final int port = ContainerTest.getListenPort(); - f.accept(path -> { - String p = path.startsWith("/") ? path.substring(1) : path; - CloseableHttpClient client = HttpClientBuilder.create().build(); - return client.execute(new HttpGet("http://localhost:" + port + "/rest-api/" + p)); - }); - } - } - - public void assertResourcesResponds(Collection<Class<? extends TestResourceBase>> resourceClasses, - HttpGetter httpGetter) throws Exception { - for (Class<? extends TestResourceBase> resource : resourceClasses) { - HttpResponse response = httpGetter.get(path(resource)); - assertThat("Failed sending response to " + resource, response.getStatusLine().getStatusCode(), is(200)); - - String content = new String(response.getEntity().getContent().readAllBytes(), StandardCharsets.UTF_8); - assertThat(content, is(TestResourceBase.content(resource))); - } - } - - public void assertDoesNotRespond(Class<? extends TestResourceBase> resourceClass, HttpGetter httpGetter) - throws Exception { - HttpResponse response = httpGetter.get(path(resourceClass)); - assertThat(response.getStatusLine().getStatusCode(), is(404)); - EntityUtils.consume(response.getEntity()); - } - - public void saveMainBundleJarClassPathMappings(Path jarFile) throws Exception { - assertTrue("Couldn't find file " + jarFile + ", please remember to run mvn process-test-resources first.", - Files.isRegularFile(jarFile)); - saveMainBundleClassPathMappings(jarFile.toAbsolutePath().toString()); - } - - public void saveMainBundleClassPathMappings(String classPathElement) throws Exception { - BundleClasspathMapping mainBundleClassPathMappings = - new BundleClasspathMapping(bundleSymbolicName, List.of(classPathElement)); - save(new ProjectBundleClassPaths(mainBundleClassPathMappings, emptyList())); - } - - public void save(ProjectBundleClassPaths projectBundleClassPaths) throws Exception { - Path path = Paths.get(testClassesDirectory).resolve(ProjectBundleClassPaths.CLASSPATH_MAPPINGS_FILENAME); - ProjectBundleClassPaths.save(path, projectBundleClassPaths); - } - - public String path(Class<?> resourceClass) { - return UriBuilder.fromResource(resourceClass).build().toString(); - } -} diff --git a/application/src/test/java/com/yahoo/application/container/jersey/resources/TestResource.java b/application/src/test/java/com/yahoo/application/container/jersey/resources/TestResource.java deleted file mode 100644 index 5b6f1fa9c35..00000000000 --- a/application/src/test/java/com/yahoo/application/container/jersey/resources/TestResource.java +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.application.container.jersey.resources; - -import com.yahoo.container.test.jars.jersey.resources.TestResourceBase; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -@Path("/test-resource") -public class TestResource extends TestResourceBase { -} diff --git a/application/src/test/java/com/yahoo/application/container/jersey/resources/nestedpackage1/NestedTestResource1.java b/application/src/test/java/com/yahoo/application/container/jersey/resources/nestedpackage1/NestedTestResource1.java deleted file mode 100644 index d4901995152..00000000000 --- a/application/src/test/java/com/yahoo/application/container/jersey/resources/nestedpackage1/NestedTestResource1.java +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.application.container.jersey.resources.nestedpackage1; - -import com.yahoo.container.test.jars.jersey.resources.TestResourceBase; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -@Path("/nested-test-resource1") -public class NestedTestResource1 extends TestResourceBase { -} diff --git a/application/src/test/java/com/yahoo/application/container/jersey/resources/nestedpackage2/NestedTestResource2.java b/application/src/test/java/com/yahoo/application/container/jersey/resources/nestedpackage2/NestedTestResource2.java deleted file mode 100644 index 1763023a533..00000000000 --- a/application/src/test/java/com/yahoo/application/container/jersey/resources/nestedpackage2/NestedTestResource2.java +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.application.container.jersey.resources.nestedpackage2; - -import com.yahoo.container.test.jars.jersey.resources.TestResourceBase; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -@Path("/nested-test-resource2") -public class NestedTestResource2 extends TestResourceBase { -} diff --git a/cloud-tenant-base-dependencies-enforcer/pom.xml b/cloud-tenant-base-dependencies-enforcer/pom.xml index 340123ae659..481211390e0 100644 --- a/cloud-tenant-base-dependencies-enforcer/pom.xml +++ b/cloud-tenant-base-dependencies-enforcer/pom.xml @@ -152,7 +152,6 @@ <include>com.yahoo.vespa:container-dev:*:jar:provided</include> <include>com.yahoo.vespa:container-disc:*:jar:provided</include> <include>com.yahoo.vespa:container-documentapi:*:jar:provided</include> - <include>com.yahoo.vespa:container-jersey2:*:jar:provided</include> <include>com.yahoo.vespa:container-messagebus:*:jar:provided</include> <include>com.yahoo.vespa:container-search-and-docproc:*:jar:provided</include> <include>com.yahoo.vespa:container-search:*:jar:provided</include> diff --git a/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/Reindexer.java b/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/Reindexer.java index 93b21c8166b..b056ba962fa 100644 --- a/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/Reindexer.java +++ b/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/Reindexer.java @@ -97,11 +97,10 @@ public class Reindexer { // Keep metrics in sync across cluster controller containers. AtomicReference<Reindexing> reindexing = new AtomicReference<>(database.readReindexing(cluster.name())); - database.writeReindexing(reindexing.get(), cluster.name()); metrics.dump(reindexing.get()); try (Lock lock = database.lockReindexing(cluster.name())) { - reindexing.set(updateWithReady(ready, reindexing.get(), clock.instant())); + reindexing.set(updateWithReady(ready, database.readReindexing(cluster.name()), clock.instant())); database.writeReindexing(reindexing.get(), cluster.name()); metrics.dump(reindexing.get()); @@ -178,8 +177,7 @@ public class Reindexer { sessionShutdown.run(); // Shutdown aborts the session unless already complete, then waits for it to terminate normally. // Only as a last resort will we be interrupted here, and the wait for outstanding replies terminate. - CompletionCode result = control.getResult() != null ? control.getResult().getCode() - : CompletionCode.ABORTED; + CompletionCode result = control.getResult() != null ? control.getResult().getCode() : CompletionCode.ABORTED; switch (result) { default: log.log(WARNING, "Unexpected visitor result '" + control.getResult().getCode() + "'"); diff --git a/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/Reindexing.java b/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/Reindexing.java index 1b5a685b69c..896b9dfc26e 100644 --- a/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/Reindexing.java +++ b/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/Reindexing.java @@ -72,11 +72,11 @@ public class Reindexing { private final Instant startedAt; private final Instant endedAt; - private final ProgressToken progress; + private final String progress; private final State state; private final String message; - Status(Instant startedAt, Instant endedAt, ProgressToken progress, State state, String message) { + Status(Instant startedAt, Instant endedAt, String progress, State state, String message) { this.startedAt = startedAt; this.endedAt = endedAt; this.progress = progress; @@ -100,7 +100,9 @@ public class Reindexing { public Status progressed(ProgressToken progress) { if (state != State.RUNNING) throw new IllegalStateException("Current state must be RUNNING when updating progress"); - return new Status(startedAt, null, requireNonNull(progress), state, null); + synchronized (progress) { + return new Status(startedAt, null, progress.serializeToString(), state, null); + } } /** Returns a copy of this in state HALTED. */ @@ -133,7 +135,7 @@ public class Reindexing { } public Optional<ProgressToken> progress() { - return Optional.ofNullable(progress); + return Optional.ofNullable(progress).map(ProgressToken::fromSerializedString); } public State state() { diff --git a/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/ReindexingCurator.java b/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/ReindexingCurator.java index d46ab812aca..67816ad0be1 100644 --- a/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/ReindexingCurator.java +++ b/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/ReindexingCurator.java @@ -5,7 +5,6 @@ import ai.vespa.reindexing.Reindexing.Status; import com.google.common.util.concurrent.UncheckedTimeoutException; import com.yahoo.document.DocumentType; import com.yahoo.document.DocumentTypeManager; -import com.yahoo.documentapi.ProgressToken; import com.yahoo.path.Path; import com.yahoo.slime.Cursor; import com.yahoo.slime.Inspector; @@ -17,9 +16,10 @@ import com.yahoo.yolean.Exceptions; import java.time.Duration; import java.time.Instant; -import java.util.Collection; import java.util.Map; import java.util.function.Function; +import java.util.logging.Level; +import java.util.logging.Logger; import static java.util.Objects.requireNonNull; import static java.util.stream.Collectors.toUnmodifiableMap; @@ -31,6 +31,8 @@ import static java.util.stream.Collectors.toUnmodifiableMap; */ public class ReindexingCurator { + private static final Logger log = Logger.getLogger(ReindexingCurator.class.getName()); + private final Curator curator; private final ReindexingSerializer serializer; private final Duration lockTimeout; @@ -57,6 +59,7 @@ public class ReindexingCurator { if (ready.get(type).isBefore(now)) reindexing = reindexing.with(type, Status.ready(now).running().successful(now)); + log.log(Level.INFO, "Creating initial reindexing status at '" + statusPath(cluster) + "'"); writeReindexing(reindexing, cluster); } catch (ReindexingLockException ignored) { @@ -66,11 +69,14 @@ public class ReindexingCurator { } public Reindexing readReindexing(String cluster) { - return curator.getData(statusPath(cluster)).map(serializer::deserialize) - .orElse(Reindexing.empty()); + Reindexing reindexing = curator.getData(statusPath(cluster)).map(serializer::deserialize) + .orElse(Reindexing.empty()); + log.log(Level.FINE, () -> "Read reindexing status '" + reindexing + "' from '" + statusPath(cluster) + "'"); + return reindexing; } public void writeReindexing(Reindexing reindexing, String cluster) { + log.log(Level.FINE, () -> "Writing reindexing status '" + reindexing + "' to '" + statusPath(cluster) + "'"); curator.set(statusPath(cluster), serializer.serialize(reindexing)); } @@ -126,7 +132,7 @@ public class ReindexingCurator { .collect(toUnmodifiableMap(object -> require(TYPE, object, field -> types.getDocumentType(field.asString())), object -> new Status(require(STARTED_MILLIS, object, field -> Instant.ofEpochMilli(field.asLong())), get(ENDED_MILLIS, object, field -> Instant.ofEpochMilli(field.asLong())), - get(PROGRESS, object, field -> ProgressToken.fromSerializedString(field.asString())), + get(PROGRESS, object, field -> field.asString()), require(STATE, object, field -> toState(field.asString())), get(MESSAGE, object, field -> field.asString()))))); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/BoolAttributeValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/BoolAttributeValidator.java new file mode 100644 index 00000000000..7ee22c3fd23 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/BoolAttributeValidator.java @@ -0,0 +1,36 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.searchdefinition.processing; + +import com.yahoo.config.application.api.DeployLogger; +import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.document.Attribute; +import com.yahoo.vespa.model.container.search.QueryProfiles; + +/** + * Validates attribute fields using bool type, ensuring the collection type is supported. + * + * Currently, only the single value bool type is supported. + * + * @author geirst + */ +public class BoolAttributeValidator extends Processor { + + public BoolAttributeValidator(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(search, deployLogger, rankProfileRegistry, queryProfiles); + } + + @Override + public void process(boolean validate, boolean documentsOnly) { + for (var field : search.allConcreteFields()) { + var attribute = field.getAttribute(); + if (attribute == null) { + continue; + } + if (attribute.getType().equals(Attribute.Type.BOOL) && + !attribute.getCollectionType().equals(Attribute.CollectionType.SINGLE)) { + fail(search, field, "Only single value bool attribute fields are supported"); + } + } + } +} diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processing.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processing.java index 136d352ece7..750842d398c 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processing.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processing.java @@ -78,6 +78,7 @@ public class Processing { OnnxModelConfigGenerator::new, OnnxModelTypeResolver::new, RankingExpressionTypeResolver::new, + BoolAttributeValidator::new, // These should be last: IndexingValidation::new, IndexingValues::new); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java index 4cc8439566e..a6704481734 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java @@ -48,7 +48,8 @@ public class ComplexAttributeFieldsValidator extends Validator { if (!unsupportedFields.isEmpty()) { throw new IllegalArgumentException( String.format("For cluster '%s', search '%s': The following complex fields do not support using struct field attributes: %s. " + - "Only supported for the following complex field types: array or map of struct with primitive types, map of primitive types", + "Only supported for the following complex field types: array or map of struct with primitive types, map of primitive types. " + + "The supported primitive types are: byte, int, long, float, double and string", clusterName, search.getName(), unsupportedFields)); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java index 317ed0f66c7..59e9b1a2b4d 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java @@ -34,8 +34,6 @@ import com.yahoo.vespa.model.container.component.Handler; import com.yahoo.vespa.model.container.component.Servlet; import com.yahoo.vespa.model.container.component.SystemBindingPattern; import com.yahoo.vespa.model.container.configserver.ConfigserverCluster; -import com.yahoo.vespa.model.container.jersey.Jersey2Servlet; -import com.yahoo.vespa.model.container.jersey.RestApi; import com.yahoo.vespa.model.container.xml.PlatformBundles; import com.yahoo.vespa.model.utils.FileSender; @@ -80,7 +78,6 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat private final Set<FileReference> applicationBundles = new LinkedHashSet<>(); private final ConfigProducerGroup<Servlet> servletGroup; - private final ConfigProducerGroup<RestApi> restApiGroup; private final Set<String> previousHosts; private ContainerModelEvaluation modelEvaluation; @@ -95,7 +92,6 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat public ApplicationContainerCluster(AbstractConfigProducer<?> parent, String configSubId, String clusterId, DeployState deployState) { super(parent, configSubId, clusterId, deployState, true); this.tlsClientAuthority = deployState.tlsClientAuthority(); - restApiGroup = new ConfigProducerGroup<>(this, "rest-api"); servletGroup = new ConfigProducerGroup<>(this, "servlet"); previousHosts = deployState.getPreviousModel().stream() .map(Model::allocatedHosts) @@ -121,8 +117,6 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat if (modelEvaluation != null) modelEvaluation.prepare(containers); sendUserConfiguredFiles(deployState); - for (RestApi restApi : restApiGroup.getComponents()) - restApi.prepare(); } private void addAndSendApplicationBundles(DeployState deployState) { @@ -166,15 +160,6 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat this.modelEvaluation = modelEvaluation; } - public final void addRestApi(RestApi restApi) { - restApiGroup.addComponent(ComponentId.fromString(restApi.getBindingPath()), restApi); - } - - public Map<ComponentId, RestApi> getRestApiMap() { - return restApiGroup.getComponentMap(); - } - - public Map<ComponentId, Servlet> getServletMap() { return servletGroup.getComponentMap(); } @@ -183,18 +168,12 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat servletGroup.addComponent(servlet.getGlobalComponentId(), servlet); } - // Returns all servlets, including rest-api/jersey servlets. public Collection<Servlet> getAllServlets() { return allServlets().collect(Collectors.toCollection(ArrayList::new)); } private Stream<Servlet> allServlets() { - return Stream.concat(allJersey2Servlets(), - servletGroup.getComponents().stream()); - } - - private Stream<Jersey2Servlet> allJersey2Servlets() { - return restApiGroup.getComponents().stream().map(RestApi::getJersey2Servlet); + return servletGroup.getComponents().stream(); } public void setMemoryPercentage(Integer memoryPercentage) { this.memoryPercentage = memoryPercentage; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/Jersey2Servlet.java b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/Jersey2Servlet.java deleted file mode 100644 index 06775d59654..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/Jersey2Servlet.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.container.jersey; - -import com.yahoo.component.ComponentId; -import com.yahoo.component.ComponentSpecification; -import com.yahoo.component.VersionSpecification; -import com.yahoo.container.bundle.BundleInstantiationSpecification; -import com.yahoo.osgi.provider.model.ComponentModel; -import com.yahoo.vespa.model.container.component.Servlet; - -/** - * @author Tony Vaagenes - */ -public class Jersey2Servlet extends Servlet { - - public static final String BUNDLE = "container-jersey2"; - public static final String CLASS = "com.yahoo.container.servlet.jersey.JerseyServletProvider"; - public static final String BINDING_SUFFIX = "/*"; - - private static final ComponentId REST_API_NAMESPACE = ComponentId.fromString("rest-api"); - - public Jersey2Servlet(String bindingPath) { - super(new ComponentModel( - new BundleInstantiationSpecification(idSpecFromPath(bindingPath), - ComponentSpecification.fromString(CLASS), - ComponentSpecification.fromString(BUNDLE))), - bindingPath + BINDING_SUFFIX); - } - - private static ComponentSpecification idSpecFromPath(String path) { - return new ComponentSpecification(RestApi.idFromPath(path), - VersionSpecification.emptyVersionSpecification, - REST_API_NAMESPACE); - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApi.java b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApi.java deleted file mode 100644 index be8209bcc4e..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApi.java +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.container.jersey; - -import com.yahoo.config.model.producer.AbstractConfigProducer; - -/** - * Represents a rest-api - * - * @author gjoranv - */ -public class RestApi extends AbstractConfigProducer<AbstractConfigProducer<?>> { - - private final String bindingPath; - private final Jersey2Servlet jerseyServlet; - private RestApiContext restApiContext; - - public RestApi(String bindingPath) { - super(idFromPath(bindingPath)); - this.bindingPath = bindingPath; - - jerseyServlet = createJersey2Servlet(this.bindingPath); - addChild(jerseyServlet); - } - - public static String idFromPath(String path) { - return path.replaceAll("/", "|"); - } - - private Jersey2Servlet createJersey2Servlet(String bindingPath) { - return new Jersey2Servlet(bindingPath); - } - - public String getBindingPath() { - return bindingPath; - } - - public void setRestApiContext(RestApiContext restApiContext) { - this.restApiContext = restApiContext; - addChild(restApiContext); - jerseyServlet.inject(restApiContext); - } - - public RestApiContext getContext() { return restApiContext; } - - public Jersey2Servlet getJersey2Servlet() { - return jerseyServlet; - } - - public void prepare() { - restApiContext.prepare(); - } -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApiContext.java b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApiContext.java deleted file mode 100644 index 390539b643a..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApiContext.java +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.container.jersey; - -import com.yahoo.config.model.producer.AbstractConfigProducer; -import com.yahoo.container.bundle.BundleInstantiationSpecification; -import com.yahoo.container.di.config.JerseyBundlesConfig; -import com.yahoo.container.di.config.JerseyInjectionConfig; -import com.yahoo.container.di.config.JerseyInjectionConfig.Inject; -import com.yahoo.osgi.provider.model.ComponentModel; -import com.yahoo.vespa.model.container.ApplicationContainerCluster; -import com.yahoo.vespa.model.container.component.Component; -import com.yahoo.vespa.model.container.component.SimpleComponent; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Predicate; -import java.util.logging.Logger; - -/** - * @author gjoranv - */ -public class RestApiContext extends SimpleComponent implements - JerseyBundlesConfig.Producer, - JerseyInjectionConfig.Producer -{ - private static final Logger log = Logger.getLogger(RestApi.class.getName()); - public static final String CONTAINER_CLASS = "com.yahoo.container.di.config.RestApiContext"; - - private final List<BundleInfo> bundles = new ArrayList<>(); - - // class name -> componentId - private final Map<String, String> injectComponentForClass = new LinkedHashMap<>(); - - private final String bindingPath; - - private ApplicationContainerCluster containerCluster; - - public RestApiContext(AbstractConfigProducer<?> ancestor, String bindingPath) { - super(componentModel(bindingPath)); - this.bindingPath = bindingPath; - - if (ancestor instanceof ApplicationContainerCluster) - containerCluster = (ApplicationContainerCluster)ancestor; - - } - - private static ComponentModel componentModel(String bindingPath) { - return new ComponentModel(BundleInstantiationSpecification.getFromStrings( - CONTAINER_CLASS + "-" + RestApi.idFromPath(bindingPath), - CONTAINER_CLASS, - null)); - } - - @Override - public void getConfig(JerseyBundlesConfig.Builder builder) { - builder.bundles(createBundlesConfig(bundles)); - } - - private List<JerseyBundlesConfig.Bundles.Builder> createBundlesConfig(List<BundleInfo> bundles) { - List<JerseyBundlesConfig.Bundles.Builder> builders = new ArrayList<>(); - for (BundleInfo b : bundles) { - builders.add( - new JerseyBundlesConfig.Bundles.Builder() - .spec(b.spec) - .packages(b.getPackagesToScan()) - ); - } - return builders; - } - - public void addBundles(Collection<BundleInfo> newBundles) { - bundles.addAll(newBundles); - } - - @Override - public void getConfig(JerseyInjectionConfig.Builder builder) { - for (Map.Entry<String, String> i : injectComponentForClass.entrySet()) { - builder.inject(new Inject.Builder() - .forClass(i.getKey()) - .instance(i.getValue())); - } - } - - @Override - public void validate() throws Exception { - super.validate(); - - if (bundles.isEmpty()) - log.warning("No bundles in rest-api '" + bindingPath + - "' - components will only be loaded from classpath."); - } - - public void prepare() { - if (containerCluster == null) return; - - containerCluster.getAllComponents().stream(). - filter(isCycleGeneratingComponent.negate()). - forEach(this::inject); - } - - - /* - * Example problem - * - * RestApiContext -> ApplicationStatusHandler -> ComponentRegistry<HttpServer> -> JettyHttpServer -> ComponentRegistry<Jersey2Servlet> -> RestApiContext - */ - private Predicate<Component> isCycleGeneratingComponent = component -> { - switch (component.getClassId().getName()) { - case CONTAINER_CLASS: - case Jersey2Servlet.CLASS: - case "com.yahoo.jdisc.http.server.jetty.JettyHttpServer": - case "com.yahoo.container.handler.observability.ApplicationStatusHandler": - return true; - default: - return false; - } - }; - - public static class BundleInfo { - // SymbolicName[:Version] - public final String spec; - - private final List<String> packagesToScan = new ArrayList<>(); - - public BundleInfo(String spec) { - this.spec = spec; - } - - public List<String> getPackagesToScan() { - return packagesToScan; - } - - public void addPackageToScan(String pkg) { - packagesToScan.add(pkg); - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/xml/RestApiBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/xml/RestApiBuilder.java deleted file mode 100644 index 4aa5882119f..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/xml/RestApiBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.container.jersey.xml; - -import com.yahoo.config.model.deploy.DeployState; -import com.yahoo.config.model.producer.AbstractConfigProducer; -import com.yahoo.text.XML; -import com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder; -import com.yahoo.vespa.model.container.jersey.RestApi; -import com.yahoo.vespa.model.container.jersey.RestApiContext; -import org.w3c.dom.Element; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * @author gjoranv - * @since 5.6 - */ -public class RestApiBuilder extends VespaDomBuilder.DomConfigProducerBuilder<RestApi> { - - @Override - protected RestApi doBuild(DeployState deployState, AbstractConfigProducer ancestor, Element spec) { - String bindingPath = spec.getAttribute("path"); - RestApi restApi = new RestApi(bindingPath); - - restApi.setRestApiContext(createRestApiContext(ancestor, spec, bindingPath)); - return restApi; - } - - private RestApiContext createRestApiContext(AbstractConfigProducer ancestor, Element spec, String bindingPath) { - RestApiContext restApiContext = new RestApiContext(ancestor, bindingPath); - - restApiContext.addBundles(getBundles(spec)); - - return restApiContext; - } - - private List<RestApiContext.BundleInfo> getBundles(Element spec) { - List<RestApiContext.BundleInfo> bundles = new ArrayList<>(); - for (Element bundleElement : XML.getChildren(spec, "components")) { - bundles.add(getBundle(bundleElement)); - } - return bundles; - } - - private RestApiContext.BundleInfo getBundle(Element bundleElement) { - RestApiContext.BundleInfo bundle = new RestApiContext.BundleInfo(bundleElement.getAttribute("bundle")); - - for (Element packageElement : XML.getChildren(bundleElement, "package")) - bundle.addPackageToScan(XML.getValue(packageElement)); - - return bundle; - } - - // TODO: use for naming injected components instead - private Map<String, String> getInjections(Element spec) { - Map<String, String> injectForClass = new LinkedHashMap<>(); - for (Element injectElement : XML.getChildren(spec, "inject")) { - injectForClass.put(injectElement.getAttribute("for-class"), - injectElement.getAttribute("component")); - } - return injectForClass; - } - -} 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 5bf8aa5228e..4b45979c698 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 @@ -184,7 +184,6 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { addConfiguredComponents(deployState, cluster, spec); addSecretStore(cluster, spec, deployState); - throwUponRestApi(spec); // TODO: remove addServlets(deployState, spec, cluster); addModelEvaluation(spec, cluster, context); addModelEvaluationBundles(cluster); @@ -517,12 +516,6 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { return http; } - private void throwUponRestApi(Element spec) { - if(! XML.getChildren(spec, "rest-api").isEmpty()) { - throw new IllegalArgumentException("The 'rest-api' element is no longer allowed in services.xml."); - } - } - private void addServlets(DeployState deployState, Element spec, ApplicationContainerCluster cluster) { for (Element servletElem : XML.getChildren(spec, "servlet")) cluster.addServlet(new ServletBuilder().build(deployState, cluster, servletElem)); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/SearchDefinitionBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/SearchDefinitionBuilder.java index 2e316bfd2c1..b86a4b6fbff 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/SearchDefinitionBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/SearchDefinitionBuilder.java @@ -12,6 +12,7 @@ import java.util.TreeMap; * @author Thomas Gundersen */ public class SearchDefinitionBuilder { + public Map<String, NewDocumentType> build(DocumentTypeRepo repo, ModelElement elem) { Map<String, NewDocumentType> docTypes = new TreeMap<>(); diff --git a/config-model/src/main/resources/schema/containercluster.rnc b/config-model/src/main/resources/schema/containercluster.rnc index 3679e53e257..992689a2189 100644 --- a/config-model/src/main/resources/schema/containercluster.rnc +++ b/config-model/src/main/resources/schema/containercluster.rnc @@ -12,7 +12,6 @@ ContainerCluster = element container | jdisc { } ContainerServices = - RestApi* & Servlet* & SearchInContainer? & DocprocInContainer? & @@ -128,22 +127,6 @@ Threadpool = element threadpool { element queue-size { xsd:nonNegativeInteger } } -# REST-API: - -RestApi = element rest-api { - attribute path { xsd:string { pattern = "\w[\w_/\-\.]*" } } & - attribute jersey2 { xsd:boolean }? & - element components { - attribute bundle { xsd:Name } & - element package { xsd:NCName }* - }* - -# element inject { -# attribute component { xsd:Name } & -# attribute for-name { xsd:Name } -# }* -} - # Servlet: Servlet = element servlet { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoolAttributeValidatorTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoolAttributeValidatorTestCase.java new file mode 100644 index 00000000000..663aace7b79 --- /dev/null +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoolAttributeValidatorTestCase.java @@ -0,0 +1,49 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.searchdefinition.processing; + +import com.yahoo.searchdefinition.parser.ParseException; +import org.junit.Test; + +import static com.yahoo.searchdefinition.SearchBuilder.createFromString; +import static com.yahoo.config.model.test.TestUtil.joinLines; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +/** + * @author geirst + */ +public class BoolAttributeValidatorTestCase { + + @Test + public void array_of_bool_attribute_is_not_supported() throws ParseException { + try { + createFromString(getSd("field b type array<bool> { indexing: attribute }")); + fail("Expected exception"); + } + catch (IllegalArgumentException e) { + assertEquals("For search 'test', field 'b': Only single value bool attribute fields are supported", + e.getMessage()); + } + } + + @Test + public void weigtedset_of_bool_attribute_is_not_supported() throws ParseException { + try { + createFromString(getSd("field b type weightedset<bool> { indexing: attribute }")); + fail("Expected exception"); + } + catch (IllegalArgumentException e) { + assertEquals("For search 'test', field 'b': Only single value bool attribute fields are supported", + e.getMessage()); + } + } + + private String getSd(String field) { + return joinLines("search test {", + " document test {", + " " + field, + " }", + "}"); + } + +} diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/jersey/xml/RestApiTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/jersey/xml/RestApiTest.java deleted file mode 100644 index c858024f749..00000000000 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/jersey/xml/RestApiTest.java +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.container.jersey.xml; - -import com.yahoo.component.ComponentId; -import com.yahoo.config.model.test.TestUtil; -import com.yahoo.container.ComponentsConfig; -import com.yahoo.container.di.config.JerseyBundlesConfig; -import com.yahoo.jdisc.http.ServletPathsConfig; -import com.yahoo.vespa.model.container.component.Component; -import com.yahoo.vespa.model.container.jersey.Jersey2Servlet; -import com.yahoo.vespa.model.container.jersey.RestApi; -import com.yahoo.vespa.model.container.jersey.RestApiContext; -import com.yahoo.vespa.model.container.xml.ContainerModelBuilderTestBase; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.w3c.dom.Element; - -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsInAnyOrder; - -/** - * @author gjoranv - * @author bjorncs - */ -@Ignore // TODO: remove test -public class RestApiTest extends ContainerModelBuilderTestBase { - private static final String PATH = "rest/api"; - private static final String REST_API_CONTEXT_ID = RestApiContext.CONTAINER_CLASS + "-" + RestApi.idFromPath(PATH); - private static final String INJECTED_COMPONENT_ID = "injectedHandler"; - private static final String CLUSTER_ID = "container"; - - private static final Element restApiXml = TestUtil.parse( - "<container version=\"1.0\" id=\"" + CLUSTER_ID + "\">", - " <rest-api path=\"" + PATH + "\">", - " <components bundle=\"my-jersey-bundle:1.0\">", - " <package>com.yahoo.foo</package>", - " </components>", - " </rest-api>", - " <handler id=\"" + INJECTED_COMPONENT_ID + "\" />", - "</container>"); - - private RestApi restApi; - private Jersey2Servlet servlet; - private RestApiContext context; - - @Before - public void setup() throws Exception { - createModel(root, restApiXml); - root.validate(); - getContainerCluster(CLUSTER_ID).prepare(root.getDeployState()); - restApi = getContainerCluster(CLUSTER_ID).getRestApiMap().values().iterator().next(); - servlet = restApi.getJersey2Servlet(); - context = restApi.getContext(); - } - - @Test - public void jersey2_servlet_has_correct_binding_path() { - assertThat(servlet, not(nullValue())); - assertThat(servlet.bindingPath, is(PATH + "/*")); - } - - @Test - public void jersey2_servlet_has_correct_bundle_spec() { - assertThat(servlet.model.bundleInstantiationSpec.bundle.stringValue(), is(Jersey2Servlet.BUNDLE)); - } - - @Test - public void rest_api_path_is_included_in_servlet_config() { - ServletPathsConfig config = root.getConfig(ServletPathsConfig.class, servlet.getConfigId()); - assertThat(config.servlets(servlet.getComponentId().stringValue()).path(), is(PATH + "/*")); - } - - @Test - public void resource_bundles_are_included_in_config() { - JerseyBundlesConfig config = root.getConfig(JerseyBundlesConfig.class, context.getConfigId()); - assertThat(config.bundles().size(), is(1)); - assertThat(config.bundles(0).spec(), is("my-jersey-bundle:1.0")); - } - - @Test - public void packages_to_scan_are_included_in_config() { - JerseyBundlesConfig config = root.getConfig(JerseyBundlesConfig.class, context.getConfigId()); - assertThat(config.bundles(0).packages(), contains("com.yahoo.foo")); - } - - @Test - public void jersey2_servlet_is_included_in_components_config() { - ComponentsConfig config = root.getConfig(ComponentsConfig.class, CLUSTER_ID); - assertThat(config.toString(), containsString(".id \"" + servlet.getComponentId().stringValue() + "\"")); - } - - @Test - public void restApiContext_is_included_in_components_config() { - ComponentsConfig config = root.getConfig(ComponentsConfig.class, CLUSTER_ID); - assertThat(config.toString(), containsString(".id \"" + REST_API_CONTEXT_ID + "\"")); - } - - @Test - public void all_non_restApi_components_are_injected_to_RestApiContext() { - ComponentsConfig componentsConfig = root.getConfig(ComponentsConfig.class, CLUSTER_ID); - - Set<ComponentId> clusterChildrenComponentIds = getContainerCluster(CLUSTER_ID).getAllComponents().stream() - .map(Component::getComponentId) - .collect(Collectors.toSet()); - - Set<ComponentId> restApiChildrenComponentIds = restApi.getChildren().values().stream() - .map(child -> ((Component<?, ?>) child).getComponentId()) - .collect(Collectors.toSet()); - - //TODO: try replacing with filtering against RestApiContext.isCycleGeneratingComponent - ComponentId cycleInducingComponents = ComponentId.fromString("com.yahoo.container.handler.observability.ApplicationStatusHandler"); - - Set<ComponentId> expectedInjectedConfigIds = new HashSet<>(clusterChildrenComponentIds); - expectedInjectedConfigIds.removeAll(restApiChildrenComponentIds); - expectedInjectedConfigIds.remove(cycleInducingComponents); - - Set<ComponentId> injectedConfigIds = restApiContextConfig(componentsConfig).inject().stream() - .map(inject -> ComponentId.fromString(inject.id())) - .collect(Collectors.toSet()); - - // Verify that the two sets are equal. Split in two asserts to get decent failure messages. - assertThat( - "Not all required components are injected", - injectedConfigIds, - containsInAnyOrder(expectedInjectedConfigIds.toArray())); - assertThat( - "We inject some components that should not be injected", - expectedInjectedConfigIds, - containsInAnyOrder(injectedConfigIds.toArray())); - } - - private static ComponentsConfig.Components restApiContextConfig(ComponentsConfig config) { - return config.components().stream() - .filter(component -> component.classId().equals(RestApiContext.CONTAINER_CLASS)) - .findFirst() - .get(); - } - -} diff --git a/config-model/src/test/schema-test-files/services.xml b/config-model/src/test/schema-test-files/services.xml index 4ad7865c93b..8477f8fcbea 100644 --- a/config-model/src/test/schema-test-files/services.xml +++ b/config-model/src/test/schema-test-files/services.xml @@ -58,18 +58,6 @@ <group name="foo" environment="aws_stage" /> </secret-store> - <rest-api path="jersey1"> - <components bundle="my-bundle" /> - <components bundle="other-bundle"> - <package>com.yahoo.foo</package> - <package>com.yahoo.bar</package> - </components> - - </rest-api> - <rest-api path="jersey/2"> - <components bundle="my-bundle" /> - </rest-api> - <servlet id="my-servlet" class="com.yahoo.MyServlet" bundle="my-bundle"> <path>p/a/t/h</path> </servlet> diff --git a/config-model/src/test/schema-test-files/standalone-container.xml b/config-model/src/test/schema-test-files/standalone-container.xml index b77654521ee..a7769a2f57b 100644 --- a/config-model/src/test/schema-test-files/standalone-container.xml +++ b/config-model/src/test/schema-test-files/standalone-container.xml @@ -1,21 +1,6 @@ <?xml version="1.0" encoding="utf-8" ?> <!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> <container id='qrsCluster_1' version='1.0'> - <rest-api path="jersey1"> - <components bundle="my-bundle" /> - <components bundle="other-bundle" /> -<!-- - <inject component="foo-component" for-name="com.yahoo.Foo" /> - <inject component="bar-component" for-name="com.yahoo.Bar" /> ---> - </rest-api> - <rest-api path="jersey/2"> - <components bundle="my-bundle" /> - <components bundle="other-bundle"> - <package>com.yahoo.foo</package> - <package>com.yahoo.bar</package> - </components> - </rest-api> <servlet id="my-servlet" class="com.yahoo.MyServlet" bundle="my-bundle"> <path>p/a/t/h</path> diff --git a/configdefinitions/src/vespa/zookeeper-server.def b/configdefinitions/src/vespa/zookeeper-server.def index 006e266916c..b08fc8eeafe 100644 --- a/configdefinitions/src/vespa/zookeeper-server.def +++ b/configdefinitions/src/vespa/zookeeper-server.def @@ -6,8 +6,8 @@ zooKeeperConfigFile string default="conf/zookeeper/zookeeper.cfg" # For more info about the values below, see ZooKeeper documentation -# tick time in milliseconds -tickTime int default=2000 +# tick time in milliseconds, min and max session timeout are 2 and 20 times this value +tickTime int default=6000 initLimit int default=20 syncLimit int default=15 maxClientConnections int default=0 diff --git a/configserver/pom.xml b/configserver/pom.xml index a237d7e00ad..ac98cfa5d5d 100644 --- a/configserver/pom.xml +++ b/configserver/pom.xml @@ -168,12 +168,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>container-jersey2</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <scope>provided</scope> diff --git a/container-dev/pom.xml b/container-dev/pom.xml index cfe9c0a6d8e..6366022c342 100644 --- a/container-dev/pom.xml +++ b/container-dev/pom.xml @@ -96,11 +96,6 @@ </dependency> <dependency> <groupId>com.yahoo.vespa</groupId> - <artifactId>container-jersey2</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> <artifactId>vespa_jersey2</artifactId> <version>${project.version}</version> <type>pom</type> diff --git a/container-jersey2/.gitignore b/container-jersey2/.gitignore deleted file mode 100644 index ea8c4bf7f35..00000000000 --- a/container-jersey2/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/container-jersey2/CMakeLists.txt b/container-jersey2/CMakeLists.txt deleted file mode 100644 index d2490563372..00000000000 --- a/container-jersey2/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -install_fat_java_artifact(container-jersey2) diff --git a/container-jersey2/OWNERS b/container-jersey2/OWNERS deleted file mode 100644 index 3b2ba1ede81..00000000000 --- a/container-jersey2/OWNERS +++ /dev/null @@ -1 +0,0 @@ -gjoranv diff --git a/container-jersey2/README.md b/container-jersey2/README.md deleted file mode 100644 index 43f83ddccbe..00000000000 --- a/container-jersey2/README.md +++ /dev/null @@ -1,4 +0,0 @@ -<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -# JDisc Jersey integration - -The integration layer between JDisc and Jersey2. diff --git a/container-jersey2/abi-spec.json b/container-jersey2/abi-spec.json deleted file mode 100644 index 2f5ef3efb70..00000000000 --- a/container-jersey2/abi-spec.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "com.yahoo.container.jaxrs.annotation.Component": { - "superClass": "java.lang.Object", - "interfaces": [ - "java.lang.annotation.Annotation" - ], - "attributes": [ - "public", - "interface", - "abstract", - "annotation" - ], - "methods": [], - "fields": [] - } -}
\ No newline at end of file diff --git a/container-jersey2/pom.xml b/container-jersey2/pom.xml deleted file mode 100644 index 8f24b5edcb7..00000000000 --- a/container-jersey2/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ -<?xml version="1.0"?> -<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 - http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.yahoo.vespa</groupId> - <artifactId>parent</artifactId> - <version>7-SNAPSHOT</version> - <relativePath>../parent/pom.xml</relativePath> - </parent> - <artifactId>container-jersey2</artifactId> - <version>7-SNAPSHOT</version> - <packaging>container-plugin</packaging> - <dependencies> - - <!-- COMPILE scope --> - <dependency> - <groupId>org.ow2.asm</groupId> - <artifactId>asm</artifactId> - </dependency> - - - <!-- PROVIDED scope --> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>annotations</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>component</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>container-core</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>jdisc_core</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>vespa_jersey2</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - <type>pom</type> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-servlet</artifactId> - <scope>provided</scope> - </dependency> - - <!-- TEST scope --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>com.yahoo.vespa</groupId> - <artifactId>bundle-plugin</artifactId> - <extensions>true</extensions> - </plugin> - <plugin> - <groupId>com.yahoo.vespa</groupId> - <artifactId>abi-check-plugin</artifactId> - </plugin> - <plugin> - <!-- Explicit for IntelliJ to detect correct language level from parent --> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - </plugin> - </plugins> - </build> -</project> diff --git a/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/Component.java b/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/Component.java deleted file mode 100644 index da8f35eaa00..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/Component.java +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.jaxrs.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation for injecting jdisc container components into jaxrs resources and providers - * @author Tony Vaagenes - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.PARAMETER) -public @interface Component {} - - diff --git a/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/package-info.java b/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/package-info.java deleted file mode 100644 index 8628d52bbb8..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -/** - * @author Tony Vaagenes - */ -@PublicApi -@ExportPackage -package com.yahoo.container.jaxrs.annotation; - -import com.yahoo.api.annotations.PublicApi; -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ComponentGraphProvider.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ComponentGraphProvider.java deleted file mode 100644 index 7ff9646cb27..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ComponentGraphProvider.java +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey; - -import com.yahoo.container.di.config.ResolveDependencyException; -import com.yahoo.container.di.config.RestApiContext; -import com.yahoo.container.jaxrs.annotation.Component; -import org.glassfish.hk2.api.Injectee; -import org.glassfish.hk2.api.InjectionResolver; -import org.glassfish.hk2.api.ServiceHandle; - -import javax.inject.Singleton; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Resolves jdisc container components for jersey 2 components. - * - * @author Tony Vaagenes - * @author ollivir - */ -@Singleton // jersey2 requirement: InjectionResolvers must be in the Singleton scope -public class ComponentGraphProvider implements InjectionResolver<Component> { - private Collection<RestApiContext.Injectable> injectables; - - public ComponentGraphProvider(Collection<RestApiContext.Injectable> injectables) { - this.injectables = injectables; - } - - @Override - public Object resolve(Injectee injectee, ServiceHandle<?> root) { - Class<?> wantedClass; - Type type = injectee.getRequiredType(); - if (type instanceof Class) { - wantedClass = (Class<?>) type; - } else { - throw new UnsupportedOperationException("Only classes are supported, got " + type); - } - - List<RestApiContext.Injectable> componentsWithMatchingType = new ArrayList<>(); - for (RestApiContext.Injectable injectable : injectables) { - if (wantedClass.isInstance(injectable.instance)) { - componentsWithMatchingType.add(injectable); - } - } - - if (componentsWithMatchingType.size() == 1) { - return componentsWithMatchingType.get(0).instance; - } else { - String injectionDescription = "class '" + wantedClass + "' to inject into Jersey resource/provider '" - + injectee.getInjecteeClass() + "')"; - if (componentsWithMatchingType.size() > 1) { - String ids = componentsWithMatchingType.stream().map(c -> c.id.toString()).collect(Collectors.joining(",")); - throw new ResolveDependencyException("Multiple components found of " + injectionDescription + ": " + ids); - } else { - throw new ResolveDependencyException("Could not find a component of " + injectionDescription + "."); - } - } - } - - @Override - public boolean isMethodParameterIndicator() { - return true; - } - - @Override - public boolean isConstructorParameterIndicator() { - return true; - } -} diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyApplication.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyApplication.java deleted file mode 100644 index 4c4e43bc8d5..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyApplication.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey; - -import javax.ws.rs.core.Application; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -public class JerseyApplication extends Application { - private Set<Class<?>> classes; - - public JerseyApplication(Collection<Class<?>> resourcesAndProviderClasses) { - this.classes = new HashSet<>(resourcesAndProviderClasses); - } - - @Override - public Set<Class<?>> getClasses() { - return classes; - } -} diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyServletProvider.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyServletProvider.java deleted file mode 100644 index b8c714fd3e3..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyServletProvider.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; -import com.yahoo.container.di.componentgraph.Provider; -import com.yahoo.container.di.config.RestApiContext; -import com.yahoo.container.di.config.RestApiContext.BundleInfo; -import com.yahoo.container.jaxrs.annotation.Component; -import org.eclipse.jetty.servlet.ServletHolder; -import org.glassfish.hk2.api.InjectionResolver; -import org.glassfish.hk2.api.TypeLiteral; -import org.glassfish.hk2.utilities.Binder; -import org.glassfish.hk2.utilities.binding.AbstractBinder; -import org.glassfish.jersey.media.multipart.MultiPartFeature; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.servlet.ServletContainer; -import org.objectweb.asm.ClassReader; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Optional; - -import static com.yahoo.container.servlet.jersey.util.ResourceConfigUtil.registerComponent; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -@SuppressWarnings("unused") // Injected -public class JerseyServletProvider implements Provider<ServletHolder> { - - private final ServletHolder jerseyServletHolder; - - public JerseyServletProvider(RestApiContext restApiContext) { - this.jerseyServletHolder = new ServletHolder(new ServletContainer(resourceConfig(restApiContext))); - } - - private ResourceConfig resourceConfig(RestApiContext restApiContext) { - ResourceConfig resourceConfig = ResourceConfig - .forApplication(new JerseyApplication(resourcesAndProviders(restApiContext.getBundles()))); - - registerComponent(resourceConfig, componentInjectorBinder(restApiContext)); - registerComponent(resourceConfig, jacksonDatatypeJdk8Provider()); - resourceConfig.register(MultiPartFeature.class); - - return resourceConfig; - } - - private static Collection<Class<?>> resourcesAndProviders(Collection<BundleInfo> bundles) { - List<Class<?>> ret = new ArrayList<>(); - - for (BundleInfo bundle : bundles) { - for (String classEntry : bundle.getClassEntries()) { - Optional<String> className = detectResourceOrProvider(bundle.classLoader, classEntry); - className.ifPresent(cname -> ret.add(loadClass(bundle.symbolicName, bundle.classLoader, cname))); - } - } - return ret; - } - - private static Optional<String> detectResourceOrProvider(ClassLoader bundleClassLoader, String classEntry) { - try (InputStream inputStream = getResourceAsStream(bundleClassLoader, classEntry)) { - ResourceOrProviderClassVisitor visitor = ResourceOrProviderClassVisitor.visit(new ClassReader(inputStream)); - return visitor.getJerseyClassName(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private static InputStream getResourceAsStream(ClassLoader bundleClassLoader, String classEntry) { - InputStream is = bundleClassLoader.getResourceAsStream(classEntry); - if (is == null) { - throw new RuntimeException("No entry " + classEntry + " in bundle " + bundleClassLoader); - } else { - return is; - } - } - - private static Class<?> loadClass(String bundleSymbolicName, ClassLoader classLoader, String className) { - try { - return classLoader.loadClass(className); - } catch (Exception e) { - throw new RuntimeException("Failed loading class " + className + " from bundle " + bundleSymbolicName, e); - } - } - - private static Binder componentInjectorBinder(RestApiContext restApiContext) { - final ComponentGraphProvider componentGraphProvider = new ComponentGraphProvider(restApiContext.getInjectableComponents()); - final TypeLiteral<InjectionResolver<Component>> componentAnnotationType = new TypeLiteral<InjectionResolver<Component>>() { - }; - - return new AbstractBinder() { - @Override - public void configure() { - bind(componentGraphProvider).to(componentAnnotationType); - } - }; - } - - private static JacksonJaxbJsonProvider jacksonDatatypeJdk8Provider() { - JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); - provider.setMapper(new ObjectMapper().registerModule(new Jdk8Module()).registerModule(new JavaTimeModule())); - return provider; - } - - @Override - public ServletHolder get() { - return jerseyServletHolder; - } - - @Override - public void deconstruct() { - } - -} diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ResourceOrProviderClassVisitor.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ResourceOrProviderClassVisitor.java deleted file mode 100644 index bf53cec670e..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ResourceOrProviderClassVisitor.java +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey; - -import org.objectweb.asm.AnnotationVisitor; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; - -import javax.ws.rs.Path; -import javax.ws.rs.ext.Provider; - -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -public class ResourceOrProviderClassVisitor extends ClassVisitor { - private String className = null; - private boolean isPublic = false; - private boolean isAbstract = false; - - private boolean isInnerClass = false; - private boolean isStatic = false; - - private boolean isAnnotated = false; - - public ResourceOrProviderClassVisitor() { - super(Opcodes.ASM7); - } - - public Optional<String> getJerseyClassName() { - if (isJerseyClass()) { - return Optional.of(getClassName()); - } else { - return Optional.empty(); - } - } - - public boolean isJerseyClass() { - return isAnnotated && isPublic && !isAbstract && (!isInnerClass || isStatic); - } - - public String getClassName() { - assert (className != null); - return org.objectweb.asm.Type.getObjectType(className).getClassName(); - } - - @Override - public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { - isPublic = isPublic(access); - className = name; - isAbstract = isAbstract(access); - } - - @Override - public void visitInnerClass(String name, String outerName, String innerName, int access) { - assert (className != null); - - if (name.equals(className)) { - isInnerClass = true; - isStatic = isStatic(access); - } - } - - @Override - public AnnotationVisitor visitAnnotation(String desc, boolean visible) { - isAnnotated |= annotationClassDescriptors.contains(desc); - return null; - } - - private static Set<String> annotationClassDescriptors = new HashSet<>(); - - static { - annotationClassDescriptors.add(Type.getDescriptor(Path.class)); - annotationClassDescriptors.add(Type.getDescriptor(Provider.class)); - } - - private static boolean isPublic(int access) { - return isSet(Opcodes.ACC_PUBLIC, access); - } - - private static boolean isStatic(int access) { - return isSet(Opcodes.ACC_STATIC, access); - } - - private static boolean isAbstract(int access) { - return isSet(Opcodes.ACC_ABSTRACT, access); - } - - private static boolean isSet(int bits, int access) { - return (access & bits) == bits; - } - - public static ResourceOrProviderClassVisitor visit(ClassReader classReader) { - ResourceOrProviderClassVisitor visitor = new ResourceOrProviderClassVisitor(); - classReader.accept(visitor, ClassReader.SKIP_DEBUG | ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES); - return visitor; - } -} diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/util/ResourceConfigUtil.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/util/ResourceConfigUtil.java deleted file mode 100644 index fdfcf6565cd..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/util/ResourceConfigUtil.java +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.util; - -import org.glassfish.jersey.server.ResourceConfig; - -/** - * @author Tony Vaagenes - */ -public class ResourceConfigUtil { - /** - * Solves ambiguous reference to overloaded definition, see - * http://stackoverflow.com/questions/3313929/how-do-i-disambiguate-in-scala-between-methods-with-vararg-and-without - */ - public static void registerComponent(ResourceConfig config, Object component) { - config.register(component); - } -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/AbstractResource.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/AbstractResource.java deleted file mode 100644 index dfa3354032a..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/AbstractResource.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("ignored") -public abstract class AbstractResource { - -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/DummyAnnotation.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/DummyAnnotation.java deleted file mode 100644 index ca6e20aba4d..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/DummyAnnotation.java +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * @author Tony Vaagenes - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface DummyAnnotation {} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InnerClass.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InnerClass.java deleted file mode 100644 index 048ac4cdd9b..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InnerClass.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -public class InnerClass { - @Path("ignored") - public class Inner {} -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InterfaceResource.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InterfaceResource.java deleted file mode 100644 index d013028db19..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InterfaceResource.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("ignored") -public interface InterfaceResource { - -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NestedClass.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NestedClass.java deleted file mode 100644 index 11ff6364074..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NestedClass.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -public class NestedClass { - @Path("ignored") - public static class Nested {} -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NonPublicNestedClass.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NonPublicNestedClass.java deleted file mode 100644 index 8e4499fe6dc..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NonPublicNestedClass.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -public class NonPublicNestedClass { - @Path("ignored") - static class Nested {} -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Provider.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Provider.java deleted file mode 100644 index c2c605db22c..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Provider.java +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -/** - * @author Tony Vaagenes - */ -@javax.ws.rs.ext.Provider -public class Provider { -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Resource.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Resource.java deleted file mode 100644 index edfa2449fc3..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Resource.java +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("ignored") -public class Resource { -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java deleted file mode 100644 index 1f5ccf4bb10..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import com.yahoo.container.servlet.jersey.ResourceOrProviderClassVisitor; -import org.junit.Test; -import org.objectweb.asm.ClassReader; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class ResourceOrProviderClassVisitorTest { - @Test - public void resource_is_detected() throws Exception { - assert_is_accepted(com.yahoo.container.servlet.jersey.classvisitor.Resource.class); - } - - @Test - public void provider_is_detected() throws Exception { - assert_is_accepted(com.yahoo.container.servlet.jersey.classvisitor.Provider.class); - } - - @Test - public void inner_class_is_ignored() throws Exception { - assert_is_ignored(com.yahoo.container.servlet.jersey.classvisitor.InnerClass.Inner.class); - } - - @Test - public void nested_public_class_is_detected() throws Exception { - assert_is_accepted(com.yahoo.container.servlet.jersey.classvisitor.NestedClass.Nested.class); - } - - @Test - public void nested_non_public_class_is_ignored() throws Exception { - assert_is_ignored(com.yahoo.container.servlet.jersey.classvisitor.NonPublicNestedClass.Nested.class); - } - - @Test - public void resource_with_multiple_annotations_is_detected() throws Exception { - assert_is_accepted(com.yahoo.container.servlet.jersey.classvisitor.ResourceWithMultipleAnnotations.class); - } - - @Test - public void interface_is_ignored() throws Exception { - assert_is_ignored(com.yahoo.container.servlet.jersey.classvisitor.InterfaceResource.class); - } - - @Test - public void abstract_class_is_ignored() throws Exception { - assert_is_ignored(com.yahoo.container.servlet.jersey.classvisitor.AbstractResource.class); - } - - @Test - public void className_is_equal_to_getName() throws Exception { - assertEquals(com.yahoo.container.servlet.jersey.classvisitor.Resource.class.getName(), analyzeClass(com.yahoo.container.servlet.jersey.classvisitor.Resource.class).getClassName()); - } - - public void assert_is_accepted(Class<?> clazz) throws Exception { - assertTrue(className(clazz) + " was not accepted", - analyzeClass(clazz).isJerseyClass()); - } - - public void assert_is_ignored(Class<?> clazz) throws Exception { - assertFalse(className(clazz) + " was not ignored", - analyzeClass(clazz).isJerseyClass()); - } - - public ResourceOrProviderClassVisitor analyzeClass(Class<?> clazz) throws Exception { - return ResourceOrProviderClassVisitor.visit(new ClassReader(className(clazz))); - } - - public String className(Class<?> clazz) { - return clazz.getName(); - } -} - - diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceWithMultipleAnnotations.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceWithMultipleAnnotations.java deleted file mode 100644 index 7047422736e..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceWithMultipleAnnotations.java +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("ignored") -@DummyAnnotation -public class ResourceWithMultipleAnnotations { - -} diff --git a/container-search/src/main/java/com/yahoo/search/handler/HttpSearchResponse.java b/container-search/src/main/java/com/yahoo/search/handler/HttpSearchResponse.java index 7ef9ebad010..aebc6e17904 100644 --- a/container-search/src/main/java/com/yahoo/search/handler/HttpSearchResponse.java +++ b/container-search/src/main/java/com/yahoo/search/handler/HttpSearchResponse.java @@ -180,9 +180,7 @@ public class HttpSearchResponse extends ExtendedResponse { @Override public Iterable<LogValue> getLogValues() { QueryContext context = query.getContext(false); - return context == null - ? Collections::emptyIterator - : context::logValueIterator; + return context == null ? Collections::emptyIterator : context::logValueIterator; } private class RendererLatencyReporter implements Runnable { 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 f81aab4259d..f7ff7e72745 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 @@ -494,8 +494,8 @@ public class SearchHandler extends LoggingRequestHandler { if (maxThreads > 3) { // cast to long to avoid overflows if maxThreads is at no // log value (maxint) - final long maxThreadsAsLong = maxThreads; - final long connectionsAsLong = connections; + long maxThreadsAsLong = maxThreads; + long connectionsAsLong = connections; // only log when exactly crossing the limit to avoid // spamming the log if (connectionsAsLong < maxThreadsAsLong * 9L / 10L) { @@ -519,7 +519,7 @@ public class SearchHandler extends LoggingRequestHandler { // Attempted workaround for missing stack traces if (e.getStackTrace().length == 0) { log.log(Level.SEVERE, "Failed executing " + query.toDetailString() + - " [" + request + "], received exception with no context", e); + " [" + request + "], received exception with no context", e); } else { log.log(Level.SEVERE, "Failed executing " + query.toDetailString() + " [" + request + "]", e); } @@ -654,6 +654,7 @@ public class SearchHandler extends LoggingRequestHandler { .override(com.yahoo.jdisc.http.HttpRequest.Method.POST, AclMapping.Action.READ) .build(); } + } diff --git a/container-search/src/main/java/com/yahoo/search/query/context/QueryContext.java b/container-search/src/main/java/com/yahoo/search/query/context/QueryContext.java index 1ba30275dc1..4fb9e1e9afa 100644 --- a/container-search/src/main/java/com/yahoo/search/query/context/QueryContext.java +++ b/container-search/src/main/java/com/yahoo/search/query/context/QueryContext.java @@ -38,10 +38,10 @@ public class QueryContext implements Cloneable { owner.getModel().getExecution().trace().trace(message,traceLevel); } /** - * Adds a key-value which will be logged to the access log for this query (by doing toString() on the value + * Adds a key-value which will be logged to the access log for this query (by doing toString() on the value). * Multiple values may be set to the same key. A value cannot be removed once set. */ - public void logValue(String key,Object value) { + public void logValue(String key, Object value) { owner.getModel().getExecution().trace().logValue(key, value.toString()); } diff --git a/container-test-jars/OWNERS b/container-test-jars/OWNERS deleted file mode 100644 index 3b2ba1ede81..00000000000 --- a/container-test-jars/OWNERS +++ /dev/null @@ -1 +0,0 @@ -gjoranv diff --git a/container-test-jars/README.md b/container-test-jars/README.md deleted file mode 100644 index f4f4481efc1..00000000000 --- a/container-test-jars/README.md +++ /dev/null @@ -1,4 +0,0 @@ -<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -# Container test bundles - -Used by the 'application' module. diff --git a/container-test-jars/bundle-with-provided-bundle/pom.xml b/container-test-jars/bundle-with-provided-bundle/pom.xml deleted file mode 100644 index d9d97ddd2b0..00000000000 --- a/container-test-jars/bundle-with-provided-bundle/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0"?> -<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 - http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.yahoo.vespa.container-test-jars</groupId> - <artifactId>container-test-jars</artifactId> - <version>7-SNAPSHOT</version> - </parent> - - <artifactId>bundle-with-provided-bundle</artifactId> - <packaging>container-plugin</packaging> - <description> - This will trigger bugs in our bundle plugins that assumes that artifact.getFile is a jar file. - Normally, artifact.getFile points to a jar file, - but in multi-module projects when running phases not including package, - this will be a directory. - </description> - - <dependencies> - <dependency> - <groupId>com.yahoo.vespa.container-test-jars</groupId> - <artifactId>jersey-resources</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>vespa_jersey2</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - <type>pom</type> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>com.yahoo.vespa</groupId> - <artifactId>bundle-plugin</artifactId> - <version>${project.version}</version> - <extensions>true</extensions> - </plugin> - </plugins> - </build> -</project> diff --git a/container-test-jars/jersey-resources/pom.xml b/container-test-jars/jersey-resources/pom.xml deleted file mode 100644 index cb35be91cfd..00000000000 --- a/container-test-jars/jersey-resources/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0"?> -<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 - http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.yahoo.vespa.container-test-jars</groupId> - <artifactId>container-test-jars</artifactId> - <version>7-SNAPSHOT</version> - </parent> - - <artifactId>jersey-resources</artifactId> - <packaging>container-plugin</packaging> - - <dependencies> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>vespa_jersey2</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - <type>pom</type> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <!-- Explicit for IntelliJ to detect correct language level from parent --> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - </plugin> - <plugin> - <groupId>com.yahoo.vespa</groupId> - <artifactId>bundle-plugin</artifactId> - <version>${project.version}</version> - <extensions>true</extensions> - </plugin> - </plugins> - </build> -</project> diff --git a/container-test-jars/jersey-resources/src/main/java/com/yahoo/container/test/jars/jersey/resources/TestResource.java b/container-test-jars/jersey-resources/src/main/java/com/yahoo/container/test/jars/jersey/resources/TestResource.java deleted file mode 100644 index 59095d05567..00000000000 --- a/container-test-jars/jersey-resources/src/main/java/com/yahoo/container/test/jars/jersey/resources/TestResource.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.test.jars.jersey.resources; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -@Path("bundle-plugin-test/test-resource") -public class TestResource extends TestResourceBase { -} diff --git a/container-test-jars/jersey-resources/src/main/java/com/yahoo/container/test/jars/jersey/resources/TestResourceBase.java b/container-test-jars/jersey-resources/src/main/java/com/yahoo/container/test/jars/jersey/resources/TestResourceBase.java deleted file mode 100644 index c3724723252..00000000000 --- a/container-test-jars/jersey-resources/src/main/java/com/yahoo/container/test/jars/jersey/resources/TestResourceBase.java +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.test.jars.jersey.resources; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.Produces; -import javax.ws.rs.GET; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -public class TestResourceBase { - @GET - @Produces({MediaType.TEXT_PLAIN}) - public String get() { - return content(getClass()); - } - - public static String content(Class<? extends TestResourceBase> clazz) { - return "Response from " + clazz.getName(); - } -} diff --git a/container-test-jars/jersey-resources/src/main/java/com/yahoo/container/test/jars/jersey/resources/nestedpackage1/NestedTestResource1.java b/container-test-jars/jersey-resources/src/main/java/com/yahoo/container/test/jars/jersey/resources/nestedpackage1/NestedTestResource1.java deleted file mode 100644 index ab1c1f8f229..00000000000 --- a/container-test-jars/jersey-resources/src/main/java/com/yahoo/container/test/jars/jersey/resources/nestedpackage1/NestedTestResource1.java +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.test.jars.jersey.resources.nestedpackage1; - -import com.yahoo.container.test.jars.jersey.resources.TestResourceBase; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("bundle-plugin-test/nested-test-resource1") -public class NestedTestResource1 extends TestResourceBase { -} diff --git a/container-test-jars/jersey-resources/src/main/java/com/yahoo/container/test/jars/jersey/resources/nestedpackage2/NestedTestResource2.java b/container-test-jars/jersey-resources/src/main/java/com/yahoo/container/test/jars/jersey/resources/nestedpackage2/NestedTestResource2.java deleted file mode 100644 index 0dfc9e1938b..00000000000 --- a/container-test-jars/jersey-resources/src/main/java/com/yahoo/container/test/jars/jersey/resources/nestedpackage2/NestedTestResource2.java +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.test.jars.jersey.resources.nestedpackage2; - -import com.yahoo.container.test.jars.jersey.resources.TestResourceBase; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("bundle-plugin-test/nested-test-resource2") -public class NestedTestResource2 extends TestResourceBase { -} diff --git a/container-test-jars/pom.xml b/container-test-jars/pom.xml deleted file mode 100644 index 7176af3791c..00000000000 --- a/container-test-jars/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0"?> -<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 - http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.yahoo.vespa</groupId> - <artifactId>parent</artifactId> - <version>7-SNAPSHOT</version> - <relativePath>../parent/pom.xml</relativePath> - </parent> - <groupId>com.yahoo.vespa.container-test-jars</groupId> - <artifactId>container-test-jars</artifactId> - <version>7-SNAPSHOT</version> - <packaging>pom</packaging> - <modules> - <module>jersey-resources</module> - <module>bundle-with-provided-bundle</module> - </modules> - - <properties> - <!-- This project only builds test artifacts --> - <maven.deploy.skip>true</maven.deploy.skip> - </properties> - -</project> diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockResourceTagger.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockResourceTagger.java index a74a362330b..0f05fa60db7 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockResourceTagger.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockResourceTagger.java @@ -15,15 +15,15 @@ import java.util.Optional; */ public class MockResourceTagger implements ResourceTagger { - Map<ZoneId, Map<HostName, Optional<ApplicationId>>> values = new HashMap<>(); + Map<ZoneId, Map<HostName, ApplicationId>> values = new HashMap<>(); @Override - public int tagResources(ZoneApi zone, Map<HostName, Optional<ApplicationId>> ownerOfHosts) { + public int tagResources(ZoneApi zone, Map<HostName, ApplicationId> ownerOfHosts) { values.put(zone.getId(), ownerOfHosts); return 0; } - public Map<ZoneId, Map<HostName, Optional<ApplicationId>>> getValues() { + public Map<ZoneId, Map<HostName, ApplicationId>> getValues() { return values; } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/ResourceTagger.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/ResourceTagger.java index 61f8a57ac8b..988949456bb 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/ResourceTagger.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/ResourceTagger.java @@ -16,7 +16,7 @@ public interface ResourceTagger { /** * Returns number of tagged resources */ - int tagResources(ZoneApi zone, Map<HostName, Optional<ApplicationId>> ownerOfHosts); + int tagResources(ZoneApi zone, Map<HostName, ApplicationId> ownerOfHosts); static ResourceTagger empty() { return (zone, tenantOfHosts) -> 0; diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java index 3b6a03a76c9..c49e3c88df3 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java @@ -198,7 +198,7 @@ public class InternalStepRunner implements StepRunner { logger) .filter(result -> { // If no tester cert, or deployment failed, propagate original result. - if (testerCertificate.isEmpty() || result != running) + if ( ! useTesterCertificate(id) || result != running) return true; // If tester cert, ensure real is deployed with the tester cert whose key was successfully deployed. return controller.jobController().run(id).get().stepStatus(deployTester).get() == succeeded @@ -828,16 +828,20 @@ public class InternalStepRunner implements StepRunner { return deployment.at().isBefore(controller.clock().instant().minus(timeout.minus(Duration.ofMinutes(1)))); } + private boolean useTesterCertificate(RunId id) { + return controller.system().isPublic() && id.type().environment().isTest(); + } + /** Returns the application package for the tester application, assembled from a generated config, fat-jar and services.xml. */ private ApplicationPackage testerPackage(RunId id) { ApplicationVersion version = controller.jobController().run(id).get().versions().targetApplication(); DeploymentSpec spec = controller.applications().requireApplication(TenantAndApplicationId.from(id.application())).deploymentSpec(); ZoneId zone = id.type().zone(controller.system()); - boolean useTesterCertificate = controller.system().isPublic() && id.type().environment().isTest(); + boolean useTesterCertificate = useTesterCertificate(id); boolean useOsgiBasedTestRuntime = testerPlatformVersion(id).isAfter(new Version(7, 247, 11)); - byte[] servicesXml = servicesXml(! controller.system().isPublic(), + byte[] servicesXml = servicesXml( ! controller.system().isPublic(), useTesterCertificate, useOsgiBasedTestRuntime, testerResourcesFor(zone, spec.requireInstance(id.application().instance())), diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java index d9d82b41e71..b622fc0bd75 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java @@ -76,9 +76,9 @@ import static java.util.stream.Collectors.toUnmodifiableList; */ public class JobController { - public static final int historyLength = 64; public static final Duration maxHistoryAge = Duration.ofDays(60); + private final int historyLength; private final Controller controller; private final CuratorDb curator; private final BufferedLogStore logs; @@ -88,6 +88,7 @@ public class JobController { private final AtomicReference<Consumer<Run>> runner = new AtomicReference<>(__ -> { }); public JobController(Controller controller) { + this.historyLength = controller.system().isCd() ? 256 : 64; this.controller = controller; this.curator = controller.curator(); this.logs = new BufferedLogStore(curator, controller.serviceRegistry().runDataStore()); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeScheduler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeScheduler.java index c2addbe9a67..d3b05922d26 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeScheduler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeScheduler.java @@ -111,7 +111,7 @@ public class OsUpgradeScheduler extends ControllerMaintainer { /** The cool-down period that must pass before a stable version can be used */ private Duration cooldown() { - return system.isCd() ? Duration.ZERO : Duration.ofDays(14); + return system.isCd() ? Duration.ZERO : Duration.ofDays(7); } } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceTagMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceTagMaintainer.java index ab988bcf0ac..e0441df025b 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceTagMaintainer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceTagMaintainer.java @@ -4,6 +4,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.CloudName; import com.yahoo.config.provision.HostName; +import com.yahoo.config.provision.NodeType; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.aws.ResourceTagger; @@ -20,6 +21,9 @@ import java.util.stream.Collectors; */ public class ResourceTagMaintainer extends ControllerMaintainer { + static final ApplicationId SHARED_HOST_APPLICATION = ApplicationId.from("hosted-vespa", "shared-host", "default"); + static final ApplicationId INFRASTRUCTURE_APPLICATION = ApplicationId.from("hosted-vespa", "infrastructure", "default"); + private final ResourceTagger resourceTagger; public ResourceTagMaintainer(Controller controller, Duration interval, ResourceTagger resourceTagger) { @@ -33,7 +37,7 @@ public class ResourceTagMaintainer extends ControllerMaintainer { .ofCloud(CloudName.from("aws")) .reachable() .zones().forEach(zone -> { - Map<HostName, Optional<ApplicationId>> applicationOfHosts = getTenantOfParentHosts(zone.getId()); + Map<HostName, ApplicationId> applicationOfHosts = getTenantOfParentHosts(zone.getId()); int taggedResources = resourceTagger.tagResources(zone, applicationOfHosts); if (taggedResources > 0) log.log(Level.INFO, "Tagged " + taggedResources + " resources in " + zone.getId()); @@ -41,15 +45,21 @@ public class ResourceTagMaintainer extends ControllerMaintainer { return 1.0; } - private Map<HostName, Optional<ApplicationId>> getTenantOfParentHosts(ZoneId zoneId) { + private Map<HostName, ApplicationId> getTenantOfParentHosts(ZoneId zoneId) { return controller().serviceRegistry().configServer().nodeRepository() .list(zoneId, false) .stream() .filter(node -> node.type().isHost()) .collect(Collectors.toMap( Node::hostname, - Node::exclusiveTo, + this::getApplicationId, (node1, node2) -> node1 )); } + + private ApplicationId getApplicationId(Node node) { + if (node.type() == NodeType.host) + return node.exclusiveTo().orElse(SHARED_HOST_APPLICATION); + return INFRASTRUCTURE_APPLICATION; + } } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeSchedulerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeSchedulerTest.java index d80a8ce1152..770d0a898fe 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeSchedulerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeSchedulerTest.java @@ -116,7 +116,7 @@ public class OsUpgradeSchedulerTest { tester.controller().osVersionTarget(cloud).get().osVersion().version()); // Enough time passes since promotion of stable release - tester.clock().advance(Duration.ofDays(14).plus(Duration.ofSeconds(1))); + tester.clock().advance(Duration.ofDays(7).plus(Duration.ofSeconds(1))); scheduler.maintain(); OsVersionTarget target0 = tester.controller().osVersionTarget(cloud).get(); assertEquals(version1, target0.osVersion().version()); @@ -139,7 +139,7 @@ public class OsUpgradeSchedulerTest { // Enough time passes for stable version to be promoted. Nothing happens as stable is now before the manually // triggered version - tester.clock().advance(Duration.ofDays(14).plus(Duration.ofSeconds(1))); + tester.clock().advance(Duration.ofDays(7).plus(Duration.ofSeconds(1))); scheduler.maintain(); assertEquals(version3, tester.controller().osVersionTarget(cloud).get().osVersion().version()); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceTagMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceTagMaintainerTest.java index 814dc2a3f50..516c28ab5cd 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceTagMaintainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceTagMaintainerTest.java @@ -17,6 +17,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import static com.yahoo.vespa.hosted.controller.maintenance.ResourceTagMaintainer.SHARED_HOST_APPLICATION; import static org.junit.Assert.assertEquals; /** @@ -35,9 +36,9 @@ public class ResourceTagMaintainerTest { mockResourceTagger); resourceTagMaintainer.maintain(); assertEquals(2, mockResourceTagger.getValues().size()); - Map<HostName, Optional<ApplicationId>> applicationForHost = mockResourceTagger.getValues().get(ZoneId.from("prod.region-2")); - assertEquals(ApplicationId.from("t1", "a1", "i1"), applicationForHost.get(HostName.from("parentHostA.prod.region-2")).get()); - assertEquals(Optional.empty(), applicationForHost.get(HostName.from("parentHostB.prod.region-2"))); + Map<HostName, ApplicationId> applicationForHost = mockResourceTagger.getValues().get(ZoneId.from("prod.region-2")); + assertEquals(ApplicationId.from("t1", "a1", "i1"), applicationForHost.get(HostName.from("parentHostA.prod.region-2"))); + assertEquals(SHARED_HOST_APPLICATION, applicationForHost.get(HostName.from("parentHostB.prod.region-2"))); } private void setUpZones() { diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/container/image/ContainerImageDownloader.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/container/image/ContainerImageDownloader.java index c65209698f6..066114dc41f 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/container/image/ContainerImageDownloader.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/container/image/ContainerImageDownloader.java @@ -13,6 +13,8 @@ import java.util.Objects; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.logging.Level; +import java.util.logging.Logger; /** * Download a container image asynchronously. @@ -21,6 +23,8 @@ import java.util.concurrent.Executors; */ public class ContainerImageDownloader { + private static final Logger LOG = Logger.getLogger(ContainerImageDownloader.class.getName()); + private final ContainerEngine containerEngine; private final ExecutorService executorService = Executors.newSingleThreadExecutor( @@ -42,6 +46,8 @@ public class ContainerImageDownloader { executorService.submit(() -> { try { containerEngine.pullImage(context, image, registryCredentials); + } catch (RuntimeException e) { + LOG.log(Level.SEVERE, "Failed to download container image " + image, e); } finally { pendingDownloads.remove(image); } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java index b57b3070d15..3a655062f7a 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java @@ -333,6 +333,9 @@ public class QuestMetricsDb extends AbstractComponent implements MetricsDb { SqlCompiler sqlCompiler = sqlCompilerPool.alloc(); try { return sqlCompiler.compile(sql, context); + } catch (SqlException e) { + log.log(Level.WARNING, "Could not execute SQL statement '" + sql + "'"); + throw e; } finally { sqlCompilerPool.free(sqlCompiler); } @@ -61,13 +61,11 @@ <module>container-disc</module> <module>container-documentapi</module> <module>container-integration-test</module> - <module>container-jersey2</module> <module>container-messagebus</module> <module>container-search-and-docproc</module> <module>container-search</module> <module>container-search-gui</module> <module>container-test</module> - <module>container-test-jars</module> <module>controller-api</module> <module>controller-server</module> <module>defaults</module> diff --git a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp index d5823a8e055..13dcfb45dc9 100644 --- a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp +++ b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp @@ -117,6 +117,7 @@ public: search::SerialNum _oldestSerial; search::SerialNum _currentSerial; uint32_t _pendingDone; + uint32_t _taskDone; std::mutex _lock; vespalib::CountDownLatch _done; FlushDoneHistory _flushDoneHistory; @@ -131,6 +132,7 @@ public: _oldestSerial(0), _currentSerial(currentSerial), _pendingDone(0u), + _taskDone(0u), _lock(), _done(targets.size()), _flushDoneHistory() @@ -143,6 +145,11 @@ public: std::vector<IFlushTarget::SP> getFlushTargets() override { + { + std::lock_guard<std::mutex> guard(_lock); + _pendingDone += _taskDone; + _taskDone = 0; + } LOG(info, "SimpleHandler(%s)::getFlushTargets()", getName().c_str()); std::vector<IFlushTarget::SP> wrappedTargets; for (const auto &target : _targets) { @@ -154,7 +161,7 @@ public: // Called once by flush engine thread for each task done void taskDone() { std::lock_guard<std::mutex> guard(_lock); - ++_pendingDone; + ++_taskDone; } // Called by flush engine master thread after flush handler is diff --git a/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java b/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java index 9a6ef3f74f1..414a18eb56d 100644 --- a/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java +++ b/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.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.curator; import com.google.inject.Inject; @@ -54,7 +54,10 @@ public class Curator implements VespaCurator, AutoCloseable { private static final Logger LOG = Logger.getLogger(Curator.class.getName()); private static final File ZK_CLIENT_CONFIG_FILE = new File(Defaults.getDefaults().underVespaHome("conf/zookeeper/zookeeper-client.cfg")); - private static final Duration ZK_SESSION_TIMEOUT = Duration.ofSeconds(30); + + // Note that session timeout has min and max values are related to tickTime defined by server, see configserver.def + private static final Duration ZK_SESSION_TIMEOUT = Duration.ofSeconds(120); + private static final Duration ZK_CONNECTION_TIMEOUT = Duration.ofSeconds(30); private static final Duration BASE_SLEEP_TIME = Duration.ofSeconds(1); private static final int MAX_RETRIES = 10; diff --git a/zookeeper-server/zookeeper-server-common/src/test/java/com/yahoo/vespa/zookeeper/ConfiguratorTest.java b/zookeeper-server/zookeeper-server-common/src/test/java/com/yahoo/vespa/zookeeper/ConfiguratorTest.java index c40b7cb7b52..ae84ff12b3b 100644 --- a/zookeeper-server/zookeeper-server-common/src/test/java/com/yahoo/vespa/zookeeper/ConfiguratorTest.java +++ b/zookeeper-server/zookeeper-server-common/src/test/java/com/yahoo/vespa/zookeeper/ConfiguratorTest.java @@ -70,6 +70,7 @@ public class ConfiguratorTest { builder.server(newServer(2, "baz", 345, 543, true)); builder.myidFile(idFile.getAbsolutePath()); builder.myid(1); + builder.tickTime(1234); new Configurator(builder.build()).writeConfigToDisk(VespaTlsConfig.tlsDisabled()); validateConfigFileMultipleHosts(cfgFile); validateIdFile(idFile, "1\n"); @@ -127,6 +128,7 @@ public class ConfiguratorTest { builder.myidFile(idFile.getAbsolutePath()); builder.server(newServer(0, "foo", 123, 321, false)); builder.myid(0); + builder.tickTime(1234); return builder; } @@ -146,7 +148,7 @@ public class ConfiguratorTest { } private String commonConfig() { - return "tickTime=2000\n" + + return "tickTime=1234\n" + "initLimit=20\n" + "syncLimit=15\n" + "maxClientCnxns=0\n" + |