Commit 3cca62fa authored by AfirSraftGarrier's avatar AfirSraftGarrier

格式并加些打印

parent fbf04b6d
...@@ -11,48 +11,48 @@ import lombok.extern.slf4j.Slf4j; ...@@ -11,48 +11,48 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class TcpServer { public class TcpServer {
private int port; private int port;
private BaseChannelInitializer channelInitializer; private BaseChannelInitializer channelInitializer;
public TcpServer(int port, BaseChannelInitializer channelInitializer) { public TcpServer(int port, BaseChannelInitializer channelInitializer) {
this.port = port; this.port = port;
this.channelInitializer = channelInitializer; this.channelInitializer = channelInitializer;
} }
public void start() { public void start() {
Thread thread = new Thread(new Runnable() { Thread thread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
//创建两个线程组 bossGroup、workerGroup //创建两个线程组 bossGroup、workerGroup
EventLoopGroup bossGroup = new NioEventLoopGroup(4); EventLoopGroup bossGroup = new NioEventLoopGroup(4);
EventLoopGroup workerGroup = new NioEventLoopGroup(4); EventLoopGroup workerGroup = new NioEventLoopGroup(4);
log.debug("Tcp服务,开始监听端口:{}",port); log.debug("Tcp服务,开始监听端口:{}", port);
//创建服务端的启动对象,设置参数 //创建服务端的启动对象,设置参数
ServerBootstrap b = new ServerBootstrap(); ServerBootstrap b = new ServerBootstrap();
//设置两个线程组boosGroup和workerGroup //设置两个线程组boosGroup和workerGroup
b.group(bossGroup, workerGroup) b.group(bossGroup, workerGroup)
//设置服务端通道实现类型 //设置服务端通道实现类型
.channel(NioServerSocketChannel.class) .channel(NioServerSocketChannel.class)
// .handler(new LoggingHandler(LogLevel.INFO)) // .handler(new LoggingHandler(LogLevel.INFO))
.childHandler(channelInitializer) .childHandler(channelInitializer)
// 设置tcp缓冲区 // 设置tcp缓冲区
.option(ChannelOption.SO_BACKLOG, 1024) .option(ChannelOption.SO_BACKLOG, 1024)
//设置保持活动连接状态 //设置保持活动连接状态
.childOption(ChannelOption.SO_KEEPALIVE, true); .childOption(ChannelOption.SO_KEEPALIVE, true);
ChannelFuture f; ChannelFuture f;
try { try {
f = b.bind(port).sync(); f = b.bind(port).sync();
f.channel().closeFuture().sync(); f.channel().closeFuture().sync();
} catch (InterruptedException e) { } catch (InterruptedException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
log.error("Tcp服务异常,端口:{}",port); log.error("Tcp服务异常,端口:{}", port);
}finally { } finally {
log.debug("Tcp服务,停止退出"); log.debug("Tcp服务,停止退出");
workerGroup.shutdownGracefully(); workerGroup.shutdownGracefully();
bossGroup.shutdownGracefully(); bossGroup.shutdownGracefully();
} }
} }
}); });
thread.start(); thread.start();
} }
} }
...@@ -8,7 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -8,7 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@Component @Component
@Slf4j @Slf4j
...@@ -43,7 +47,7 @@ public class OperateManager { ...@@ -43,7 +47,7 @@ public class OperateManager {
return result; return result;
} }
public int getCount(){ public int getCount() {
return this.count; return this.count;
} }
...@@ -69,8 +73,8 @@ public class OperateManager { ...@@ -69,8 +73,8 @@ public class OperateManager {
this.putSamMonitorMap(serverIp, samMonitor); this.putSamMonitorMap(serverIp, samMonitor);
} }
// createProxyClient(); // createProxyClient();
// test(); // test();
} }
...@@ -89,8 +93,8 @@ public class OperateManager { ...@@ -89,8 +93,8 @@ public class OperateManager {
private void test() { private void test() {
String serverIp = "192.168.1.56"; String serverIp = "192.168.1.56";
int port = 18889; int port = 18889;
// serverIp = "172.17.115.81"; // serverIp = "172.17.115.81";
// port = 777; // port = 777;
this.startTcpClient(serverIp, port); this.startTcpClient(serverIp, port);
} }
......
...@@ -87,9 +87,9 @@ public class CommonUtil { ...@@ -87,9 +87,9 @@ public class CommonUtil {
String serverParentDirectory = getServerParentDirectory(); String serverParentDirectory = getServerParentDirectory();
if (os != null) { if (os != null) {
if (os.toLowerCase(Locale.ENGLISH).startsWith("win")) { if (os.toLowerCase(Locale.ENGLISH).startsWith("win")) {
return serverParentDirectory + File.separator + "lib" + File.separator + fileName + ".dll"; return serverParentDirectory + File.separator + "license/file/libs" + File.separator + fileName + ".dll";
} else { } else {
return serverParentDirectory + File.separator + "lib" + File.separator + fileName + ".so"; return serverParentDirectory + File.separator + "license/file/libs" + File.separator + fileName + ".so";
} }
} }
return ""; return "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment