Quellcode durchsuchen

增加OkHttp配置文件读取

tags/v1.0.0^2
林万龙 vor 3 Jahren
Ursprung
Commit
62bff69c3f
2 geänderte Dateien mit 11 neuen und 23 gelöschten Zeilen
  1. +0
    -15
      src/main/java/com/telpo/dipperposition/config/AsyncExecutorConfig.java
  2. +11
    -8
      src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java

+ 0
- 15
src/main/java/com/telpo/dipperposition/config/AsyncExecutorConfig.java Datei anzeigen

@@ -19,8 +19,6 @@ import java.util.concurrent.ThreadPoolExecutor;
* @author: linwl * @author: linwl
* @create: 2020-07-11 09:17 * @create: 2020-07-11 09:17
*/ */
@Getter
@Setter
@Configuration @Configuration
@Slf4j @Slf4j
public class AsyncExecutorConfig implements AsyncConfigurer { public class AsyncExecutorConfig implements AsyncConfigurer {
@@ -34,19 +32,6 @@ public class AsyncExecutorConfig implements AsyncConfigurer {
@Value("${async.pool.queueCapacity}") @Value("${async.pool.queueCapacity}")
private int queueCapacity; private int queueCapacity;



@Value(value = "${position.server.serverAddr}")
private String serverAddr;

@Value(value = "${position.server.timeAsycPort}")
private String timeAsycServerPort;

@Value(value = "${position.server.posAsycPort}")
private String posAsycServerPort;

@Value(value = "${position.server.starsAsycPort}")
private String starsAsycServerPort;

@Bean(name = "asyncServiceExecutor") @Bean(name = "asyncServiceExecutor")
public Executor asyncServiceExecutor() { public Executor asyncServiceExecutor() {
log.info("start asyncServiceExecutor"); log.info("start asyncServiceExecutor");


+ 11
- 8
src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java Datei anzeigen

@@ -27,6 +27,11 @@ import java.net.InetSocketAddress;
@Slf4j @Slf4j
public class DipperPositionServer { public class DipperPositionServer {


private String serverAddr="172.16.192.26";
private String timeAsycServerPort="9011";
private String posAsycServerPort="9013";
private String starsAsycServerPort="9012";

@Autowired @Autowired
AsyncExecutorConfig positionConfig; AsyncExecutorConfig positionConfig;
/* /*
@@ -34,14 +39,12 @@ public class DipperPositionServer {
*/ */
public void startTimeAsnc() { public void startTimeAsnc() {


log.debug("Server is :", positionConfig.getServerAddr());
log.debug("Port is :", positionConfig.getTimeAsycServerPort());
//new 一个主线程组 //new 一个主线程组
EventLoopGroup mainThreadGroup = new NioEventLoopGroup(1); EventLoopGroup mainThreadGroup = new NioEventLoopGroup(1);
//new 一个工作线程组 //new 一个工作线程组
EventLoopGroup workThreadGroup = new NioEventLoopGroup(200); EventLoopGroup workThreadGroup = new NioEventLoopGroup(200);
InetSocketAddress socketAddress = new InetSocketAddress(positionConfig.getServerAddr(),
Integer.parseInt("9101"));
InetSocketAddress socketAddress = new InetSocketAddress(serverAddr,
Integer.parseInt(timeAsycServerPort));
ServerBootstrap bootstrap = new ServerBootstrap() ServerBootstrap bootstrap = new ServerBootstrap()
.group(mainThreadGroup, workThreadGroup) .group(mainThreadGroup, workThreadGroup)
.channel(NioServerSocketChannel.class) .channel(NioServerSocketChannel.class)
@@ -79,8 +82,8 @@ public class DipperPositionServer {
EventLoopGroup mainThreadGroup = new NioEventLoopGroup(1); EventLoopGroup mainThreadGroup = new NioEventLoopGroup(1);
//new 一个工作线程组 //new 一个工作线程组
EventLoopGroup workThreadGroup = new NioEventLoopGroup(200); EventLoopGroup workThreadGroup = new NioEventLoopGroup(200);
InetSocketAddress socketAddress = new InetSocketAddress(positionConfig.getServerAddr(),
Integer.parseInt(positionConfig.getPosAsycServerPort()));
InetSocketAddress socketAddress = new InetSocketAddress(serverAddr,
Integer.parseInt(posAsycServerPort));
ServerBootstrap bootstrap = new ServerBootstrap() ServerBootstrap bootstrap = new ServerBootstrap()
.group(mainThreadGroup, workThreadGroup) .group(mainThreadGroup, workThreadGroup)
.channel(NioServerSocketChannel.class) .channel(NioServerSocketChannel.class)
@@ -119,8 +122,8 @@ public class DipperPositionServer {
EventLoopGroup mainThreadGroup = new NioEventLoopGroup(1); EventLoopGroup mainThreadGroup = new NioEventLoopGroup(1);
//new 一个工作线程组 //new 一个工作线程组
EventLoopGroup workThreadGroup = new NioEventLoopGroup(200); EventLoopGroup workThreadGroup = new NioEventLoopGroup(200);
InetSocketAddress socketAddress = new InetSocketAddress(positionConfig.getServerAddr(),
Integer.parseInt(positionConfig.getStarsAsycServerPort()));
InetSocketAddress socketAddress = new InetSocketAddress(serverAddr,
Integer.parseInt(starsAsycServerPort));
ServerBootstrap bootstrap = new ServerBootstrap() ServerBootstrap bootstrap = new ServerBootstrap()
.group(mainThreadGroup, workThreadGroup) .group(mainThreadGroup, workThreadGroup)
.channel(NioServerSocketChannel.class) .channel(NioServerSocketChannel.class)


Laden…
Abbrechen
Speichern