Browse Source

update smart-http to 1.0.10.1006-beta (#5130)

* update dockerfile

* update to 1.0.10-SNAPSHOT

* update to 1.0.10-beta

* fix bug

* update to 1.0.10.1119-beta

* update to 1.0.10.1128-beta

* 还原代码

* update to 1.0.10.1206-beta

* update to 1.0.10.1209-beta

* update to 1.0.10.1214-beta

* 增加缓冲区

* update to 1.0.10-beta

* update to 1.0.10.1231-beta

* update to 1.0.10.0106-beta

* update to 1.0.0107-beta

* update to 1.0.10.0113-beta

* set new pageSize

* update smart-socket to 1.4.0-rc.2

* update to 1.4.0-rc.3

* update smart-socket to 1.4.0-rc.4

* update  to 1.0.10.0221-beta

* update smart-socket to 1.4.0-rc.5

* update maxCompletionHandlersOnStack

* config thread number

* update  to 1.0.10.0324-beta

* update smart-socket to 1.4.0-rc.9

* update smart-socket to 1.4.0-rc.10

* update smart-socket to 1.4.0-rc.11

* update smart-socket to 1.4.0-rc.13

* update smart-socket to 1.4.0

* update smart-socket to 1.4.1-rc.1

* update smart-socket to 1.4.1-rc.2

* update smart-http to 1.0.10.0501-beta

* set thread config

* update smart-socket to 1.4.1

* update smart-socket to 1.4.0-rc.4

* config thead num

* update smart-http to 1.0.10.0623-beta

* update smart-http to 1.0.10.0630-beta

* update smart-socket to 1.4.2.rc-3

* update smart-socket to 1.4.0-rc.5

* update smart-socket to 1.4.0-rc.6

* update smart-socket to 1.4.0-rc.7

* update smart-socket to 1.4.0-rc.8

* update smart-socket to 1.4.3-rc.2

* update smart-socket to 1.4.3-rc.3

* update smart-socket to 1.4.3-rc.4

* update smart-socket to 1.4.3-rc.5

* update smart-socket to 1.4.3-rc.7

* update smart-socket to 1.4.3-rc.8

* update smart-socket to 1.4.3-rc.9

* Revert "update smart-socket to 1.4.3-rc.9"

This reverts commit 931babe

* update smart-socket to 1.4.3-rc.9

* update thread num

* update smart-socket to 1.4.3

* update smart-socket to 1.4.4.rc-1

* update smart-http to 1.0.10.1006-beta

* update smart-socket to 1.4.3
三刀 5 years ago
parent
commit
9ccd568ccf

+ 6 - 6
frameworks/Java/smart-socket/pom.xml

@@ -9,7 +9,7 @@
     <parent>
     <parent>
         <groupId>org.smartboot.http</groupId>
         <groupId>org.smartboot.http</groupId>
         <artifactId>smart-http-parent</artifactId>
         <artifactId>smart-http-parent</artifactId>
-        <version>1.0.10.0630-beta</version>
+        <version>1.0.10.1006-beta</version>
     </parent>
     </parent>
     <properties>
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -22,11 +22,11 @@
             <groupId>org.smartboot.http</groupId>
             <groupId>org.smartboot.http</groupId>
             <artifactId>smart-http-server</artifactId>
             <artifactId>smart-http-server</artifactId>
         </dependency>
         </dependency>
-        <dependency>
-            <groupId>org.smartboot.socket</groupId>
-            <artifactId>aio-core</artifactId>
-            <version>1.4.4.rc-1</version>
-        </dependency>
+        <!--<dependency>-->
+            <!--<groupId>org.smartboot.socket</groupId>-->
+            <!--<artifactId>aio-pro</artifactId>-->
+            <!--<version>1.4.4.rc-2</version>-->
+        <!--</dependency>-->
         <dependency>
         <dependency>
             <groupId>com.jsoniter</groupId>
             <groupId>com.jsoniter</groupId>
             <artifactId>jsoniter</artifactId>
             <artifactId>jsoniter</artifactId>

+ 20 - 3
frameworks/Java/smart-socket/src/main/java/org/smartboot/http/Bootstrap.java

@@ -16,7 +16,11 @@ import org.smartboot.http.server.decode.Http11Request;
 import org.smartboot.http.server.decode.HttpRequestProtocol;
 import org.smartboot.http.server.decode.HttpRequestProtocol;
 import org.smartboot.http.server.handle.HttpHandle;
 import org.smartboot.http.server.handle.HttpHandle;
 import org.smartboot.socket.MessageProcessor;
 import org.smartboot.socket.MessageProcessor;
+import org.smartboot.socket.StateMachineEnum;
+import org.smartboot.socket.extension.plugins.MonitorPlugin;
+import org.smartboot.socket.extension.processor.AbstractMessageProcessor;
 import org.smartboot.socket.transport.AioQuickServer;
 import org.smartboot.socket.transport.AioQuickServer;
+import org.smartboot.socket.transport.AioSession;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 
@@ -25,7 +29,7 @@ public class Bootstrap {
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {
         System.setProperty("smart-socket.server.pageSize", (8 * 1024 * 1024) + "");
         System.setProperty("smart-socket.server.pageSize", (8 * 1024 * 1024) + "");
-        System.setProperty("smart-socket.bufferPool.pageNum", 16 + "");
+//        System.setProperty("smart-socket.bufferPool.pageNum", 16 + "");
         System.setProperty("smart-socket.session.writeChunkSize", (1024 * 4) + "");
         System.setProperty("smart-socket.session.writeChunkSize", (1024 * 4) + "");
 //        System.setProperty("sun.nio.ch.maxCompletionHandlersOnStack","24");
 //        System.setProperty("sun.nio.ch.maxCompletionHandlersOnStack","24");
         HttpMessageProcessor processor = new HttpMessageProcessor(System.getProperty("webapps.dir", "./"));
         HttpMessageProcessor processor = new HttpMessageProcessor(System.getProperty("webapps.dir", "./"));
@@ -51,6 +55,7 @@ public class Bootstrap {
                     stream.writeVal(Message.class, new Message("Hello, World!"));
                     stream.writeVal(Message.class, new Message("Hello, World!"));
                     response.setContentLength(stream.buffer().tail());
                     response.setContentLength(stream.buffer().tail());
                     response.getOutputStream().write(stream.buffer().data(), 0, stream.buffer().tail());
                     response.getOutputStream().write(stream.buffer().data(), 0, stream.buffer().tail());
+                    response.getOutputStream().flush();
                 } catch (IOException e) {
                 } catch (IOException e) {
                     throw new JsonException(e);
                     throw new JsonException(e);
                 } finally {
                 } finally {
@@ -62,9 +67,21 @@ public class Bootstrap {
 //        https(processor);
 //        https(processor);
     }
     }
 
 
-    public static void http(MessageProcessor<Http11Request> processor) {
+    public static void http(final MessageProcessor<Http11Request> processor) {
+        AbstractMessageProcessor messageProcessor = new AbstractMessageProcessor<Http11Request>() {
+            @Override
+            public void process0(AioSession<Http11Request> session, Http11Request msg) {
+                processor.process(session, msg);
+            }
+
+            @Override
+            public void stateEvent0(AioSession<Http11Request> session, StateMachineEnum stateMachineEnum, Throwable throwable) {
+                processor.stateEvent(session, stateMachineEnum, throwable);
+            }
+        };
+        messageProcessor.addPlugin(new MonitorPlugin(5  ));
         // 定义服务器接受的消息类型以及各类消息对应的处理器
         // 定义服务器接受的消息类型以及各类消息对应的处理器
-        AioQuickServer<Http11Request> server = new AioQuickServer<>(8080, new HttpRequestProtocol(), processor);
+        AioQuickServer<Http11Request> server = new AioQuickServer<>(8080, new HttpRequestProtocol(), messageProcessor);
         server.setReadBufferSize(1024 * 4);
         server.setReadBufferSize(1024 * 4);
         int cpuNum = Runtime.getRuntime().availableProcessors();
         int cpuNum = Runtime.getRuntime().availableProcessors();
         server.setThreadNum(cpuNum + 2);
         server.setThreadNum(cpuNum + 2);