summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dist/vespa.spec2
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeListMicroBenchmarkTest.java100
-rw-r--r--security-utils/CMakeLists.txt2
-rw-r--r--security-utils/pom.xml41
4 files changed, 115 insertions, 30 deletions
diff --git a/dist/vespa.spec b/dist/vespa.spec
index 5fe27bb3549..1fa9fbc9796 100644
--- a/dist/vespa.spec
+++ b/dist/vespa.spec
@@ -823,7 +823,7 @@ fi
%{_prefix}/lib/jars/model-integration-jar-with-dependencies.jar
%{_prefix}/lib/jars/org.apache.aries.spifly.dynamic.bundle-*.jar
%{_prefix}/lib/jars/osgi-resource-locator-*.jar
-%{_prefix}/lib/jars/security-utils.jar
+%{_prefix}/lib/jars/security-utils-jar-with-dependencies.jar
%{_prefix}/lib/jars/standalone-container-jar-with-dependencies.jar
%{_prefix}/lib/jars/validation-api-*.jar
%{_prefix}/lib/jars/vespa-athenz-jar-with-dependencies.jar
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeListMicroBenchmarkTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeListMicroBenchmarkTest.java
new file mode 100644
index 00000000000..a1edbec5769
--- /dev/null
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeListMicroBenchmarkTest.java
@@ -0,0 +1,100 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.provision;
+
+import com.yahoo.config.provision.Flavor;
+import com.yahoo.config.provision.NodeFlavors;
+import com.yahoo.config.provision.NodeResources;
+import com.yahoo.config.provision.NodeType;
+import com.yahoo.config.provisioning.FlavorsConfig;
+import com.yahoo.vespa.hosted.provision.node.IP;
+import com.yahoo.vespa.hosted.provision.provisioning.FlavorConfigBuilder;
+import com.yahoo.vespa.hosted.provision.provisioning.ProvisioningTester;
+import org.junit.Test;
+
+import java.time.Duration;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Random;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * @author hmusum
+ */
+public class NodeListMicroBenchmarkTest {
+
+ private static final NodeFlavors nodeFlavors = createNodeFlavors();
+ private final NodeResources resources0 = new NodeResources(1, 30, 20, 1.5);
+ private int nodeCounter = 0;
+ private static final int hostCount = 1000;
+
+ @Test
+ public void testChildrenOf() {
+ List<Node> nodes = createHosts();
+
+ List<Node> childNodes = nodes.stream().map(host -> createNodes(host.hostname())).flatMap(Collection::stream).collect(Collectors.toList());
+ nodes.addAll(childNodes);
+ NodeList nodeList = new NodeList(nodes, false);
+
+ int iterations = 100000;
+ Random random = new Random(0);
+ ArrayList<Integer> indexes = new ArrayList<>();
+ for (int i = 0; i < iterations; i++) {
+ indexes.add(random.nextInt(hostCount));
+ }
+
+ Instant start = Instant.now();
+ for (int i = 0; i < iterations; i++) {
+ nodeList.childrenOf(nodes.get(indexes.get(i)));
+ }
+ Duration duration = Duration.between(start, Instant.now());
+ System.out.println("Calling NodeList.childrenOf took " + duration + " (" + duration.toNanos() / iterations / 1000 + " microseconds per invocation)");
+ }
+
+ private List<Node> createHosts() {
+ List<Node> hosts = new ArrayList<>();
+ for (int i = 0; i < hostCount; i++) {
+ hosts.add(Node.create("host" + i, IP.Config.of(Set.of("::1"), createIps(), List.of()),
+ "host" + i, getFlavor("host"), NodeType.host).build());
+ }
+ return hosts;
+ }
+
+ private List<Node> createNodes(String parentHostname) {
+ List<Node> nodes = new ArrayList<>();
+ for (int i = 0; i < 10; i++) {
+ nodeCounter++;
+ Node node = Node.reserve(Set.of("::2"), "node" + nodeCounter, parentHostname, resources0, NodeType.tenant).build();
+ nodes.add(node);
+ }
+ return nodes;
+ }
+
+ private static NodeFlavors createNodeFlavors() {
+ FlavorConfigBuilder builder = new FlavorConfigBuilder();
+ builder.addFlavor("host", 30, 30, 40, 3, Flavor.Type.BARE_METAL);
+ builder.addFlavor("node", 3, 3, 4, 3, Flavor.Type.DOCKER_CONTAINER);
+ FlavorsConfig flavorsConfig = builder.build();
+ return new NodeFlavors(Optional.ofNullable(flavorsConfig).orElseGet(ProvisioningTester::createConfig));
+ }
+
+ private Flavor getFlavor(String name) {
+ return nodeFlavors.getFlavor(name).orElseThrow(() -> new RuntimeException("Unknown flavor"));
+ }
+
+ private Set<String> createIps() {
+ // Allow 4 containers
+ int start = 2;
+ int count = 4;
+ Set<String> ipAddressPool = new LinkedHashSet<>();
+ for (int i = start; i < (start + count); i++) {
+ ipAddressPool.add("::" + i);
+ }
+ return ipAddressPool;
+ }
+
+}
diff --git a/security-utils/CMakeLists.txt b/security-utils/CMakeLists.txt
index b701b78e3cc..a6fe917c322 100644
--- a/security-utils/CMakeLists.txt
+++ b/security-utils/CMakeLists.txt
@@ -1,2 +1,2 @@
# Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-install_java_artifact(security-utils)
+install_fat_java_artifact(security-utils)
diff --git a/security-utils/pom.xml b/security-utils/pom.xml
index 567174df102..4796a809293 100644
--- a/security-utils/pom.xml
+++ b/security-utils/pom.xml
@@ -9,7 +9,7 @@
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>security-utils</artifactId>
- <packaging>bundle</packaging>
+ <packaging>container-plugin</packaging>
<version>7-SNAPSHOT</version>
<properties>
@@ -26,6 +26,13 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <!-- required for bundle-plugin to generate import-package statements for Java's standard library -->
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>jdisc_core</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
<!-- compile scope -->
<dependency>
@@ -70,6 +77,11 @@
<build>
<plugins>
<plugin>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
@@ -86,33 +98,6 @@
</compilerArgs>
</configuration>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>parse-version</id>
- <goals>
- <goal>parse-version</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <!-- Build with maven-bundle-plugin to avoid depending on jdisc_core to get the correct Import-Packages -->
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Bundle-Version>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</Bundle-Version>
- <Export-Package>com.yahoo.security.*;version=1.0.0;-noimport:=true</Export-Package>
- <_nouses>true</_nouses> <!-- Don't include 'uses' directives for package exports -->
- <_fixupmessages>"Classes found in the wrong directory"</_fixupmessages> <!-- Hide warnings for bouncycastle multi-release jars -->
- </instructions>
- </configuration>
- </plugin>
</plugins>
</build>
</project>