Browse Source

add voovan framework to tfb (#4392)

* add voovan framework to tfb

* update .travis.yml

.travis.yml with voovan framework

* fix web server listen on 127.0.0.1

* Update VoovanTFB.java

* Update VoovanTFB.java

* Update voovan.dockerfile

* Update VoovanTFB.java

* Update voovan.dockerfile

* Update framework.properties

* Update voovan.dockerfile

* Update voovan.dockerfile

* Update framework.properties

* Update VoovanTFB.java
hely ho 6 years ago
parent
commit
e8523858cb

+ 1 - 0
.travis.yml

@@ -84,6 +84,7 @@ env:
      - "TESTDIR=Java/undertow"
      - "TESTDIR=Java/undertow"
      - "TESTDIR=Java/undertow-jersey"
      - "TESTDIR=Java/undertow-jersey"
      - "TESTDIR=Java/vertx"
      - "TESTDIR=Java/vertx"
+     - "TESTDIR=Java/voovan"
      - "TESTDIR=Java/vertx-web"
      - "TESTDIR=Java/vertx-web"
      - "TESTDIR=Java/wicket"
      - "TESTDIR=Java/wicket"
      - "TESTDIR=Java/wildfly-ee"
      - "TESTDIR=Java/wildfly-ee"

+ 19 - 0
frameworks/Java/voovan/README.md

@@ -0,0 +1,19 @@
+# voovan Benchmarking Test
+
+
+This is the voovan portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
+
+## Versions
+
+* [Java OpenJDK 1.8](http://openjdk.java.net/)
+* [Voovan 4.0.0](https://gitee.com/helyho/Voovan)
+
+## Test URLs
+
+### JSON Encoding Test
+
+    http://localhost:8080/json
+    
+### Plaintext Encoding Test
+
+    http://localhost:8080/plaintext

+ 24 - 0
frameworks/Java/voovan/benchmark_config.json

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

+ 26 - 0
frameworks/Java/voovan/config/framework.properties

@@ -0,0 +1,26 @@
+#if it set true, framework will free noheapmemory immediately,  default is true
+NoHeapManualRelease=true
+
+#when jvm nohup object is recycle, every this interval whill release nohup memory, default is 30
+NoHeapReleaseInterval = 30
+
+#one cpu core's min thread size,  default is 2
+ThreadPoolMinSize= 2
+
+#one cpu core's max thread size,  default is 50
+ThreadPoolMaxSize= 2
+
+#thread pool status log output interval, ,  default is 1000
+ThreadPoolStatusInterval = 3000
+
+#ByteBufferChannel max size, unit byte, default is 1024*1024*2
+ByteBufferChannelMaxSize = 20971520
+
+#Cache used serialize method , chose with: JDK or JSON, default is jdk
+SerializeType = JDK
+
+#if set this argument is true, Convernt escape char in JSON, like: \f \b \r \n \t to unicode for browser parse the json, default is true
+JSONConvertEscapeChar = true;
+
+#the host where is the remote class source locations
+#RemoteClassSource=127.0.0.1:3001

+ 55 - 0
frameworks/Java/voovan/pom.xml

@@ -0,0 +1,55 @@
+<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>com.techempower</groupId>
+    <artifactId>voovan-bench</artifactId>
+    <version>0.1</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+        <main.class>org.voovan.VoovanTFB</main.class>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.voovan</groupId>
+            <artifactId>voovan-framework</artifactId>
+            <version>4.0.6</version>
+        </dependency>
+    </dependencies>
+    <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>
+                </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/voovan/src/main/java/framework.properties

@@ -0,0 +1,26 @@
+#if it set true, framework will free noheapmemory immediately,  default is true
+NoHeapManualRelease=true
+
+#when jvm nohup object is recycle, every this interval whill release nohup memory, default is 30
+NoHeapReleaseInterval = 30
+
+#one cpu core's min thread size,  default is 2
+ThreadPoolMinSize= 5
+
+#one cpu core's max thread size,  default is 50
+ThreadPoolMaxSize= 100
+
+#thread pool status log output interval, ,  default is 1000
+ThreadPoolStatusInterval = 3000
+
+#ByteBufferChannel max size, unit byte, default is 1024*1024*2
+ByteBufferChannelMaxSize = 20971520
+
+#Cache used serialize method , chose with: JDK or JSON, default is jdk
+SerializeType = JDK
+
+#if set this argument is true, Convernt escape char in JSON, like: \f \b \r \n \t to unicode for browser parse the json, default is true
+JSONConvertEscapeChar = true;
+
+#the host where is the remote class source locations
+#RemoteClassSource=127.0.0.1:3001

+ 49 - 0
frameworks/Java/voovan/src/main/java/org/voovan/VoovanTFB.java

@@ -0,0 +1,49 @@
+package org.voovan;
+
+import org.voovan.http.message.HttpStatic;
+import org.voovan.http.server.HttpRequest;
+import org.voovan.http.server.HttpResponse;
+import org.voovan.http.server.HttpRouter;
+import org.voovan.http.server.WebServer;
+import org.voovan.http.server.context.WebContext;
+import org.voovan.http.server.context.WebServerConfig;
+import org.voovan.tools.TObject;
+import org.voovan.tools.json.JSON;
+import org.voovan.tools.log.Logger;
+
+
+public class VoovanTFB {
+    private static final byte[] HELLO_WORLD = "Hello, World!".getBytes();
+
+    public static void main(String[] args) {
+        WebServerConfig webServerConfig = WebContext.getWebServerConfig();
+	webServerConfig.setGzip(false);
+	webServerConfig.setAccessLog(false);
+	webServerConfig.setKeepAliveTimeout(20000);
+	webServerConfig.setHost("0.0.0.0");
+	webServerConfig.setPort(8080);
+	webServerConfig.getModuleonfigs().clear();
+	webServerConfig.getRouterConfigs().clear();
+        WebServer webServer = WebServer.newInstance(webServerConfig);
+        Logger.setEnable(false);
+
+        //性能测试路由
+        webServer.get("/plaintext", new HttpRouter() {
+            public void process(HttpRequest req, HttpResponse resp) throws Exception {
+                resp.header().put(HttpStatic.CONTENT_TYPE_STRING, "text/plain");
+                resp.header().remove(HttpStatic.CONNECTION_STRING);
+                resp.write(HELLO_WORLD);
+            }
+        });
+
+        //性能测试路由
+        webServer.get("/json", new HttpRouter() {
+            public void process(HttpRequest req, HttpResponse resp) throws Exception {
+                resp.header().put("Content-Type", "application/json");
+                resp.write(JSON.toJSON(TObject.asMap("message", "Hello, World!")));
+            }
+        });
+
+        webServer.serve();
+    }
+}

+ 12 - 0
frameworks/Java/voovan/voovan.dockerfile

@@ -0,0 +1,12 @@
+FROM maven:3.5.3-jdk-11-slim as maven
+WORKDIR /voovan
+COPY pom.xml pom.xml
+COPY src src
+COPY config/framework.properties config/framework.properties
+RUN mvn package -q
+
+FROM openjdk:11-jdk-slim
+WORKDIR /voovan
+COPY --from=maven /voovan/target/voovan-bench-0.1-jar-with-dependencies.jar app.jar
+COPY --from=maven /voovan/config/framework.properties config/framework.properties
+CMD ["java", "-server", "-XX:+UseParallelGC", "-XX:+UseNUMA", "--illegal-access=warn", "-Djdk.attach.allowAttachSelf=true", "-cp", "./config:voovan.jar:app.jar", "org.voovan.VoovanTFB"]