Skip to content

Commit

Permalink
update dockerfile (#8573)
Browse files Browse the repository at this point in the history
* 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
smthing authored Nov 29, 2023
1 parent 1883313 commit 04c9461
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 69 deletions.
6 changes: 3 additions & 3 deletions frameworks/Java/smart-socket/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<log4j.version>2.17.1</log4j.version>
<smartservlet.version>0.2.1-SNAPSHOT</smartservlet.version>
<smartservlet.version>0.6-SNAPSHOT</smartservlet.version>
<hikaricp.version>5.0.0</hikaricp.version>
<jsoniter.version>0.9.23</jsoniter.version>
</properties>
Expand Down
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"]
6 changes: 3 additions & 3 deletions frameworks/Java/smart-socket/smart-socket.dockerfile
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"]
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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("/");
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package org.smartboot.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/**
Expand All @@ -16,7 +17,7 @@ public class HelloWorldServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentLength(BODY.length);
resp.setContentType("text/plain; charset=UTF-8");
resp.setContentType("text/plain;charset=UTF-8");
resp.setBufferSize(0);
resp.getOutputStream().write(BODY);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.smartboot.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.smartboot.Message;
import org.smartboot.http.JsonUtil;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
Expand All @@ -16,7 +16,7 @@
public class JsonServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("application/json");
resp.setContentType("application/json;charset=UTF-8");
resp.setBufferSize(0);
JsonUtil.writeJsonBytes(resp, new Message("Hello, World!"));
}
Expand Down

0 comments on commit 04c9461

Please sign in to comment.