-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
Showing
7 changed files
with
66 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
frameworks/Java/smart-socket/smart-socket-smart-servlet.dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
FROM maven:3.6.1-jdk-11-slim as maven | ||
FROM maven:3.8.6-openjdk-18-slim as maven | ||
WORKDIR /smart-socket | ||
COPY pom.xml pom.xml | ||
COPY src src | ||
RUN mvn compile assembly:single -q | ||
|
||
FROM openjdk:11.0.3-jdk-slim | ||
FROM openjdk:21-jdk-slim | ||
WORKDIR /smart-socket | ||
COPY --from=maven /smart-socket/target/smart-socket-benchmark-1.0-jar-with-dependencies.jar app.jar | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AggressiveOpts", "-cp", "app.jar", "org.smartboot.servlet.Bootstrap"] | ||
CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-cp", "app.jar", "org.smartboot.servlet.Bootstrap"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
FROM maven:3.6.1-jdk-11-slim as maven | ||
FROM maven:3.8.6-openjdk-18-slim as maven | ||
WORKDIR /smart-socket | ||
COPY pom.xml pom.xml | ||
COPY src src | ||
RUN mvn compile assembly:single -q | ||
|
||
FROM openjdk:11.0.3-jdk-slim | ||
FROM openjdk:21-jdk-slim | ||
WORKDIR /smart-socket | ||
COPY --from=maven /smart-socket/target/smart-socket-benchmark-1.0-jar-with-dependencies.jar app.jar | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AggressiveOpts", "-cp", "app.jar", "org.smartboot.http.Bootstrap"] | ||
CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-cp", "app.jar", "org.smartboot.http.Bootstrap"] |
84 changes: 42 additions & 42 deletions
84
frameworks/Java/smart-socket/src/main/java/org/smartboot/http/JsonUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,69 @@ | ||
package org.smartboot.http; | ||
|
||
import com.jsoniter.output.JsonStream; | ||
import com.jsoniter.output.JsonStreamPool; | ||
import com.jsoniter.spi.JsonException; | ||
import io.edap.x.json.Eson; | ||
import io.edap.x.json.JsonWriter; | ||
import com.jsoniter.spi.Slice; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import org.smartboot.http.server.HttpResponse; | ||
|
||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @author 三刀 | ||
* @version V1.0 , 2020/6/16 | ||
*/ | ||
public class JsonUtil { | ||
// public static void writeJsonBytes(HttpResponse httpResponse, Object obj) { | ||
// JsonWriter writer = Eson.THREAD_WRITER.get(); | ||
// try { | ||
// writer.reset(); | ||
// Eson.serialize(obj, writer); | ||
// httpResponse.setContentLength(writer.size()); | ||
// writer.toStream(httpResponse.getOutputStream()); | ||
// } catch (IOException e) { | ||
// throw new JsonException(e); | ||
// } | ||
// } | ||
public static void writeJsonBytes(HttpResponse httpResponse, Object obj) { | ||
JsonWriter writer = Eson.THREAD_WRITER.get(); | ||
JsonStream stream = JsonStreamPool.borrowJsonStream(); | ||
try { | ||
writer.reset(); | ||
Eson.serialize(obj, writer); | ||
httpResponse.setContentLength(writer.size()); | ||
writer.toStream(httpResponse.getOutputStream()); | ||
stream.reset(null); | ||
stream.writeVal(obj.getClass(), obj); | ||
Slice slice = stream.buffer(); | ||
httpResponse.setContentLength(slice.tail()); | ||
httpResponse.getOutputStream().write(slice.data(), 0, slice.tail()); | ||
} catch (IOException e) { | ||
throw new JsonException(e); | ||
} finally { | ||
JsonStreamPool.returnJsonStream(stream); | ||
} | ||
} | ||
|
||
// public static void writeJsonBytes(HttpResponse httpResponse, Object obj) { | ||
// JsonStream stream = JsonStreamPool.borrowJsonStream(); | ||
// try { | ||
// stream.reset(null); | ||
// stream.writeVal(obj.getClass(), obj); | ||
// Slice slice = stream.buffer(); | ||
// httpResponse.setContentLength(slice.tail()); | ||
// httpResponse.getOutputStream().write(slice.data(), 0, slice.tail()); | ||
// } catch (IOException e) { | ||
// throw new JsonException(e); | ||
// } finally { | ||
// JsonStreamPool.returnJsonStream(stream); | ||
// } | ||
// } | ||
public static void writeJsonBytes(HttpServletResponse httpResponse, Object obj) { | ||
JsonStream stream = JsonStreamPool.borrowJsonStream(); | ||
try { | ||
stream.reset(null); | ||
stream.writeVal(obj.getClass(), obj); | ||
Slice slice = stream.buffer(); | ||
httpResponse.setContentLength(slice.tail()); | ||
httpResponse.getOutputStream().write(slice.data(), 0, slice.tail()); | ||
} catch (IOException e) { | ||
throw new JsonException(e); | ||
} finally { | ||
JsonStreamPool.returnJsonStream(stream); | ||
} | ||
} | ||
|
||
// public static void writeJsonBytes(HttpServletResponse httpResponse, Object obj) { | ||
// JsonStream stream = JsonStreamPool.borrowJsonStream(); | ||
// JsonWriter writer = Eson.THREAD_WRITER.get(); | ||
// try { | ||
// stream.reset(null); | ||
// stream.writeVal(obj.getClass(), obj); | ||
// Slice slice = stream.buffer(); | ||
// httpResponse.setContentLength(slice.tail()); | ||
// httpResponse.getOutputStream().write(slice.data(), 0, slice.tail()); | ||
// writer.reset(); | ||
// Eson.serialize(obj, writer); | ||
// httpResponse.setContentLength(writer.size()); | ||
// writer.toStream(httpResponse.getOutputStream()); | ||
// } catch (IOException e) { | ||
// throw new JsonException(e); | ||
// } finally { | ||
// JsonStreamPool.returnJsonStream(stream); | ||
// } | ||
// } | ||
|
||
public static void writeJsonBytes(HttpServletResponse httpResponse, Object obj) { | ||
JsonWriter writer = Eson.THREAD_WRITER.get(); | ||
try { | ||
writer.reset(); | ||
Eson.serialize(obj, writer); | ||
httpResponse.setContentLength(writer.size()); | ||
writer.toStream(httpResponse.getOutputStream()); | ||
} catch (IOException e) { | ||
throw new JsonException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,21 +4,17 @@ | |
import org.smartboot.http.server.HttpRequest; | ||
import org.smartboot.http.server.HttpResponse; | ||
import org.smartboot.http.server.HttpServerHandler; | ||
import org.smartboot.http.server.impl.Request; | ||
import org.smartboot.servlet.conf.ServletInfo; | ||
import org.smartboot.socket.StateMachineEnum; | ||
import org.smartboot.socket.extension.processor.AbstractMessageProcessor; | ||
import org.smartboot.socket.transport.AioSession; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* @author 三刀([email protected]) | ||
* @version V1.0 , 2020/12/22 | ||
*/ | ||
public class Bootstrap { | ||
|
||
public static void main(String[] args) { | ||
public static void main(String[] args) throws Throwable { | ||
ContainerRuntime containerRuntime = new ContainerRuntime(); | ||
// plaintext | ||
ServletContextRuntime applicationRuntime = new ServletContextRuntime("/"); | ||
|
@@ -50,8 +46,8 @@ public static void main(String[] args) { | |
bootstrap.setPort(8080) | ||
.httpHandler(new HttpServerHandler() { | ||
@Override | ||
public void handle(HttpRequest request, HttpResponse response) throws IOException { | ||
containerRuntime.doHandle(request, response); | ||
public void handle(HttpRequest request, HttpResponse response, CompletableFuture<Object> completableFuture) throws Throwable { | ||
containerRuntime.doHandle(request, response, completableFuture); | ||
} | ||
}) | ||
.start(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters