Skip to content

Commit 8ccf877

Browse files
authored
Merge pull request #147 from rabbitmq/jetty-11
Use Jetty 11 in performance tool
2 parents 34204ec + dd726ff commit 8ccf877

17 files changed

+65
-12
lines changed

pom.xml

+46-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<micrometer.version>1.9.1</micrometer.version>
5858
<swiftmq-client.version>12.2.2</swiftmq-client.version>
5959
<picocli.version>4.6.3</picocli.version>
60-
<jetty.version>9.4.48.v20220622</jetty.version>
60+
<jetty.version>11.0.11</jetty.version>
6161
<guava.version>31.1-jre</guava.version>
6262
<commons-compress.version>1.21</commons-compress.version>
6363
<zstd-jni.version>1.5.2-3</zstd-jni.version>
@@ -189,7 +189,7 @@
189189

190190
<dependency>
191191
<groupId>org.eclipse.jetty</groupId>
192-
<artifactId>jetty-servlet</artifactId>
192+
<artifactId>jetty-server</artifactId>
193193
<version>${jetty.version}</version>
194194
<optional>true</optional>
195195
</dependency>
@@ -578,6 +578,49 @@
578578
</build>
579579

580580
<profiles>
581+
582+
<profile>
583+
<id>perf</id>
584+
<activation>
585+
<jdk>[11,)</jdk>
586+
</activation>
587+
<build>
588+
<plugins>
589+
<plugin>
590+
<groupId>org.codehaus.mojo</groupId>
591+
<artifactId>build-helper-maven-plugin</artifactId>
592+
<version>3.3.0</version>
593+
<executions>
594+
<execution>
595+
<id>add-source</id>
596+
<phase>generate-sources</phase>
597+
<goals>
598+
<goal>add-source</goal>
599+
</goals>
600+
<configuration>
601+
<sources>
602+
<source>src/performance-tool/java</source>
603+
</sources>
604+
</configuration>
605+
</execution>
606+
<execution>
607+
<id>add-test-source</id>
608+
<phase>generate-test-sources</phase>
609+
<goals>
610+
<goal>add-test-source</goal>
611+
</goals>
612+
<configuration>
613+
<sources>
614+
<source>src/performance-tool/test</source>
615+
</sources>
616+
</configuration>
617+
</execution>
618+
</executions>
619+
</plugin>
620+
</plugins>
621+
</build>
622+
</profile>
623+
581624
<profile>
582625
<id>performance-tool</id>
583626
<dependencies>
@@ -621,7 +664,7 @@
621664

622665
<dependency>
623666
<groupId>org.eclipse.jetty</groupId>
624-
<artifactId>jetty-servlet</artifactId>
667+
<artifactId>jetty-server</artifactId>
625668
<version>${jetty.version}</version>
626669
</dependency>
627670

src/docs/asciidoc/performance-tool.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
== The Performance Tool
22

3+
NOTE: The performance tool requires *Java 11 or more*.
4+
35
The library contains also a performance tool to test the RabbitMQ Stream plugin.
46
It is usable as an uber JAR
57
https://github.com/rabbitmq/rabbitmq-stream-java-client/releases[downloadable from GitHub Release] or as a https://hub.docker.com/r/pivotalrabbitmq/stream-perf-test[Docker image].

src/main/java/com/rabbitmq/stream/perf/DebugEndpointMonitoring.java renamed to src/performance-tool/java/com/rabbitmq/stream/perf/DebugEndpointMonitoring.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021 VMware, Inc. or its affiliates. All rights reserved.
1+
// Copyright (c) 2021-2022 VMware, Inc. or its affiliates. All rights reserved.
22
//
33
// This software, the RabbitMQ Stream Java client library, is dual-licensed under the
44
// Mozilla Public License 2.0 ("MPL"), and the Apache License version 2 ("ASL").
@@ -13,6 +13,8 @@
1313
1414
package com.rabbitmq.stream.perf;
1515

16+
import jakarta.servlet.http.HttpServletRequest;
17+
import jakarta.servlet.http.HttpServletResponse;
1618
import java.io.IOException;
1719
import java.io.PrintWriter;
1820
import java.io.StringWriter;
@@ -26,8 +28,6 @@
2628
import java.util.List;
2729
import java.util.stream.Collectors;
2830
import java.util.stream.Stream;
29-
import javax.servlet.http.HttpServletRequest;
30-
import javax.servlet.http.HttpServletResponse;
3131
import org.eclipse.jetty.server.Request;
3232
import org.eclipse.jetty.server.handler.AbstractHandler;
3333
import picocli.CommandLine.Option;
@@ -54,7 +54,6 @@ public void handle(
5454
HttpServletRequest request,
5555
HttpServletResponse response)
5656
throws IOException {
57-
5857
ThreadInfo[] threadInfos =
5958
ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
6059
String content = formatter.format(threadInfos);

src/main/java/com/rabbitmq/stream/perf/MonitoringContext.java renamed to src/performance-tool/java/com/rabbitmq/stream/perf/MonitoringContext.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@
2626
import org.eclipse.jetty.server.handler.ContextHandler;
2727
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
2828
import org.eclipse.jetty.util.thread.QueuedThreadPool;
29+
import org.slf4j.Logger;
30+
import org.slf4j.LoggerFactory;
2931

3032
class MonitoringContext {
3133

34+
private static final Logger LOGGER = LoggerFactory.getLogger(MonitoringContext.class);
35+
3236
private final int monitoringPort;
3337
private final CompositeMeterRegistry meterRegistry;
3438

@@ -70,14 +74,17 @@ void start() throws Exception {
7074
new ContextHandlerCollection(contextHandlers.toArray(new ContextHandler[0]));
7175
server.setHandler(contextHandler);
7276

73-
server.setStopTimeout(1000);
77+
server.setStopTimeout(10000);
7478
server.start();
7579
}
7680
}
7781

7882
void close() throws Exception {
7983
if (server != null) {
84+
LOGGER.debug("Closing Jetty server");
85+
long start = System.currentTimeMillis();
8086
server.stop();
87+
LOGGER.debug("Closed Jetty server in {} ms", (System.currentTimeMillis() - start));
8188
}
8289
}
8390

src/main/java/com/rabbitmq/stream/perf/PrometheusEndpointMonitoring.java renamed to src/performance-tool/java/com/rabbitmq/stream/perf/PrometheusEndpointMonitoring.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021 VMware, Inc. or its affiliates. All rights reserved.
1+
// Copyright (c) 2021-2022 VMware, Inc. or its affiliates. All rights reserved.
22
//
33
// This software, the RabbitMQ Stream Java client library, is dual-licensed under the
44
// Mozilla Public License 2.0 ("MPL"), and the Apache License version 2 ("ASL").
@@ -15,9 +15,9 @@
1515

1616
import io.micrometer.prometheus.PrometheusConfig;
1717
import io.micrometer.prometheus.PrometheusMeterRegistry;
18+
import jakarta.servlet.http.HttpServletRequest;
19+
import jakarta.servlet.http.HttpServletResponse;
1820
import java.io.IOException;
19-
import javax.servlet.http.HttpServletRequest;
20-
import javax.servlet.http.HttpServletResponse;
2121
import org.eclipse.jetty.server.Request;
2222
import org.eclipse.jetty.server.handler.AbstractHandler;
2323
import picocli.CommandLine.Option;
@@ -47,7 +47,6 @@ public void handle(
4747
HttpServletRequest request,
4848
HttpServletResponse response)
4949
throws IOException {
50-
5150
String scraped = registry.scrape();
5251

5352
response.setStatus(HttpServletResponse.SC_OK);

src/test/java/com/rabbitmq/stream/perf/StreamPerfTestTest.java renamed to src/performance-tool/test/com/rabbitmq/stream/perf/StreamPerfTestTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@
5151
import org.junit.jupiter.api.BeforeEach;
5252
import org.junit.jupiter.api.Test;
5353
import org.junit.jupiter.api.TestInfo;
54+
import org.junit.jupiter.api.condition.EnabledForJreRange;
55+
import org.junit.jupiter.api.condition.JRE;
5456
import org.junit.jupiter.api.extension.ExtendWith;
5557

5658
@ExtendWith(TestUtils.StreamTestInfrastructureExtension.class)
59+
@EnabledForJreRange(min = JRE.JAVA_11)
5760
public class StreamPerfTestTest {
5861

5962
static ExecutorService executor = Executors.newSingleThreadExecutor();

0 commit comments

Comments
 (0)