|
@@ -35,10 +35,9 @@ public class VmsTcpCommServerService {
|
|
|
private ChannelFuture channelFuture = null;
|
|
|
|
|
|
public void run() {
|
|
|
- if (!OS.isWindows()) {
|
|
|
- if (!Epoll.isAvailable()) {
|
|
|
- Epoll.unavailabilityCause().printStackTrace();
|
|
|
- }
|
|
|
+ if (!OS.isWindows() && !Epoll.isAvailable()) {
|
|
|
+ log.warn("OS is not windows but Epoll is not available");
|
|
|
+// Epoll.unavailabilityCause().printStackTrace();
|
|
|
}
|
|
|
if (NettyUtils.isEpollAvailable()) {
|
|
|
log.info("서버가 리눅스 EPOLL 모드에서 실행됩니다.");
|
|
@@ -76,39 +75,45 @@ public class VmsTcpCommServerService {
|
|
|
public void stop() {
|
|
|
try {
|
|
|
this.acceptGroups.shutdownGracefully().sync();
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ log.error("stop, acceptGroups.InterruptedException");
|
|
|
+ }
|
|
|
+ try {
|
|
|
this.workerGroups.shutdownGracefully().sync();
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ log.error("stop, workerGroups.InterruptedException");
|
|
|
+ }
|
|
|
+ try {
|
|
|
this.channelFuture.channel().closeFuture().sync();
|
|
|
} catch (InterruptedException e) {
|
|
|
- log.error("stop, InterruptedException");
|
|
|
+ log.error("stop, channelFuture.InterruptedException");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public ServerBootstrap createBootstrap() {
|
|
|
- ServerBootstrap serverBootstrap = new ServerBootstrap();
|
|
|
- EventLoopGroup acceptGroups;
|
|
|
- EventLoopGroup workerGroups;
|
|
|
+ ServerBootstrap bootstrap = new ServerBootstrap();
|
|
|
|
|
|
- acceptGroups = NettyUtils.newEventLoopGroup(config.getAcceptThreads(), "Accept");
|
|
|
- workerGroups = NettyUtils.newEventLoopGroup(config.getWorkerThreads(), "Worker");
|
|
|
- serverBootstrap.channel(NettyUtils.getServerSocketChannel());
|
|
|
- serverBootstrap.group(acceptGroups, workerGroups);
|
|
|
+ this.acceptGroups = NettyUtils.newEventLoopGroup(this.config.getAcceptThreads(), "Accept");
|
|
|
+ this.workerGroups = NettyUtils.newEventLoopGroup(this.config.getWorkerThreads(), "Worker");
|
|
|
+ bootstrap.channel(NettyUtils.getServerSocketChannel());
|
|
|
+ bootstrap.group(this.acceptGroups, this.workerGroups);
|
|
|
|
|
|
- serverBootstrap.option(ChannelOption.AUTO_READ, true);
|
|
|
- serverBootstrap.option(ChannelOption.SO_BACKLOG, config.getBackLog());
|
|
|
- serverBootstrap.option(ChannelOption.SO_REUSEADDR, true);
|
|
|
- serverBootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.getConnectTimeoutSeconds()*1000);
|
|
|
+ bootstrap.option(ChannelOption.AUTO_READ, true);
|
|
|
+ bootstrap.option(ChannelOption.SO_BACKLOG, this.config.getBackLog());
|
|
|
+ bootstrap.option(ChannelOption.SO_REUSEADDR, true);
|
|
|
+ bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, this.config.getConnectTimeoutSeconds()*1000);
|
|
|
|
|
|
// TODO: 20240213 - START
|
|
|
//serverBootstrap.option(ChannelOption.SO_RCVBUF, config.getRcvBuf());
|
|
|
- serverBootstrap.option(ChannelOption.SO_SNDBUF, 1024 * 32768);
|
|
|
- serverBootstrap.option(ChannelOption.SO_RCVBUF, 1024 * 32768);
|
|
|
- serverBootstrap.option(ChannelOption.TCP_NODELAY, true);
|
|
|
+ bootstrap.option(ChannelOption.SO_SNDBUF, 1024 * 32768);
|
|
|
+ bootstrap.option(ChannelOption.SO_RCVBUF, 1024 * 32768);
|
|
|
+ bootstrap.option(ChannelOption.TCP_NODELAY, true);
|
|
|
// TODO: 20240213 - END
|
|
|
|
|
|
- serverBootstrap.childOption(ChannelOption.SO_LINGER, 0); // 4way-handshake 비활성
|
|
|
- serverBootstrap.childOption(ChannelOption.SO_KEEPALIVE, false); // KEEPALIVE 비활성(활성: true)
|
|
|
- serverBootstrap.childOption(ChannelOption.SO_REUSEADDR, true); // 소켓 재사용
|
|
|
- serverBootstrap.childOption(ChannelOption.TCP_NODELAY, true); // Nagle 알고리즘 비활성화, true
|
|
|
+ bootstrap.childOption(ChannelOption.SO_LINGER, 0); // 4way-handshake 비활성
|
|
|
+ bootstrap.childOption(ChannelOption.SO_KEEPALIVE, false); // KEEPALIVE 비활성(활성: true)
|
|
|
+ bootstrap.childOption(ChannelOption.SO_REUSEADDR, true); // 소켓 재사용
|
|
|
+ bootstrap.childOption(ChannelOption.TCP_NODELAY, true); // Nagle 알고리즘 비활성화, true
|
|
|
|
|
|
VmsTcpCommServerInitializer vmsTcpCommServerInitializer = new VmsTcpCommServerInitializer(
|
|
|
this.config,
|
|
@@ -118,9 +123,9 @@ public class VmsTcpCommServerService {
|
|
|
this.tcpServerByteBufMessageDecoder,
|
|
|
this.repoService
|
|
|
);
|
|
|
- serverBootstrap.childHandler(vmsTcpCommServerInitializer);
|
|
|
+ bootstrap.childHandler(vmsTcpCommServerInitializer);
|
|
|
|
|
|
- return serverBootstrap;
|
|
|
+ return bootstrap;
|
|
|
}
|
|
|
|
|
|
}
|