瀏覽代碼

Quarkus: remove unnecessary test (#8241)

* Quarkus: let's not enable io_uring support yet

* Quarkus: remove legacy configuration to help with testing times
Sanne Grinovero 2 年之前
父節點
當前提交
a09f4277e3
共有 23 個文件被更改,包括 21 次插入816 次删除
  1. 7 4
      frameworks/Java/quarkus/README.md
  2. 3 26
      frameworks/Java/quarkus/benchmark_config.json
  3. 3 20
      frameworks/Java/quarkus/config.toml
  4. 6 7
      frameworks/Java/quarkus/pom.xml
  5. 0 1
      frameworks/Java/quarkus/quarkus-hibernate-reactive.dockerfile
  6. 0 44
      frameworks/Java/quarkus/quarkus-resteasy-reactive-hibernate.dockerfile
  7. 2 3
      frameworks/Java/quarkus/quarkus.dockerfile
  8. 0 69
      frameworks/Java/quarkus/resteasy-hibernate/README.md
  9. 0 113
      frameworks/Java/quarkus/resteasy-hibernate/pom.xml
  10. 0 24
      frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/cdi/HibernateOrmNativeComponents.java
  11. 0 38
      frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/filter/ServerHeaderFilter.java
  12. 0 56
      frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/model/Fortune.java
  13. 0 29
      frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/model/World.java
  14. 0 31
      frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/repository/FortuneRepository.java
  15. 0 76
      frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/repository/WorldRepository.java
  16. 0 126
      frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/resource/DbResource.java
  17. 0 46
      frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/resource/FortuneResource.java
  18. 0 18
      frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/resource/JsonResource.java
  19. 0 13
      frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/resource/Message.java
  20. 0 17
      frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/resource/PlaintextResource.java
  21. 0 21
      frameworks/Java/quarkus/resteasy-hibernate/src/main/resources/Fortunes.rocker.html
  22. 0 33
      frameworks/Java/quarkus/resteasy-hibernate/src/main/resources/application.properties
  23. 0 1
      frameworks/Java/quarkus/resteasy-hibernate/src/main/resources/import.sql

+ 7 - 4
frameworks/Java/quarkus/README.md

@@ -4,11 +4,14 @@ This is the Quarkus portion of a [benchmarking test suite](../) comparing a vari
 
 
 ## Implementations
 ## Implementations
 
 
-There are currently 3 implementations:
+There are currently 2 implementations:
 
 
-- RESTEasy and Hibernate ORM
-- RESTEasy Reactive and Hibernate ORM
-- RESTEasy Reactive and Hibernate Reactive
+- Quarkus using RESTEasy Reactive and Hibernate ORM (classic Hibernate for DB operations, while handling web via the reactive stack)
+- Quarkus using RESTEasy Reactive and Hibernate Reactive (fully reactive stack)
+
+## Testing
+
+    ./tfb --mode verify --test quarkus quarkus-hibernate-reactive
 
 
 ## Versions
 ## Versions
 
 

+ 3 - 26
frameworks/Java/quarkus/benchmark_config.json

@@ -3,29 +3,6 @@
   "tests": [
   "tests": [
     {
     {
       "default": {
       "default": {
-        "json_url": "/json",
-        "db_url": "/db",
-        "query_url": "/queries?queries=",
-        "update_url": "/updates?queries=",
-        "fortune_url": "/fortunes",
-        "plaintext_url": "/plaintext",
-        "port": 8080,
-        "approach": "Realistic",
-        "classification": "fullstack",
-        "database": "Postgres",
-        "framework": "Quarkus",
-        "language": "Java",
-        "flavor": "None",
-        "orm": "Full",
-        "platform": "JAX-RS",
-        "webserver": "Vert.x",
-        "os": "Linux",
-        "database_os": "Linux",
-        "display_name": "quarkus [RESTEasy, Hibernate ORM]",
-        "notes": "",
-        "versus": "Netty"
-      },
-      "resteasy-reactive-hibernate": {
         "json_url": "/json",
         "json_url": "/json",
         "db_url": "/db",
         "db_url": "/db",
         "query_url": "/queries?queries=",
         "query_url": "/queries?queries=",
@@ -44,11 +21,11 @@
         "webserver": "Vert.x",
         "webserver": "Vert.x",
         "os": "Linux",
         "os": "Linux",
         "database_os": "Linux",
         "database_os": "Linux",
-        "display_name": "quarkus [RESTEasy Reactive, Hibernate ORM]",
+        "display_name": "Quarkus, Hibernate ORM",
         "notes": "",
         "notes": "",
         "versus": "Netty"
         "versus": "Netty"
       },
       },
-      "resteasy-reactive-hibernate-reactive": {
+      "hibernate-reactive": {
         "json_url": "/json",
         "json_url": "/json",
         "db_url": "/db",
         "db_url": "/db",
         "query_url": "/queries?queries=",
         "query_url": "/queries?queries=",
@@ -67,7 +44,7 @@
         "webserver": "Vert.x",
         "webserver": "Vert.x",
         "os": "Linux",
         "os": "Linux",
         "database_os": "Linux",
         "database_os": "Linux",
-        "display_name": "quarkus [RESTEasy Reactive, Hibernate Reactive]",
+        "display_name": "Quarkus, Hibernate Reactive",
         "notes": "",
         "notes": "",
         "versus": "Netty"
         "versus": "Netty"
       }
       }

+ 3 - 20
frameworks/Java/quarkus/config.toml

@@ -14,28 +14,11 @@ database = "Postgres"
 database_os = "Linux"
 database_os = "Linux"
 os = "Linux"
 os = "Linux"
 orm = "Full"
 orm = "Full"
-platform = "JAX-RS"
-webserver = "Undertow"
-versus = "Netty"
-
-[resteasy-reactive-hibernate]
-urls.plaintext = "/plaintext"
-urls.json = "/json"
-urls.db = "/db"
-urls.query = "/queries?queries="
-urls.update = "/updates?queries="
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "fullstack"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Full"
 platform = "RESTEasy Reactive"
 platform = "RESTEasy Reactive"
-webserver = "Vertx"
+webserver = "Vert.x"
 versus = "Netty"
 versus = "Netty"
 
 
-[resteasy-reactive-hibernate-reactive]
+[hibernate-reactive]
 urls.plaintext = "/plaintext"
 urls.plaintext = "/plaintext"
 urls.json = "/json"
 urls.json = "/json"
 urls.db = "/db"
 urls.db = "/db"
@@ -49,5 +32,5 @@ database_os = "Linux"
 os = "Linux"
 os = "Linux"
 orm = "Full"
 orm = "Full"
 platform = "RESTEasy Reactive"
 platform = "RESTEasy Reactive"
-webserver = "Vertx"
+webserver = "Vert.x"
 versus = "Netty"
 versus = "Netty"

+ 6 - 7
frameworks/Java/quarkus/pom.xml

@@ -22,10 +22,9 @@
     </properties>
     </properties>
 
 
     <modules>
     <modules>
-        <module>resteasy-hibernate</module>
+        <module>quarkus-benchmark-common</module>
         <module>resteasy-reactive-hibernate</module>
         <module>resteasy-reactive-hibernate</module>
         <module>resteasy-reactive-hibernate-reactive</module>
         <module>resteasy-reactive-hibernate-reactive</module>
-        <module>quarkus-benchmark-common</module>
     </modules>
     </modules>
 
 
     <dependencyManagement>
     <dependencyManagement>
@@ -121,12 +120,12 @@
             </properties>
             </properties>
         </profile>
         </profile>
         <profile>
         <profile>
-            <id>Linux</id>
+            <id>iouring</id>
             <activation>
             <activation>
-                <activeByDefault>false</activeByDefault>
-                <os>
-                    <family>unix</family>
-                </os>
+                <property>
+                    <!-- Not enabling this by default yet -->
+                    <name>iouring</name>
+                </property>
             </activation>
             </activation>
             <dependencies>
             <dependencies>
                 <dependency>
                 <dependency>

+ 0 - 1
frameworks/Java/quarkus/quarkus-resteasy-reactive-hibernate-reactive.dockerfile → frameworks/Java/quarkus/quarkus-hibernate-reactive.dockerfile

@@ -6,7 +6,6 @@ ENV MODULE=resteasy-reactive-hibernate-reactive
 
 
 COPY --chown=185 pom.xml pom.xml
 COPY --chown=185 pom.xml pom.xml
 COPY --chown=185 quarkus-benchmark-common quarkus-benchmark-common/
 COPY --chown=185 quarkus-benchmark-common quarkus-benchmark-common/
-COPY --chown=185 resteasy-hibernate resteasy-hibernate/
 COPY --chown=185 resteasy-reactive-hibernate resteasy-reactive-hibernate/
 COPY --chown=185 resteasy-reactive-hibernate resteasy-reactive-hibernate/
 COPY --chown=185 resteasy-reactive-hibernate-reactive resteasy-reactive-hibernate-reactive/
 COPY --chown=185 resteasy-reactive-hibernate-reactive resteasy-reactive-hibernate-reactive/
 
 

+ 0 - 44
frameworks/Java/quarkus/quarkus-resteasy-reactive-hibernate.dockerfile

@@ -1,44 +0,0 @@
-FROM registry.access.redhat.com/ubi8/openjdk-17:1.15 as maven
-ENV LANGUAGE='en_US:en'
-
-WORKDIR /quarkus
-ENV MODULE=resteasy-reactive-hibernate
-
-COPY --chown=185 pom.xml pom.xml
-COPY --chown=185 quarkus-benchmark-common quarkus-benchmark-common/
-COPY --chown=185 resteasy-hibernate resteasy-hibernate/
-COPY --chown=185 resteasy-reactive-hibernate resteasy-reactive-hibernate/
-COPY --chown=185 resteasy-reactive-hibernate-reactive resteasy-reactive-hibernate-reactive/
-
-# Uncomment to test pre-release quarkus
-#RUN mkdir -p /root/.m2/repository/io
-#COPY m2-quarkus /root/.m2/repository/io/quarkus
-
-USER 185
-WORKDIR /quarkus
-RUN mvn -DskipTests install -pl :benchmark,:quarkus-benchmark-common -B -q
-
-WORKDIR /quarkus/$MODULE
-RUN mvn dependency:go-offline -B -q
-WORKDIR /quarkus
-
-COPY $MODULE/src $MODULE/src
-
-WORKDIR /quarkus/$MODULE
-RUN mvn package -B -q
-WORKDIR /quarkus
-
-FROM registry.access.redhat.com/ubi8/openjdk-17-runtime:1.15
-ENV LANGUAGE='en_US:en'
-WORKDIR /quarkus
-ENV MODULE=resteasy-reactive-hibernate
-
-COPY --chown=185 --from=maven /quarkus/$MODULE/target/quarkus-app/lib/ lib
-COPY --chown=185 --from=maven /quarkus/$MODULE/target/quarkus-app/app/ app
-COPY --chown=185 --from=maven /quarkus/$MODULE/target/quarkus-app/quarkus/ quarkus
-COPY --chown=185 --from=maven /quarkus/$MODULE/target/quarkus-app/quarkus-run.jar quarkus-run.jar
-COPY --chown=185 run_quarkus.sh run_quarkus.sh
-
-EXPOSE 8080
-USER 185
-ENTRYPOINT "./run_quarkus.sh"

+ 2 - 3
frameworks/Java/quarkus/quarkus.dockerfile

@@ -2,11 +2,10 @@ FROM registry.access.redhat.com/ubi8/openjdk-17:1.15 as maven
 ENV LANGUAGE='en_US:en'
 ENV LANGUAGE='en_US:en'
 
 
 WORKDIR /quarkus
 WORKDIR /quarkus
-ENV MODULE=resteasy-hibernate
+ENV MODULE=resteasy-reactive-hibernate
 
 
 COPY --chown=185 pom.xml pom.xml
 COPY --chown=185 pom.xml pom.xml
 COPY --chown=185 quarkus-benchmark-common quarkus-benchmark-common/
 COPY --chown=185 quarkus-benchmark-common quarkus-benchmark-common/
-COPY --chown=185 resteasy-hibernate resteasy-hibernate/
 COPY --chown=185 resteasy-reactive-hibernate resteasy-reactive-hibernate/
 COPY --chown=185 resteasy-reactive-hibernate resteasy-reactive-hibernate/
 COPY --chown=185 resteasy-reactive-hibernate-reactive resteasy-reactive-hibernate-reactive/
 COPY --chown=185 resteasy-reactive-hibernate-reactive resteasy-reactive-hibernate-reactive/
 
 
@@ -31,7 +30,7 @@ WORKDIR /quarkus
 FROM registry.access.redhat.com/ubi8/openjdk-17-runtime:1.15
 FROM registry.access.redhat.com/ubi8/openjdk-17-runtime:1.15
 ENV LANGUAGE='en_US:en'
 ENV LANGUAGE='en_US:en'
 WORKDIR /quarkus
 WORKDIR /quarkus
-ENV MODULE=resteasy-hibernate
+ENV MODULE=resteasy-reactive-hibernate
 
 
 COPY --chown=185 --from=maven /quarkus/$MODULE/target/quarkus-app/lib/ lib
 COPY --chown=185 --from=maven /quarkus/$MODULE/target/quarkus-app/lib/ lib
 COPY --chown=185 --from=maven /quarkus/$MODULE/target/quarkus-app/app/ app
 COPY --chown=185 --from=maven /quarkus/$MODULE/target/quarkus-app/app/ app

+ 0 - 69
frameworks/Java/quarkus/resteasy-hibernate/README.md

@@ -1,69 +0,0 @@
-# Local development
-
-During development it might be easier to start a PostgreSQL instance directly:
-
-    sudo podman run --ulimit memlock=-1:-1 -it --rm=true --network host --memory-swappiness=0 --name HibernateTestingPGSQL -e POSTGRES_USER=benchmarkdbuser -e POSTGRES_PASSWORD=benchmarkdbpass -e POSTGRES_DB=hello_world -p 5432:5432 postgres:12
-
-Then edit the `application.properties` resource, so to point to the database on localhost.
-
-On first run make sure you set Hibernate to create the schema:
-
-    quarkus.hibernate-orm.database.generation=drop-and-create
-
-Build the application (might need to have installed the parent and dependencies first):
-
-    mvn clean package
-
-Run the application
-
-    ./start-app.sh
-
-If you just created the DB schema, you will need to create the test data. Hit this endpoint once:
-
-    http://127.0.0.1:8080/createdata
-
-Generate load on the application to test / profile it. I suggest to use `https://github.com/giltene/wrk2`.
-
-Example run, assuming you have built wrk2 in `~/sources/wrk2` :
-
-     ~/sources/wrk2/wrk -c 100 -d 60 -R 400 http://localhost:8080/db
-
-The URL `http://localhost:8080/db` represents one specific benchmark; there are several more to try
-but you will likely want to focus on them one at a time.
-
-
-## Test URLs
-
-### Plaintext Test
-
-    http://localhost:8080/plaintext
-
-### JSON Encoding Test
-
-    http://localhost:8080/json
-
-### Database Query Test
-
-    http://localhost:8080/db
-
-### Database Queries Test
-
-    http://localhost:8080/queries?queries=5
-
-### Database Update Test
-
-    http://localhost:8080/updates?queries=5
-
-### Template rendering Test
-
-    http://localhost:8080/fortunes
-
-## Full verification
-
-Use the main Techempower script in the root to run all official verifications:
-
-./tfb --type all --mode verify --test quarkus-hibernate
-
-## Run the benchmark
-
-./tfb --type all --mode benchmark --test quarkus-hibernate

+ 0 - 113
frameworks/Java/quarkus/resteasy-hibernate/pom.xml

@@ -1,113 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project>
-    <modelVersion>4.0.0</modelVersion>
-
-    <parent>
-        <groupId>io.quarkus</groupId>
-        <artifactId>benchmark</artifactId>
-        <version>1.0-SNAPSHOT</version>
-    </parent>
-
-    <groupId>io.quarkus.benchmark</groupId>
-    <artifactId>resteasy-hibernate</artifactId>
-
-    <dependencies>
-        <dependency>
-            <groupId>io.quarkus</groupId>
-            <artifactId>quarkus-benchmark-common</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>io.quarkus</groupId>
-            <artifactId>quarkus-hibernate-orm</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>io.quarkus</groupId>
-            <artifactId>quarkus-scheduler</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>io.quarkus</groupId>
-            <artifactId>quarkus-resteasy</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>io.quarkus</groupId>
-            <artifactId>quarkus-resteasy-jackson</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>io.quarkus</groupId>
-            <artifactId>quarkus-jdbc-postgresql</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.fizzed</groupId>
-            <artifactId>rocker-compiler</artifactId>
-            <version>1.3.0</version>
-        </dependency>
-        <dependency>
-            <groupId>io.netty</groupId>
-            <artifactId>netty-transport-native-epoll</artifactId>
-            <classifier>linux-x86_64</classifier>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>com.fizzed</groupId>
-                <artifactId>rocker-maven-plugin</artifactId>
-                <version>1.3.0</version>
-                <executions>
-                    <execution>
-                        <id>generate-rocker-templates</id>
-                        <phase>generate-sources</phase>
-                        <goals>
-                            <goal>generate</goal>
-                        </goals>
-                        <configuration>
-                            <templateDirectory>${project.basedir}/src/main/resources</templateDirectory>
-                            <optimize>true</optimize>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-
-    </build>
-
-    <profiles>
-        <profile>
-            <!-- Optionally activate this profile to compile to native! -->
-            <id>native</id>
-            <activation>
-                <property>
-                    <name>native</name>
-                </property>
-            </activation>
-            <properties>
-                <quarkus.package.type>native</quarkus.package.type>
-            </properties>
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-failsafe-plugin</artifactId>
-                        <version>${surefire-plugin.version}</version>
-                        <executions>
-                            <execution>
-                                <goals>
-                                    <goal>integration-test</goal>
-                                    <goal>verify</goal>
-                                </goals>
-                                <configuration>
-                                    <systemPropertyVariables>
-                                        <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
-                                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
-                                        <maven.home>${maven.home}</maven.home>
-                                    </systemPropertyVariables>
-                                </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
-    </profiles>
-</project>

+ 0 - 24
frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/cdi/HibernateOrmNativeComponents.java

@@ -1,24 +0,0 @@
-package io.quarkus.benchmark.cdi;
-
-import jakarta.enterprise.inject.Produces;
-import jakarta.enterprise.inject.Typed;
-import jakarta.inject.Singleton;
-import jakarta.persistence.EntityManagerFactory;
-import jakarta.persistence.PersistenceUnit;
-
-import org.hibernate.SessionFactory;
-
-@Singleton
-public class HibernateOrmNativeComponents {
-
-	@PersistenceUnit
-	EntityManagerFactory entityManagerFactory;
-
-	@Singleton
-	@Typed(SessionFactory.class)
-	@Produces
-	SessionFactory extractSessionFactory() {
-		return entityManagerFactory.unwrap( SessionFactory.class );
-	}
-
-}

+ 0 - 38
frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/filter/ServerHeaderFilter.java

@@ -1,38 +0,0 @@
-package io.quarkus.benchmark.filter;
-
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-
-import jakarta.annotation.PostConstruct;
-import jakarta.inject.Singleton;
-import jakarta.ws.rs.container.ContainerRequestContext;
-import jakarta.ws.rs.container.ContainerResponseContext;
-import jakarta.ws.rs.container.ContainerResponseFilter;
-import jakarta.ws.rs.core.MultivaluedMap;
-import jakarta.ws.rs.ext.Provider;
-
-import io.quarkus.scheduler.Scheduled;
-
-@Singleton
-@Provider
-public class ServerHeaderFilter implements ContainerResponseFilter {
-
-    private volatile String date;
-
-    @PostConstruct
-    public void init() {
-        date = DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now());
-    }
-
-    @Scheduled(every="1s")
-    void increment() {
-        date = DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now());
-    }
-
-    @Override
-    public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) {
-        final MultivaluedMap<String, Object> headers = responseContext.getHeaders();
-        headers.add( "Server", "Quarkus");
-        headers.add( "Date", date);
-    }
-}

+ 0 - 56
frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/model/Fortune.java

@@ -1,56 +0,0 @@
-package io.quarkus.benchmark.model;
-
-import org.hibernate.annotations.Immutable;
-
-import java.util.Objects;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-
-@Entity
-@Immutable
-public class Fortune {
-
-    @Id
-    private int id;
-    private String message;
-
-    public Fortune() {}
-
-    public Fortune(int id, String message) {
-        this.id = id;
-        this.message = message;
-    }
-
-    public int getId() {
-        return id;
-    }
-
-    public void setId(int id) {
-        this.id = id;
-    }
-
-    public String getMessage() {
-        return message;
-    }
-
-    public void setMessage(String message) {
-        this.message = message;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o)
-            return true;
-        if (o == null || getClass() != o.getClass())
-            return false;
-        Fortune fortune = (Fortune) o;
-        return id == fortune.id &&
-                Objects.equals(message, fortune.message);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(id, message);
-    }
-}

+ 0 - 29
frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/model/World.java

@@ -1,29 +0,0 @@
-package io.quarkus.benchmark.model;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-
-@Entity
-public class World {
-
-    @Id
-    private int id;
-    private int randomNumber;
-
-    public int getId() {
-        return id;
-    }
-
-    public void setId(int id) {
-        this.id = id;
-    }
-
-    public int getRandomNumber() {
-        return randomNumber;
-    }
-
-    public void setRandomNumber(int randomNumber) {
-        this.randomNumber = randomNumber;
-    }
-
-}

+ 0 - 31
frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/repository/FortuneRepository.java

@@ -1,31 +0,0 @@
-package io.quarkus.benchmark.repository;
-
-import java.util.List;
-
-import jakarta.inject.Inject;
-import jakarta.inject.Singleton;
-import jakarta.persistence.criteria.CriteriaBuilder;
-import jakarta.persistence.criteria.CriteriaQuery;
-import jakarta.persistence.criteria.Root;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.StatelessSession;
-
-import io.quarkus.benchmark.model.Fortune;
-
-@Singleton
-public class FortuneRepository {
-
-    @Inject
-    SessionFactory sf;
-
-    public List<Fortune> findAllStateless() {
-        try (StatelessSession s = sf.openStatelessSession()) {
-            CriteriaBuilder criteriaBuilder = sf.getCriteriaBuilder();
-            CriteriaQuery<Fortune> fortuneQuery = criteriaBuilder.createQuery(Fortune.class);
-            Root<Fortune> from = fortuneQuery.from(Fortune.class);
-            fortuneQuery.select(from);
-            return s.createQuery(fortuneQuery).getResultList();
-        }
-    }
-}

+ 0 - 76
frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/repository/WorldRepository.java

@@ -1,76 +0,0 @@
-package io.quarkus.benchmark.repository;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Set;
-import java.util.concurrent.ThreadLocalRandom;
-
-import jakarta.inject.Inject;
-import jakarta.inject.Singleton;
-import jakarta.transaction.Transactional;
-
-import org.hibernate.FlushMode;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.StatelessSession;
-
-import io.quarkus.benchmark.model.World;
-
-
-@Singleton
-public class WorldRepository {
-
-    @Inject
-    SessionFactory sf;
-
-    /**
-     * This method is not required (nor specified) by the benchmark rules,
-     * but is quite handy to seed a local database and be able to experiment
-     * with the app locally.
-     */
-    @Transactional
-    public void createData() {
-        try (StatelessSession statelessSession = sf.openStatelessSession()) {
-            final ThreadLocalRandom random = ThreadLocalRandom.current();
-            for (int i=1; i<=10000; i++) {
-                final World world = new World();
-                world.setId(i);
-                world.setRandomNumber(1 + random.nextInt(10000));
-                statelessSession.insert(world);
-            }
-        }
-    }
-
-    public World findSingleAndStateless(int id) {
-        try (StatelessSession ss = sf.openStatelessSession()) {
-            return singleStatelessWorldLoad(ss,id);
-        }
-    }
-
-    public void updateAll(Collection<World> worlds) {
-        try (Session s = sf.openSession()) {
-            s.setJdbcBatchSize(worlds.size());
-            s.setHibernateFlushMode(FlushMode.MANUAL);
-            for (World w : worlds) {
-                s.update(w);
-            }
-            s.flush();
-        }
-    }
-
-    public Collection<World> findReadonly(Set<Integer> ids) {
-        try (StatelessSession s = sf.openStatelessSession()) {
-            //The rules require individual load: we can't use the Hibernate feature which allows load by multiple IDs as one single operation
-            ArrayList l = new ArrayList<>(ids.size());
-            for (Integer id : ids) {
-                l.add(singleStatelessWorldLoad(s,id));
-            }
-            return l;
-        }
-    }
-
-    private static World singleStatelessWorldLoad(final StatelessSession ss, final Integer id) {
-        return (World) ss.get(World.class, id);
-    }
-
-}

+ 0 - 126
frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/resource/DbResource.java

@@ -1,126 +0,0 @@
-package io.quarkus.benchmark.resource;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.ThreadLocalRandom;
-
-import jakarta.inject.Inject;
-import jakarta.inject.Singleton;
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.core.MediaType;
-
-import io.quarkus.benchmark.model.World;
-import io.quarkus.benchmark.repository.WorldRepository;
-
-
-@Singleton
-@Path("/")
-@Produces(MediaType.APPLICATION_JSON)
-@Consumes(MediaType.APPLICATION_JSON)
-public class DbResource {
-
-    @Inject
-    WorldRepository worldRepository;
-
-    @GET
-    @Path("/db")
-    public World db() {
-        return worldRepository.findSingleAndStateless(randomWorldNumber());
-    }
-
-    @GET
-    @Path("/queries")
-    public World[] queries(@QueryParam("queries") String queries) {
-        final int count = parseQueryCount(queries);
-        World[] worlds = randomWorldForRead(count).toArray(new World[0]);
-        return worlds;
-    }
-
-    @GET
-    @Path("/updates")
-    //Rules: https://github.com/TechEmpower/FrameworkBenchmarks/wiki/Project-Information-Framework-Tests-Overview#database-updates
-    //N.B. the benchmark seems to be designed to get in deadlocks when using a "safe pattern" of updating
-    // the entity within the same transaction as the one which read it.
-    // We therefore need to do a "read then write" while relinquishing the transaction between the two operations, as
-    // all other tested frameworks seem to do.
-    public World[] updates(@QueryParam("queries") String queries) {
-        final int count = parseQueryCount(queries);
-        final Collection<World> worlds = randomWorldForRead(count);
-        worlds.forEach( w -> {
-            //Read the one field, as required by the following rule:
-            // # vi. At least the randomNumber field must be read from the database result set.
-            final int previousRead = w.getRandomNumber();
-            //Update it, but make sure to exclude the current number as Hibernate optimisations would have us "fail"
-            //the verification:
-            w.setRandomNumber(randomWorldNumber(previousRead));
-        } );
-        worldRepository.updateAll(worlds);
-        return worlds.toArray(new World[0]);
-    }
-
-    @GET
-    @Path( "/createdata" )
-    public String createData() {
-        worldRepository.createData();
-        return "OK";
-    }
-
-    private Collection<World> randomWorldForRead(int count) {
-        Set<Integer> ids = new HashSet<>(count);
-        int counter = 0;
-        while (counter < count) {
-            counter += ids.add(Integer.valueOf(randomWorldNumber())) ? 1 : 0;
-        }
-        return worldRepository.findReadonly(ids);
-    }
-
-    /**
-     * According to benchmark requirements
-     * @return returns a number from 1 to 10000
-     */
-    private int randomWorldNumber() {
-        return 1 + ThreadLocalRandom.current().nextInt(10000);
-    }
-
-
-    /**
-     * Also according to benchmark requirements, except that in this special case
-     * of the update test we need to ensure we'll actually generate an update operation:
-     * for this we need to generate a random number between 1 to 10000, but different
-     * from the current field value.
-     * @param previousRead
-     * @return
-     */
-    private int randomWorldNumber(final int previousRead) {
-        //conceptually split the random space in those before previousRead,
-        //and those after: this approach makes sure to not affect the random characteristics.
-        final int trueRandom = ThreadLocalRandom.current().nextInt(9999) + 2;
-        if (trueRandom<=previousRead) {
-            //all figures equal or before the current field read need to be shifted back by one
-            //so to avoid hitting the same number while not affecting the distribution.
-            return trueRandom - 1;
-        }
-        else {
-            //Those after are generated by taking the generated value 2...10000 as is.
-            return trueRandom;
-        }
-    }
-
-    private int parseQueryCount(String textValue) {
-        if (textValue == null) {
-            return 1;
-        }
-        int parsedValue;
-        try {
-            parsedValue = Integer.parseInt(textValue);
-        } catch (NumberFormatException e) {
-            return 1;
-        }
-        return Math.min(500, Math.max(1, parsedValue));
-    }
-}

+ 0 - 46
frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/resource/FortuneResource.java

@@ -1,46 +0,0 @@
-package io.quarkus.benchmark.resource;
-
-import com.fizzed.rocker.Rocker;
-import com.fizzed.rocker.RockerOutput;
-import io.quarkus.benchmark.model.Fortune;
-import io.quarkus.benchmark.repository.FortuneRepository;
-
-import jakarta.inject.Inject;
-import jakarta.inject.Singleton;
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-@Singleton
-@Path("/")
-@Produces(MediaType.TEXT_HTML + "; charset=UTF-8")
-@Consumes(MediaType.APPLICATION_JSON)
-public class FortuneResource {
-
-    @Inject
-    FortuneRepository repository;
-
-    private static final String FORTUNES_MAP_KEY = "fortunes";
-    private static final String FORTUNES_TEMPLATE_FILENAME = "Fortunes.rocker.html";
-    private static final Comparator<Fortune> fortuneComparator = Comparator.comparing(fortune -> fortune.getMessage());
-
-    @GET
-    @Path("/fortunes")
-    public String fortunes() {
-        List<Fortune> fortunes = new ArrayList<>(repository.findAllStateless());
-        fortunes.add(new Fortune(0, "Additional fortune added at request time."));
-        fortunes.sort(fortuneComparator);
-
-        RockerOutput output = Rocker.template(FORTUNES_TEMPLATE_FILENAME)
-                .bind(Collections.singletonMap(FORTUNES_MAP_KEY, fortunes))
-                .render();
-
-        return output.toString();
-    }
-}

+ 0 - 18
frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/resource/JsonResource.java

@@ -1,18 +0,0 @@
-package io.quarkus.benchmark.resource;
-
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-
-@Path("/json")
-public class JsonResource {
-    private static final String HELLO = "Hello, World!";
-
-    @GET
-    @Produces(MediaType.APPLICATION_JSON)
-    public Message json() {
-        return new Message(HELLO);
-    }
-}
-

+ 0 - 13
frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/resource/Message.java

@@ -1,13 +0,0 @@
-package io.quarkus.benchmark.resource;
-
-public class Message {
-  private final String message;
-
-  public Message(String message) {
-    this.message = message;
-  }
-
-  public String getMessage() {
-    return message;
-  }
-}

+ 0 - 17
frameworks/Java/quarkus/resteasy-hibernate/src/main/java/io/quarkus/benchmark/resource/PlaintextResource.java

@@ -1,17 +0,0 @@
-package io.quarkus.benchmark.resource;
-
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.MediaType;
-
-@Path("/plaintext")
-public class PlaintextResource {
-    private static final String HELLO = "Hello, World!";
-
-    @GET
-    @Produces(MediaType.TEXT_PLAIN)
-    public String plaintext() {
-        return HELLO;
-    }
-}

+ 0 - 21
frameworks/Java/quarkus/resteasy-hibernate/src/main/resources/Fortunes.rocker.html

@@ -1,21 +0,0 @@
-@import java.util.*
-@import io.quarkus.benchmark.model.*
-@args(List fortunes)
-<!DOCTYPE html>
-<html>
-<head><title>Fortunes</title></head>
-<body>
-<table>
-    <tr>
-        <th>id</th>
-        <th>message</th>
-    </tr>
-    @for ((ForIterator i, Fortune fortune) : fortunes) {
-    <tr>
-        <td>@fortune.getId()</td>
-        <td>@fortune.getMessage()</td>
-    </tr>
-    }
-</table>
-</body>
-</html>

+ 0 - 33
frameworks/Java/quarkus/resteasy-hibernate/src/main/resources/application.properties

@@ -1,33 +0,0 @@
-#Test preferQueryMode ? sendBufferSize ? receiveBufferSize ?
-#disableColumnSanitiser requires lower case column names
-quarkus.datasource.db-kind=postgresql
-quarkus.datasource.username=benchmarkdbuser
-quarkus.datasource.password=benchmarkdbpass
-quarkus.datasource.jdbc.url=jdbc:postgresql://tfb-database:5432/hello_world?loggerLevel=OFF&disableColumnSanitiser=true&assumeMinServerVersion=12&sslmode=disable
-%dev.quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/hello_world?loggerLevel=OFF&disableColumnSanitiser=true&assumeMinServerVersion=12&sslmode=disable
-quarkus.datasource.jdbc.driver=org.postgresql.Driver
-quarkus.datasource.jdbc.transactions=disabled
-quarkus.datasource.jdbc.detect-statement-leaks=false
-quarkus.datasource.jdbc.max-size=512
-quarkus.datasource.jdbc.min-size=16
-quarkus.datasource.jdbc.initial-size=512
-
-quarkus.log.console.enable=true
-quarkus.log.console.level=INFO
-quarkus.log.file.enable=false
-quarkus.log.level=INFO
-
-# Fully disable Hibernate ORM statistics gathering::
-quarkus.log.category."org.hibernate.engine.internal.StatisticalLoggingSessionEventListener".level=WARN
-
-# Explicitly disable 2LC as it's not used:
-quarkus.hibernate-orm.second-level-caching-enabled=false
-
-# To create the schema:
-%dev.quarkus.hibernate-orm.database.generation=drop-and-create
-%dev.quarkus.hibernate-orm.sql-load-script=import.sql
-quarkus.hibernate-orm.database.generation=validate
-quarkus.hibernate-orm.log.sql=false
-
-
-

+ 0 - 1
frameworks/Java/quarkus/resteasy-hibernate/src/main/resources/import.sql

@@ -1 +0,0 @@
-INSERT INTO Fortune(id, message) VALUES (1, 'Test value One');