Skip to content

Commit cdb3e07

Browse files
authored
Updates files to run with Helidon 4.0.3. (#8764)
Signed-off-by: Santiago Pericasgeertsen <[email protected]>
1 parent 53352ca commit cdb3e07

File tree

7 files changed

+73
-74
lines changed

7 files changed

+73
-74
lines changed
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
FROM docker.io/maven:3.9.2-eclipse-temurin-20 as maven
1+
FROM docker.io/maven:3.9.6-eclipse-temurin-21 as maven
22
WORKDIR /helidon
33
COPY nima/src src
44
COPY nima/pom.xml pom.xml
55
RUN mvn package -q
66

7-
FROM openjdk:20-jdk-slim
7+
FROM openjdk:22-rc-jdk-slim
88
WORKDIR /helidon
99
COPY --from=maven /helidon/target/libs libs
1010
COPY --from=maven /helidon/target/benchmark-nima.jar app.jar
1111

1212
EXPOSE 8080
1313

14-
CMD java --enable-preview \
15-
-XX:+UseNUMA \
14+
CMD java -XX:+UseNUMA \
1615
-XX:+UseParallelGC \
1716
-jar app.jar

frameworks/Java/helidon/nima/pom.xml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>io.helidon.applications</groupId>
2323
<artifactId>helidon-se</artifactId>
24-
<version>4.0.0-ALPHA6</version>
24+
<version>4.0.3</version>
2525
<relativePath/>
2626
</parent>
2727

@@ -33,25 +33,25 @@
3333

3434
<properties>
3535
<mainClass>io.helidon.benchmark.nima.Main</mainClass>
36-
<version.java>20</version.java>
36+
<version.java>21</version.java>
3737
<version.plugin.compiler>3.11.0</version.plugin.compiler>
3838
<rocker.version>1.3.0</rocker.version>
39-
<vertx-pg-client.version>4.4.2</vertx-pg-client.version>
39+
<vertx-pg-client.version>4.5.3</vertx-pg-client.version>
4040
<jsoniter.version>0.9.23</jsoniter.version>
4141
</properties>
4242

4343
<dependencies>
4444
<dependency>
45-
<groupId>io.helidon.nima.webserver</groupId>
46-
<artifactId>helidon-nima-webserver</artifactId>
45+
<groupId>io.helidon.webserver</groupId>
46+
<artifactId>helidon-webserver</artifactId>
4747
</dependency>
4848
<dependency>
4949
<groupId>io.helidon.config</groupId>
5050
<artifactId>helidon-config-yaml</artifactId>
5151
</dependency>
5252
<dependency>
53-
<groupId>io.helidon.nima.http.media</groupId>
54-
<artifactId>helidon-nima-http-media-jsonp</artifactId>
53+
<groupId>io.helidon.http.media</groupId>
54+
<artifactId>helidon-http-media-jsonp</artifactId>
5555
</dependency>
5656
<dependency>
5757
<groupId>io.helidon.common</groupId>
@@ -83,8 +83,8 @@
8383
<version>${rocker.version}</version>
8484
</dependency>
8585
<dependency>
86-
<groupId>io.helidon.nima.testing.junit5</groupId>
87-
<artifactId>helidon-nima-testing-junit5-webserver</artifactId>
86+
<groupId>io.helidon.common.testing</groupId>
87+
<artifactId>helidon-common-testing-junit5</artifactId>
8888
<scope>test</scope>
8989
</dependency>
9090
<dependency>
@@ -113,7 +113,6 @@
113113
<compilerArgs>
114114
<arg>-Xlint:unchecked</arg>
115115
<arg>-Xpkginfo:always</arg>
116-
<arg>--enable-preview</arg>
117116
</compilerArgs>
118117
</configuration>
119118
</plugin>

frameworks/Java/helidon/nima/src/main/java/io/helidon/benchmark/nima/Main.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@
2929
import io.helidon.benchmark.nima.models.PgClientRepository;
3030
import io.helidon.benchmark.nima.services.DbService;
3131
import io.helidon.benchmark.nima.services.FortuneHandler;
32-
import io.helidon.common.http.Http;
33-
import io.helidon.common.http.Http.Header;
34-
import io.helidon.common.http.Http.HeaderValue;
35-
import io.helidon.common.http.Http.HeaderValues;
32+
import io.helidon.http.Header;
33+
import io.helidon.http.HeaderNames;
34+
import io.helidon.http.HeaderValues;
3635
import io.helidon.config.Config;
3736
import io.helidon.config.ConfigException;
3837
import io.helidon.logging.common.LogConfig;
39-
import io.helidon.nima.webserver.WebServer;
40-
import io.helidon.nima.webserver.http.Handler;
41-
import io.helidon.nima.webserver.http.HttpRules;
42-
import io.helidon.nima.webserver.http.ServerRequest;
43-
import io.helidon.nima.webserver.http.ServerResponse;
38+
import io.helidon.webserver.WebServer;
39+
import io.helidon.webserver.http.Handler;
40+
import io.helidon.webserver.http.HttpRules;
41+
import io.helidon.webserver.http.ServerRequest;
42+
import io.helidon.webserver.http.ServerResponse;
4443

4544
/**
4645
* Main class of the benchmark.
@@ -50,9 +49,9 @@
5049
public final class Main {
5150
private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
5251

53-
public static final Http.HeaderValue CONTENT_TYPE_HTML =
54-
Http.Header.createCached(Http.Header.CONTENT_TYPE, "text/html; charset=UTF-8");
55-
public static final Http.HeaderValue SERVER = Http.Header.createCached(Http.Header.SERVER, "Nima");
52+
public static final Header CONTENT_TYPE_HTML =
53+
HeaderValues.createCached(HeaderNames.CONTENT_TYPE, "text/html; charset=UTF-8");
54+
public static final Header SERVER = HeaderValues.createCached(HeaderNames.SERVER, "Nima");
5655

5756
private Main() {
5857
}
@@ -67,11 +66,14 @@ public static void main(String[] args) {
6766
LogConfig.configureRuntime();
6867

6968
WebServer.builder()
69+
.config(Config.create().get("server"))
7070
.routing(Main::routing)
71+
.build()
7172
.start();
7273
}
7374

7475
// exposed for tests
76+
@SuppressWarnings("unchecked")
7577
static void routing(HttpRules rules) {
7678
Config config = Config.create();
7779

@@ -107,9 +109,9 @@ private static byte[] serializeMsg(Message obj) {
107109
}
108110

109111
static class PlaintextHandler implements Handler {
110-
static final HeaderValue CONTENT_TYPE = Header.createCached(Header.CONTENT_TYPE,
112+
static final Header CONTENT_TYPE = HeaderValues.createCached(HeaderNames.CONTENT_TYPE,
111113
"text/plain; charset=UTF-8");
112-
static final HeaderValue CONTENT_LENGTH = Header.createCached(Header.CONTENT_LENGTH, "13");
114+
static final Header CONTENT_LENGTH = HeaderValues.createCached(HeaderNames.CONTENT_LENGTH, "13");
113115

114116
private static final byte[] RESPONSE_BYTES = "Hello, World!".getBytes(StandardCharsets.UTF_8);
115117

@@ -125,7 +127,7 @@ public void handle(ServerRequest req, ServerResponse res) {
125127
static class JsonHandler implements Handler {
126128
private static final String MESSAGE = "Hello, World!";
127129
private static final int JSON_LENGTH = serializeMsg(new Message(MESSAGE)).length;
128-
static final HeaderValue CONTENT_LENGTH = Header.createCached(Header.CONTENT_LENGTH,
130+
static final Header CONTENT_LENGTH = HeaderValues.createCached(HeaderNames.CONTENT_LENGTH,
129131
String.valueOf(JSON_LENGTH));
130132

131133
@Override
@@ -142,13 +144,13 @@ private static Message newMsg() {
142144
}
143145

144146
static class JsonKHandler implements Handler {
145-
private final HeaderValue contentLength;
147+
private final Header contentLength;
146148
private final String message;
147149

148150
JsonKHandler(int kilobytes) {
149151
this.message = "a".repeat(1024 * kilobytes);
150152
int length = serializeMsg(new Message(message)).length;
151-
this.contentLength = Header.createCached(Header.CONTENT_LENGTH,
153+
this.contentLength = HeaderValues.createCached(HeaderNames.CONTENT_LENGTH,
152154
String.valueOf(length));
153155
}
154156

frameworks/Java/helidon/nima/src/main/java/io/helidon/benchmark/nima/models/PgClientRepository.java

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,29 +110,34 @@ public List<World> getWorlds(int count) {
110110

111111
@Override
112112
public World updateWorld(World world) {
113-
try {
114-
updateWorlds(List.of(world), 0, updatePool);
115-
return world;
116-
} catch (Exception e) {
117-
throw new RuntimeException(e);
118-
}
113+
return Single.create(queryPool.preparedQuery("UPDATE world SET randomnumber = $1 WHERE id = $2")
114+
.execute(Tuple.of(world.id, world.id))
115+
.toCompletionStage()
116+
.thenApply(rows -> world)).await();
119117
}
120118

121119
@Override
122120
public List<World> updateWorlds(int count) {
123121
List<World> worlds = getWorlds(count);
124-
for (World w : worlds) {
125-
w.randomNumber = randomWorldNumber();
126-
}
127-
if (count <= batchSize) {
128-
LOGGER.finest(() -> "Updating single batch of size " + count);
129-
updateWorldsRetry(worlds, 0, 0);
130-
} else {
131-
int batches = count / batchSize + (count % batchSize == 0 ? 0 : 1);
132-
for (int i = 0; i < batches; i++) {
133-
final int from = i * batchSize;
134-
LOGGER.finest(() -> "Updating batch from " + from + " to " + (from + batchSize));
135-
updateWorldsRetry(worlds, from, 0);
122+
if (batchSize > 1) { // batching updates
123+
for (World w : worlds) {
124+
w.randomNumber = randomWorldNumber();
125+
}
126+
if (count <= batchSize) {
127+
LOGGER.finest(() -> "Updating single batch of size " + count);
128+
updateWorldsRetry(worlds, 0, 0);
129+
} else {
130+
int batches = count / batchSize + (count % batchSize == 0 ? 0 : 1);
131+
for (int i = 0; i < batches; i++) {
132+
final int from = i * batchSize;
133+
LOGGER.finest(() -> "Updating batch from " + from + " to " + (from + batchSize));
134+
updateWorldsRetry(worlds, from, 0);
135+
}
136+
}
137+
} else { // no batching for size 1
138+
for (World w : worlds) {
139+
w.randomNumber = randomWorldNumber();
140+
updateWorld(w);
136141
}
137142
}
138143
return worlds;

frameworks/Java/helidon/nima/src/main/java/io/helidon/benchmark/nima/services/DbService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import io.helidon.benchmark.nima.models.DbRepository;
88
import io.helidon.benchmark.nima.models.World;
99
import io.helidon.common.parameters.Parameters;
10-
import io.helidon.nima.webserver.http.HttpRules;
11-
import io.helidon.nima.webserver.http.HttpService;
12-
import io.helidon.nima.webserver.http.ServerRequest;
13-
import io.helidon.nima.webserver.http.ServerResponse;
10+
import io.helidon.webserver.http.HttpRules;
11+
import io.helidon.webserver.http.HttpService;
12+
import io.helidon.webserver.http.ServerRequest;
13+
import io.helidon.webserver.http.ServerResponse;
1414

1515
import jakarta.json.Json;
1616
import jakarta.json.JsonArrayBuilder;

frameworks/Java/helidon/nima/src/main/java/io/helidon/benchmark/nima/services/FortuneHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import com.fizzed.rocker.runtime.ArrayOfByteArraysOutput;
88
import io.helidon.benchmark.nima.models.DbRepository;
99
import io.helidon.benchmark.nima.models.Fortune;
10-
import io.helidon.nima.webserver.http.Handler;
11-
import io.helidon.nima.webserver.http.ServerRequest;
12-
import io.helidon.nima.webserver.http.ServerResponse;
10+
import io.helidon.webserver.http.Handler;
11+
import io.helidon.webserver.http.ServerRequest;
12+
import io.helidon.webserver.http.ServerResponse;
1313
import views.fortunes;
1414

1515
import static io.helidon.benchmark.nima.Main.CONTENT_TYPE_HTML;

frameworks/Java/helidon/nima/src/main/resources/application.yaml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2022, 2023 Oracle and/or its affiliates.
2+
# Copyright (c) 2022, 2024 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -15,33 +15,27 @@
1515
#
1616

1717
server:
18+
host: 0.0.0.0
1819
port: 8080
19-
sockets:
20-
- name: "@default"
21-
host: 0.0.0.0
22-
port: 8080
23-
backlog: 8192
24-
receive-buffer-size: 64000
25-
# set write-queue-length to 0 or not setting it will disable async writes
26-
# write-queue-length: 1024
27-
connection-options:
28-
read-timeout-seconds: 0
29-
connect-timeout-seconds: 0
30-
send-buffer-size: 64000
31-
receive-buffer-size: 64000
32-
connection-providers:
20+
backlog: 8192
21+
write-queue-length: 8192
22+
connection-options:
23+
read-timeout: PT0S
24+
connect-timeout: PT0S
25+
tcp-no-delay: true
26+
protocols:
3327
"http_1_1":
34-
validate-headers: false
28+
validate-request-headers: false
29+
validate-response-headers: false
3530
validate-path: false
3631
recv-log: false
3732
send-log: false
3833

3934
host: "tfb-database"
40-
#host: "localhost"
4135
db: "hello_world"
4236
username: benchmarkdbuser
4337
password: benchmarkdbpass
44-
sql-pool-size: 200
38+
sql-pool-size: 300
4539
db-repository: "pgclient" # "pgclient" (default) or "hikari"
4640

4741
# The following for pgclient only

0 commit comments

Comments
 (0)