瀏覽代碼

update t-io to 3.0.3 (#3865)

* add test for t-io

* update README.md

* update README.md

* add t-io

* add t-io.dockerfile

* delete t-io test

* add t-io test once more

* update t-io to 3.0.2

* 去掉没用的代码

* delete some useless code

* Optimization parameters

* delete useless jar

* upadte t-io to 3.0.3
tywo45 7 年之前
父節點
當前提交
1b4d7bbd01

+ 1 - 1
frameworks/Java/t-io/README.md

@@ -10,7 +10,7 @@ These implementations use the t-io's controller.
 
 
 
 
 ## Versions
 ## Versions
-3.0.2.v20180612-RELEASE (https://gitee.com/tywo45/t-io)
+3.0.3.v20180620-RELEASE (https://gitee.com/tywo45/t-io)
 
 
 ## Test URLs
 ## Test URLs
 
 

+ 1 - 1
frameworks/Java/t-io/pom.xml

@@ -8,7 +8,7 @@
 	<parent>
 	<parent>
 		<groupId>org.t-io</groupId>
 		<groupId>org.t-io</groupId>
 		<artifactId>tio-http-parent</artifactId>
 		<artifactId>tio-http-parent</artifactId>
-		<version>3.0.2.v20180612-RELEASE</version>
+    <version>3.0.3.v20180620-RELEASE</version>
 	</parent>
 	</parent>
 	
 	
 	<properties>
 	<properties>

+ 8 - 3
frameworks/Java/t-io/src/main/java/org/tio/http/server/benchmark/controller/TestController.java

@@ -2,19 +2,24 @@ package org.tio.http.server.benchmark.controller;
 
 
 import org.tio.http.common.HttpRequest;
 import org.tio.http.common.HttpRequest;
 import org.tio.http.common.HttpResponse;
 import org.tio.http.common.HttpResponse;
+import org.tio.http.common.MimeType;
 import org.tio.http.server.annotation.RequestPath;
 import org.tio.http.server.annotation.RequestPath;
 import org.tio.http.server.benchmark.model.Message;
 import org.tio.http.server.benchmark.model.Message;
 import org.tio.http.server.util.Resps;
 import org.tio.http.server.util.Resps;
 
 
 /**
 /**
+ * ab -k -n1000000 -c10 http://127.0.0.1:8080/json
+ * ab -k -n1000000 -c10 http://127.0.0.1:8080/plaintext
  * @author tanyaowu
  * @author tanyaowu
- * 2017年6月29日 下午7:53:59
+ *
  */
  */
 @RequestPath(value = "/")
 @RequestPath(value = "/")
 public class TestController {
 public class TestController {
 
 
 	private static final String HELLO_WORLD = "Hello, World!";
 	private static final String HELLO_WORLD = "Hello, World!";
-
+	
+	private static final byte[] HELLO_WORLD_BYTES = HELLO_WORLD.getBytes();
+	
 	@RequestPath(value = "json")
 	@RequestPath(value = "json")
 	public HttpResponse json(HttpRequest request) throws Exception {
 	public HttpResponse json(HttpRequest request) throws Exception {
 		return Resps.json(request, new Message(HELLO_WORLD));
 		return Resps.json(request, new Message(HELLO_WORLD));
@@ -22,6 +27,6 @@ public class TestController {
 
 
 	@RequestPath(value = "plaintext")
 	@RequestPath(value = "plaintext")
 	public HttpResponse plaintext(HttpRequest request) throws Exception {
 	public HttpResponse plaintext(HttpRequest request) throws Exception {
-		return Resps.txt(request, HELLO_WORLD);
+		return Resps.bytesWithContentType(request, HELLO_WORLD_BYTES, MimeType.TEXT_PLAIN_TXT.getType());
 	}
 	}
 }
 }

+ 5 - 1
frameworks/Java/t-io/src/main/java/org/tio/http/server/benchmark/init/HttpServerInit.java

@@ -1,5 +1,7 @@
 package org.tio.http.server.benchmark.init;
 package org.tio.http.server.benchmark.init;
 
 
+import org.tio.core.PacketHandlerMode;
+import org.tio.core.TcpConst;
 import org.tio.http.common.HttpConfig;
 import org.tio.http.common.HttpConfig;
 import org.tio.http.common.handler.HttpRequestHandler;
 import org.tio.http.common.handler.HttpRequestHandler;
 import org.tio.http.server.HttpServerStarter;
 import org.tio.http.server.HttpServerStarter;
@@ -24,6 +26,7 @@ public class HttpServerInit {
 	public static void init() throws Exception {
 	public static void init() throws Exception {
 		httpConfig = new HttpConfig(8080, null, null, null);
 		httpConfig = new HttpConfig(8080, null, null, null);
 		httpConfig.setUseSession(false);
 		httpConfig.setUseSession(false);
+		httpConfig.setWelcomeFile(null);
 
 
 		String[] scanPackages = new String[] { TestController.class.getPackage().getName() };
 		String[] scanPackages = new String[] { TestController.class.getPackage().getName() };
 		Routes routes = new Routes(scanPackages);
 		Routes routes = new Routes(scanPackages);
@@ -32,7 +35,8 @@ public class HttpServerInit {
 
 
 		httpServerStarter = new HttpServerStarter(httpConfig, requestHandler);
 		httpServerStarter = new HttpServerStarter(httpConfig, requestHandler);
 		serverGroupContext = httpServerStarter.getServerGroupContext();
 		serverGroupContext = httpServerStarter.getServerGroupContext();
-		serverGroupContext.setReadBufferSize(1024 * 60);
+		serverGroupContext.setReadBufferSize(TcpConst.MAX_DATA_LENGTH);
+		serverGroupContext.setPacketHandlerMode(PacketHandlerMode.QUEUE);
 		httpServerStarter.start();
 		httpServerStarter.start();
 	}
 	}
 }
 }

+ 1 - 1
frameworks/Java/t-io/t-io.dockerfile

@@ -6,5 +6,5 @@ RUN mvn compile assembly:single -q
 
 
 FROM openjdk:10-jre-slim
 FROM openjdk:10-jre-slim
 WORKDIR /t-io
 WORKDIR /t-io
-COPY --from=maven /t-io/target/tio-http-server-benchmark-3.0.2.v20180612-RELEASE.jar app.jar
+COPY --from=maven /t-io/target/tio-http-server-benchmark-3.0.3.v20180620-RELEASE.jar app.jar
 CMD ["java", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-jar", "app.jar"]
 CMD ["java", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-jar", "app.jar"]