Browse Source

Update voovan to 4.2.2 (#5600)

* Update pom.xml

update voovan to 4.2.2

* Update VoovanTFB.java

* Update voovan.dockerfile

* Update voovan.dockerfile

* Update VoovanTFB.java

* Update README.md

* Update voovan.dockerfile

* Update voovan.dockerfile
hely ho 5 years ago
parent
commit
f27dee7e91

+ 2 - 2
frameworks/Java/voovan/README.md

@@ -6,7 +6,7 @@ This is the voovan portion of a [benchmarking test suite](../) comparing a varie
 ## Versions
 ## Versions
 
 
 * [Java OpenJDK 1.8](http://openjdk.java.net/)
 * [Java OpenJDK 1.8](http://openjdk.java.net/)
-* [Voovan 4.0.0](https://gitee.com/helyho/Voovan)
+* [Voovan 4.2.x](https://gitee.com/helyho/Voovan)
 
 
 ## Test URLs
 ## Test URLs
 
 
@@ -16,4 +16,4 @@ This is the voovan portion of a [benchmarking test suite](../) comparing a varie
     
     
 ### Plaintext Encoding Test
 ### Plaintext Encoding Test
 
 
-    http://localhost:8080/plaintext
+    http://localhost:8080/plaintext

+ 1 - 1
frameworks/Java/voovan/pom.xml

@@ -17,7 +17,7 @@
         <dependency>
         <dependency>
             <groupId>org.voovan</groupId>
             <groupId>org.voovan</groupId>
             <artifactId>voovan-framework</artifactId>
             <artifactId>voovan-framework</artifactId>
-            <version>4.2.1</version>
+            <version>4.2.2</version>
         </dependency>
         </dependency>
     </dependencies>
     </dependencies>
     <build>
     <build>

+ 29 - 6
frameworks/Java/voovan/src/main/java/org/voovan/VoovanTFB.java

@@ -11,17 +11,39 @@ import org.voovan.tools.TEnv;
 import org.voovan.tools.TObject;
 import org.voovan.tools.TObject;
 import org.voovan.tools.json.JSON;
 import org.voovan.tools.json.JSON;
 import org.voovan.tools.log.Logger;
 import org.voovan.tools.log.Logger;
+import org.voovan.tools.reflect.TReflect;
 
 
+import java.io.IOException;
+import java.util.Arrays;
 import java.util.Map;
 import java.util.Map;
+import java.util.Objects;
 
 
 
 
 public class VoovanTFB {
 public class VoovanTFB {
 	private static final byte[] HELLO_WORLD = "Hello, World!".getBytes();
 	private static final byte[] HELLO_WORLD = "Hello, World!".getBytes();
 
 
+	public static class Message {
+
+		private final String message;
+
+		public Message(String message) {
+			this.message = message;
+		}
+
+		public String getMessage() {
+			return message;
+		}
+
+		@Override
+		public int hashCode() {
+			return Objects.hash(message);
+		}
+	}
 
 
 	public static void main(String[] args) {
 	public static void main(String[] args) {
+		TReflect.register(Message.class);
 
 
-		WebServerConfig webServerConfig = WebContext.getWebServerConfig();
+		WebServerConfig webServerConfig = WebContext.buildWebServerConfig();
 		webServerConfig.setGzip(false);
 		webServerConfig.setGzip(false);
 		webServerConfig.setAccessLog(false);
 		webServerConfig.setAccessLog(false);
 		webServerConfig.setKeepAliveTimeout(1000);
 		webServerConfig.setKeepAliveTimeout(1000);
@@ -36,19 +58,20 @@ public class VoovanTFB {
 		//性能测试请求;
 		//性能测试请求;
 		webServer.get("/plaintext", new HttpRouter() {
 		webServer.get("/plaintext", new HttpRouter() {
 			public void process(HttpRequest req, HttpResponse resp) throws Exception {
 			public void process(HttpRequest req, HttpResponse resp) throws Exception {
-				resp.header().put(HttpStatic.CONTENT_TYPE_STRING, "text/plain");
+				resp.header().put(HttpStatic.CONTENT_TYPE_STRING, HttpStatic.TEXT_PLAIN_STRING);
 				resp.write(HELLO_WORLD);
 				resp.write(HELLO_WORLD);
 			}
 			}
 		});
 		});
-		
 		//性能测试请求
 		//性能测试请求
 		webServer.get("/json", new HttpRouter() {
 		webServer.get("/json", new HttpRouter() {
 			public void process(HttpRequest req, HttpResponse resp) throws Exception {
 			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!")));
+				resp.header().put(HttpStatic.CONTENT_TYPE_STRING, HttpStatic.APPLICATION_JSON_STRING);
+				resp.write(JSON.toJSON(new Message("Hello, World!"), false, false));
 			}
 			}
 		});
 		});
 
 
-		webServer.serve();	
+		Logger.setEnable(true);
+
+		webServer.serve();
 	}
 	}
 }
 }

+ 5 - 3
frameworks/Java/voovan/voovan.dockerfile

@@ -9,7 +9,9 @@ FROM openjdk:11.0.3-jdk-slim
 WORKDIR /voovan
 WORKDIR /voovan
 COPY --from=maven /voovan/target/voovan-bench-0.1-jar-with-dependencies.jar app.jar
 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
 COPY --from=maven /voovan/config/framework.properties config/framework.properties
-CMD java  -server -Xms2g -Xmx2g \
-    --illegal-access=warn -XX:-RestrictContended -XX:+UseParallelGC -XX:+UseNUMA \
-    -DThreadBufferPoolSize=256 -DAsyncSend=false \
+CMD java -DThreadBufferPoolSize=1024 -DAsyncSend=false \
+    -server -Xms2g -Xmx2g \
+    --illegal-access=warn -XX:-RestrictContended \
+    -XX:+UseParallelGC -XX:+UseNUMA \
+    -XX:+AggressiveOpts -XX:+UseBiasedLocking \
     -cp ./config:voovan.jar:app.jar org.voovan.VoovanTFB
     -cp ./config:voovan.jar:app.jar org.voovan.VoovanTFB