Browse Source

upgrade smart-servlet to 2.4 (#9445)

* update smart-servlet to 0.1.3-SNAPSHOT

* update aio-enhance to 1.0.3-SNAPSHOT

* smart-servlet bugfix

* bugfix

* update smart-socket to 1.5.6-SNAPSHOT

* remove file

* update aio-enhance to 1.0.4-SNAPSHOT

* 优化代码

* 优化代码

* update smart-socket to 1.5.6

* config threadNum

* update smart-socket to 1.5.7-SNAPSHOT

* 优化代码

* update smart-socket to 1.5.10-SNAPSHOT

* 优化代码

* 优化代码

* 优化代码

* 异常aio-enhance

* 优化代码

* 优化代码

* 优化代码

* remove aio-pro

* remove headerLimiter

* update hikaricp version

* replace json util

* 更新线程模型

* upgrade smart-servlet to 0.1.9-SNAPSHOT

* config thread num

* config thread num

* revert code

* revert code

* upgrade smart-servlet to 0.2.1-SNAPSHOT

* upgrade smart-servlet to 0.6-SNAPSHOT

* upgrade smart-servlet to 0.6-SNAPSHOT

* upgrade smart-servlet to 0.6-SNAPSHOT

* upgrade smart-servlet to 0.6-SNAPSHOT

* upgrade smart-servlet to 0.6-SNAPSHOT

* upgrade smart-servlet to 0.6-SNAPSHOT

* upgrade smart-servlet to 0.6-SNAPSHOT

* upgrade smart-servlet to 1.0-SNAPSHOT

* upgrade smart-servlet to 1.4

* upgrade smart-servlet to 1.5-SNAPSHOT

* 启用虚拟线程

* 启用虚拟线程

* 适配最新版

* 适配最新版

* 适配最新版

* 适配最新版

* 适配最新版

* 适配最新版
三刀 8 months ago
parent
commit
cda709d99e

+ 0 - 3
frameworks/Java/smart-socket/benchmark_config.json

@@ -5,9 +5,6 @@
       "default": {
         "json_url": "/json",
         "plaintext_url": "/plaintext",
-        "db_url": "/db",
-        "query_url": "/queries?queries=",
-        "update_url": "/updates?queries=",
         "port": 8080,
         "approach": "Realistic",
         "classification": "Platform",

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

@@ -11,7 +11,7 @@
         <maven.compiler.source>21</maven.compiler.source>
         <maven.compiler.target>21</maven.compiler.target>
         <log4j.version>2.17.1</log4j.version>
-        <smartservlet.version>2.3</smartservlet.version>
+        <smartservlet.version>2.5</smartservlet.version>
         <hikaricp.version>5.0.0</hikaricp.version>
         <jsoniter.version>0.9.23</jsoniter.version>
     </properties>

+ 14 - 27
frameworks/Java/smart-socket/src/main/java/org/smartboot/http/Bootstrap.java

@@ -18,34 +18,11 @@ import org.smartboot.http.server.HttpServerHandler;
 import org.smartboot.http.server.handler.HttpRouteHandler;
 
 import javax.sql.DataSource;
-import java.io.IOException;
 
 public class Bootstrap {
     static byte[] body = "Hello, World!".getBytes();
 
     public static void main(String[] args) {
-        HttpRouteHandler routeHandle = new HttpRouteHandler();
-        routeHandle
-                .route("/plaintext", new HttpServerHandler() {
-
-
-                    @Override
-                    public void handle(HttpRequest request, HttpResponse response) throws IOException {
-                        response.setContentLength(body.length);
-                        response.setContentType("text/plain; charset=UTF-8");
-                        response.write(body);
-                    }
-                })
-                .route("/json", new HttpServerHandler() {
-
-                    @Override
-                    public void handle(HttpRequest request, HttpResponse response) throws IOException {
-
-                        response.setContentType("application/json");
-                        JsonUtil.writeJsonBytes(response, new Message("Hello, World!"));
-                    }
-                });
-        initDB(routeHandle);
         int cpuNum = Runtime.getRuntime().availableProcessors();
         // 定义服务器接受的消息类型以及各类消息对应的处理器
         HttpBootstrap bootstrap = new HttpBootstrap();
@@ -53,10 +30,20 @@ public class Bootstrap {
                 .threadNum(cpuNum)
                 .headerLimiter(0)
                 .readBufferSize(1024 * 4)
-                .writeBufferSize(1024 * 4)
-                .readMemoryPool(16384 * 1024 * 4)
-                .writeMemoryPool(10 * 1024 * 1024 * cpuNum, cpuNum);
-        bootstrap.httpHandler(routeHandle).setPort(8080).start();
+                .writeBufferSize(1024 * 4);
+        bootstrap.httpHandler(new HttpServerHandler() {
+            @Override
+            public void handle(HttpRequest request, HttpResponse response) throws Throwable {
+                if ("/plaintext".equals(request.getRequestURI())) {
+                    response.setContentLength(body.length);
+                    response.setContentType("text/plain; charset=UTF-8");
+                    response.write(body);
+                } else if ("/json".equals(request.getRequestURI())) {
+                    response.setContentType("application/json");
+                    JsonUtil.writeJsonBytes(response, new Message("Hello, World!"));
+                }
+            }
+        }).setPort(8080).start();
     }
 
     private static void initDB(HttpRouteHandler routeHandle) {

+ 7 - 25
frameworks/Java/smart-socket/src/main/java/org/smartboot/servlet/Bootstrap.java

@@ -1,17 +1,11 @@
 package org.smartboot.servlet;
 
 
-import org.smartboot.http.server.HttpBootstrap;
-import org.smartboot.http.server.HttpRequest;
-import org.smartboot.http.server.HttpResponse;
-import org.smartboot.http.server.HttpServerHandler;
 import tech.smartboot.servlet.Container;
 import tech.smartboot.servlet.ServletContextRuntime;
 import tech.smartboot.servlet.conf.ServletInfo;
 import tech.smartboot.servlet.conf.ServletMappingInfo;
 
-import java.util.concurrent.CompletableFuture;
-
 /**
  * @author 三刀([email protected]
  * @version V1.0 , 2020/12/22
@@ -19,6 +13,7 @@ import java.util.concurrent.CompletableFuture;
 public class Bootstrap {
 
     public static void main(String[] args) throws Throwable {
+        System.setProperty("smart-servlet-spring-boot-starter","true");
         Container containerRuntime = new Container();
         // plaintext
         ServletContextRuntime applicationRuntime = new ServletContextRuntime(null, Thread.currentThread().getContextClassLoader(), "/");
@@ -38,26 +33,13 @@ public class Bootstrap {
         applicationRuntime.getDeploymentInfo().addServlet(jsonServletInfo);
         applicationRuntime.getDeploymentInfo().addServletMapping(new ServletMappingInfo(jsonServletInfo.getServletName(), "/json"));
         containerRuntime.addRuntime(applicationRuntime);
-
         int cpuNum = Runtime.getRuntime().availableProcessors();
         // 定义服务器接受的消息类型以及各类消息对应的处理器
-        HttpBootstrap bootstrap = new HttpBootstrap();
-        bootstrap.configuration()
-                .threadNum(cpuNum)
-                .bannerEnabled(false)
-                .headerLimiter(0)
-                .readBufferSize(1024 * 4)
-                .writeBufferSize(1024 * 4)
-                .readMemoryPool(16384 * 1024 * 4)
-                .writeMemoryPool(10 * 1024 * 1024 * cpuNum, cpuNum);
-        containerRuntime.start(bootstrap.configuration());
-        bootstrap.setPort(8080)
-                .httpHandler(new HttpServerHandler() {
-                    @Override
-                    public void handle(HttpRequest request, HttpResponse response, CompletableFuture<Object> completableFuture) throws Throwable {
-                        containerRuntime.doHandle(request, response, completableFuture);
-                    }
-                })
-                .start();
+        containerRuntime.getConfiguration()
+                .setThreadNum(cpuNum)
+                .setReadBufferSize(1024 * 4);
+        containerRuntime.initialize();
+        containerRuntime.start();
+        
     }
 }

BIN
frameworks/Java/smart-socket/src/main/resources/smart-servlet/License.shield


+ 55 - 0
frameworks/Java/smart-socket/src/main/resources/smart-servlet/smart-servlet.pem

@@ -0,0 +1,55 @@
+-----BEGIN CERTIFICATE-----
+MIIEhTCCAu2gAwIBAgIQF5C4/s1tNk9arohyD4J2UDANBgkqhkiG9w0BAQsFADCB
+nzEeMBwGA1UEChMVbWtjZXJ0IGRldmVsb3BtZW50IENBMTowOAYDVQQLDDF6aGVu
+Z2p3MjJtYWMxMjNAemhlbmdqdzIyTWFjMTIzLmxvY2FsICh6aGVuZ2p3MjIpMUEw
+PwYDVQQDDDhta2NlcnQgemhlbmdqdzIybWFjMTIzQHpoZW5nancyMk1hYzEyMy5s
+b2NhbCAoemhlbmdqdzIyKTAeFw0yNDAyMTUwNzU3NTNaFw0yNjA1MTUwNzU3NTNa
+MGUxJzAlBgNVBAoTHm1rY2VydCBkZXZlbG9wbWVudCBjZXJ0aWZpY2F0ZTE6MDgG
+A1UECwwxemhlbmdqdzIybWFjMTIzQHpoZW5nancyMk1hYzEyMy5sb2NhbCAoemhl
+bmdqdzIyKTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALvMsE1RIalU
+Kzy+4U+Ixw+Z8FL3KHiKLk1513qsn40Po4bsE8zgsrd4lLx1lHpEkmKK3dpHREP1
+a1goi8Jqypmiz4oBUzrBMKBVo60wom3Al/XslgiZdzrhtFMOhwcjfGhkthq3ps5q
+wHyqRneijfeB/YICfF+e0K6fnbiSPd8rBJP6F7de2oafawIV9jNtIpqUQpfk+b+F
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HQQZ
+A7V+dgUGaQyBEc5Pq3gbOXRnCs10GTr69z7hCozGGCC3mUWVO/TZRe23AoGBAOFI
+y0LaAUPHstS8H2oyU8a0qqSFQ01YemugN+Bf9iHa1GSVNO5mv7upkkZbHu+TAAUq
+ZgvLdfEdSUKqW7Tt8XpP8Zhi/qDxV63fblhmsjsZvSwyYnI/UOMjZ4+IcCRb/8ZT
+mdxhzYl1Z9YJ+119IFapi0h+IO2UwBzkq2iOJg+zAoGBALJSi+nD7/lhA/HKu8Nr
+sh4G6tczLMOHN+jvngf5WoGEnBM1ENUtmMiH0YvBIpyHSHgyKwq+H29fgA5f42Eb
+xe7HfOye3a3OmmJvzkckEs5Ms1J4ahErwRUvM5+xsCG5bdpA/p61sy14W3eYyA/r
+tSSrxN4ernLg7k/vNHB0NIjK
+-----END PRIVATE KEY-----

+ 15 - 0
frameworks/Java/smart-socket/src/main/resources/smart-servlet/smart-servlet.properties

@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2017-2020, org.smartboot. All rights reserved.
+# project name: smart-servlet
+# file name: smart-servlet.properties
+# Date: 2020-12-10
+# Author: sandao ([email protected])
+#
+#
+http.port=8080
+http.readBufferSize=8192
+#http.threadNum=10
+root.context=ROOT
+## tls/ssl
+ssl.enable=false
+ssl.port=443