Răsfoiți Sursa

add edap-http framework (#6160)

* 初始化edap-http-benchmark的项目

* 修改pom文件以及测试的配置

* 修改端口号,jdk版本以及去掉有问题的plaintext的测试项

* 修改Message启动时初始化为每次请求生成新的对象

* 去掉多余的"s"字符

* 增加plaintext的测试配置

* add edap-http framwork

Co-authored-by: louis <[email protected]>
luyongshou 4 ani în urmă
părinte
comite
875969eab3

+ 1 - 1
.travis.yml

@@ -48,7 +48,7 @@ env:
     - "TESTDIR=Haskell/warp"
     - "TESTDIR=Haskell/wizzardo-inline"
     - "TESTDIR=Haskell/postgrest"
-    - 'TESTDIR="Java/act Java/comsat"'
+    - 'TESTDIR="Java/act Java/comsat Java/edap-http"'
     - 'TESTDIR="Java/activeweb Java/armeria Java/baratine Java/bayou Java/blade Java/curacao Java/dropwizard Java/firenio Java/servicetalk Java/voovan"'
     - 'TESTDIR="Java/gemini Java/greenlightning Java/grizzly Java/helidon Java/httpserver Java/jetty Java/jlhttp Java/jooby Java/wicket"'
     - 'TESTDIR="Java/light-java Java/minijax Java/nanohttpd Java/netty Java/ninja-standalone Java/officefloor Java/proteus Java/quarkus"'

+ 23 - 0
frameworks/Java/edap-http/README.md

@@ -0,0 +1,23 @@
+# edap-http Benchmarking Test
+
+
+This is the edap-http portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
+
+### JSON Encoding Test
+* [JSON test source](src/main/java/io/edap/http/HttpBootstrap.java)
+* [Plaintext test source](src/main/java/io/edap/http/HttpBootstrap.java)
+
+## Versions
+
+* [Java OpenJDK 11](http://openjdk.java.net/)
+* [edap-http_0.1](https://github.com/edap-io/edap)
+
+## Test URLs
+
+### JSON Encoding Test
+
+    http://localhost:8080/json
+    
+### Plaintext Encoding Test
+
+    http://localhost:8080/plaintext

+ 26 - 0
frameworks/Java/edap-http/benchmark_config.json

@@ -0,0 +1,26 @@
+{
+  "framework": "edap-http",
+  "tests": [
+    {
+      "default": {
+        "plaintext_url": "/plaintext",
+        "json_url": "/json",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Platform",
+        "database": "Postgres",
+        "framework": "None",
+        "language": "Java",
+        "flavor": "None",
+        "orm": "Raw",
+        "platform": "edap",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "edap-http",
+        "notes": "",
+        "versus": "edap-http"
+      }
+    }
+  ]
+}

+ 10 - 0
frameworks/Java/edap-http/edap-http.dockerfile

@@ -0,0 +1,10 @@
+FROM maven:3.6.3-openjdk-8-slim as maven
+WORKDIR /edap-http
+COPY pom.xml pom.xml
+COPY src src
+RUN mvn compile assembly:single -q
+
+FROM openjdk:8u275-jdk-slim
+WORKDIR /edap-http
+COPY --from=maven /edap-http/target/edap-http-benchmark-1.0-SNAPSHOT-jar-with-dependencies.jar app.jar
+CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AggressiveOpts", "-cp", "app.jar", "io.edap.http.Bootstrap"]

+ 96 - 0
frameworks/Java/edap-http/pom.xml

@@ -0,0 +1,96 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>io.edap</groupId>
+    <artifactId>edap-http-benchmark</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <java.version>8</java.version>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <maven.compiler.compilerVersion>8</maven.compiler.compilerVersion>
+        <edap.version>0.1-SNAPSHOT</edap.version>
+        <edap.name>edapx</edap.name>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>io.edap</groupId>
+            <artifactId>${edap.name}-http</artifactId>
+            <version>${edap.version}</version>
+        </dependency>
+    </dependencies>
+
+    <repositories>
+        <repository>
+            <id>central</id>
+            <name>Central Repository</name>
+            <url>https://repo.maven.apache.org/maven2</url>
+        </repository>
+        <repository>
+            <id>sonatype-nexus-snapshots</id>
+            <name>Sonatype Nexus Snapshots</name>
+            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+        </repository>
+    </repositories>
+    <pluginRepositories>
+        <pluginRepository>
+            <id>central</id>
+            <name>Central Repository</name>
+            <url>https://repo.maven.apache.org/maven2</url>
+        </pluginRepository>
+        <pluginRepository>
+            <id>sonatype-nexus-snapshots</id>
+            <name>Sonatype Nexus Snapshots</name>
+            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+            <releases>
+                <enabled>false</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </pluginRepository>
+    </pluginRepositories>
+    <build>
+        <plugins>
+
+            <plugin>
+                <inherited>true</inherited>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.0</version>
+                <configuration>
+                    <debug>false</debug>
+                    <source>8</source>
+                    <target>8</target>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>3.1.0</version>
+                <configuration>
+                    <descriptorRefs>
+                        <descriptorRef>jar-with-dependencies</descriptorRef>
+                    </descriptorRefs>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>make-assembly</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
+        </plugins>
+    </build>
+</project>

+ 26 - 0
frameworks/Java/edap-http/src/main/java/io/edap/http/Bootstrap.java

@@ -0,0 +1,26 @@
+package io.edap.http;
+
+import io.edap.http.model.Message;
+import io.edap.x.Edap;
+import io.edap.x.http.HttpServer;
+import io.edap.x.http.HttpServerBuilder;
+
+import java.io.IOException;
+
+import static io.edap.x.http.header.ContentType.JSON;
+import static io.edap.x.http.header.ContentType.PLAIN;
+
+public class Bootstrap {
+
+    public static void main(String[] args) throws IOException {
+
+        HttpServer httpServer = new HttpServerBuilder()
+                .listen(8080)
+                .req("/plaintext", (req, resp) -> resp.contentType(PLAIN).write("Hello, World!"))
+                .get("/json", (req, resp) -> resp.contentType(JSON).write(new Message("Hello, World!")))
+                .build();
+        Edap edap = new Edap();
+        edap.addServer(httpServer);
+        edap.run();
+    }
+}

+ 18 - 0
frameworks/Java/edap-http/src/main/java/io/edap/http/model/Message.java

@@ -0,0 +1,18 @@
+package io.edap.http.model;
+
+public class Message {
+    private String message;
+
+
+    public Message(String message) {
+        this.message = message;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+}