Skip to content

Commit

Permalink
Fixes #77 - Java 8 compatibility. (#79)
Browse files Browse the repository at this point in the history
* Fixes #77 - Java 8 compatibility.

Updated dependencies for ALPN.
Updated usage of Java 11 API back to Java 8 APIs.
Updated README.
Added both ALPN implementations to uber jar, so that it can be used with any Java version.

Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet authored May 3, 2021
1 parent ce99bb8 commit af10b21
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
java: [11, 16]
java: [8, 11, 16]
fail-fast: false

runs-on: ${{ matrix.os }}
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ Jetty's `LoadGenerator` is an API to load-test HTTP servers, based on Jetty's `H

| Jetty Load Generator Version | Jetty Version | Java Version
| :---: | :---: | :---:
| 1.0.x | 9.4.x | Java 11
| 2.0.x | 11.0.x | Java 11
| 1.0.0-1.0.6 | 9.4.x | Java 11+
| 1.0.7-1.0.x | 9.4.x | Java 8+
| 2.0.x | 11.0.x | Java 11+

The design of the `LoadGenerator` is based around these concepts:

Expand Down
48 changes: 38 additions & 10 deletions jetty-load-generator-client/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<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 https://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.mortbay.jetty.loadgenerator</groupId>
<artifactId>jetty-load-generator</artifactId>
Expand All @@ -26,10 +26,6 @@
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-http-client-transport</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-java-client</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util-ajax</artifactId>
Expand All @@ -50,11 +46,6 @@
<artifactId>jetty-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-java-server</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
Expand All @@ -81,4 +72,41 @@
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>java8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-openjdk8-client</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-openjdk8-server</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>java9+</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-java-client</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-java-server</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public void failed(Throwable x) {
}
}, nodes);
Sender sender = new Sender(client, warmup, treeCallback);
sender.offer(List.of(info));
sender.offer(Collections.singletonList(info));
sender.send();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public long getResponseLength() {
* @return this Resource
*/
public Resource resources(Resource... resources) {
this.resources.addAll(List.of(resources));
this.resources.addAll(Arrays.asList(resources));
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion jetty-load-generator-listeners/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<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 https://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.mortbay.jetty.loadgenerator</groupId>
<artifactId>jetty-load-generator</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public void toJSON(JSON.Output out) {
HistogramLogWriter hw = new HistogramLogWriter(histogramOutput);
hw.outputIntervalHistogram(getResponseTimeHistogram());
hw.close();
out.add("histogram", histogramOutput.toString(StandardCharsets.UTF_8));
out.add("histogram", new String(histogramOutput.toByteArray(), StandardCharsets.UTF_8));
}

@Override
Expand Down
13 changes: 12 additions & 1 deletion jetty-load-generator-starter/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<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 https://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.mortbay.jetty.loadgenerator</groupId>
<artifactId>jetty-load-generator</artifactId>
Expand Down Expand Up @@ -66,6 +66,17 @@
<artifactId>jetty-servlet</artifactId>
<scope>test</scope>
</dependency>
<!-- Put both ALPN implementations in the uberjar to work with any Java version -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-openjdk8-client</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-java-client</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.lang.management.ManagementFactory;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -69,7 +69,7 @@ public static void main(String[] args) throws Exception {
}
String statsFile = starterArgs.getStatsFile();
if (statsFile != null) {
try (OutputStream output = Files.newOutputStream(Path.of(statsFile))) {
try (OutputStream output = Files.newOutputStream(Paths.get(statsFile))) {
Map<String, Object> map = new HashMap<>();
map.put("config", generator.getConfig());
map.put("report", report);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -169,7 +170,7 @@ public void onCommit(Request request) {
@Test
public void testFromGroovyToJSON() throws Exception {
try (Reader reader = Files.newBufferedReader(Paths.get("src/test/resources/tree_resources.groovy"))) {
Resource resource = LoadGeneratorStarterArgs.evaluateGroovy(reader, Map.of());
Resource resource = LoadGeneratorStarterArgs.evaluateGroovy(reader, Collections.emptyMap());
Path tmpPath = Files.createTempFile("resources_", ".tmp");
tmpPath.toFile().deleteOnExit();
try (BufferedWriter writer = Files.newBufferedWriter(tmpPath, StandardCharsets.UTF_8)) {
Expand All @@ -184,7 +185,7 @@ public void testFromGroovyToJSON() throws Exception {
@Test
public void testCalculateDescendantCount() throws Exception {
try (Reader reader = Files.newBufferedReader(Paths.get("src/test/resources/tree_resources.groovy"))) {
Resource resource = LoadGeneratorStarterArgs.evaluateGroovy(reader, Map.of());
Resource resource = LoadGeneratorStarterArgs.evaluateGroovy(reader, Collections.emptyMap());
Assert.assertEquals(17, resource.descendantCount());
}
}
Expand Down Expand Up @@ -223,7 +224,7 @@ public void testFullJSON() {

@Test
public void testStatsFile() throws Exception {
Path statsPath = Files.createTempFile(Path.of("target"), "jlg-stats-", ".json");
Path statsPath = Files.createTempFile(Paths.get("target"), "jlg-stats-", ".json");
statsPath.toFile().deleteOnExit();
String[] args = new String[]{
"--port",
Expand Down
46 changes: 38 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<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 https://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>org.mortbay.jetty.loadgenerator</groupId>
Expand Down Expand Up @@ -73,6 +73,16 @@
<artifactId>jetty-client</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-openjdk8-client</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-openjdk8-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-java-client</artifactId>
Expand Down Expand Up @@ -153,7 +163,7 @@
<configuration>
<rules>
<requireJavaVersion>
<version>[11,)</version>
<version>[1.8,)</version>
</requireJavaVersion>
<requireMavenVersion>
<version>[3.5,)</version>
Expand All @@ -166,9 +176,8 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
<release>11</release>
<source>8</source>
<target>8</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<compilerArgument>-Xlint:all,-serial,-unchecked</compilerArgument>
Expand Down Expand Up @@ -284,9 +293,6 @@
<version>3.2.0</version>
<configuration>
<source>8</source>
<additionalOptions>
<additionalOption>-html5</additionalOption>
</additionalOptions>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -356,6 +362,30 @@
</developers>

<profiles>
<profile>
<id>java9+</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>8</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalOptions>
<additionalOption>-html5</additionalOption>
</additionalOptions>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>
Expand Down

0 comments on commit af10b21

Please sign in to comment.