From a7c2cebc9ad718f47a9699d5002dc6e26f722b94 Mon Sep 17 00:00:00 2001 From: linwl <304115325@qq.com> Date: Tue, 2 Feb 2021 15:53:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=9F=E5=8E=86=E6=95=B0=E6=8D=AE=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E4=B8=BAbyte[]=E6=95=B0=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 +- dipper_position_run.sh | 44 ++++----- pom.xml | 40 ++------ .../DipperPositionApplication.java | 3 - .../dipperposition/common/SocketClient.java | 5 +- .../config/AsyncExecutorConfig.java | 8 +- .../config/NettyServerConfig.java | 25 ++--- .../dipperposition/config/OkHttpConfig.java | 14 ++- .../dipperposition/config/PositionConfig.java | 39 ++------ .../config/SchedulingExecutorConfig.java | 16 ++-- .../DipperAstPosAsyncTaskController.java | 37 -------- .../DipperAstTimeAsyncTaskController.java | 39 -------- .../DipperDataAsyncTaskController.java | 55 ----------- .../handler/NettyServerHandler.java | 94 +++++++++++-------- .../handler/ServerChannelInitializer.java | 2 + .../mapper/IpProvinceMapper.java | 4 - .../server/DipperPositionServer.java | 7 +- .../server/TimeAsyncServer.java | 81 ---------------- .../service/IDipperDataAsyncTaskService.java | 2 +- .../DipperAstPosAsyncTaskServiceImpl.java | 15 +-- .../DipperAstTimeAsyncTaskServiceImpl.java | 5 - .../impl/DipperDataAsyncTaskServiceImpl.java | 18 ++-- .../service/impl/IpProvinceServiceImpl.java | 8 -- .../service/impl/ProvinceInfoServiceImpl.java | 6 -- .../dipperposition/task/ScheduleService.java | 6 +- src/main/resources/application.properties | 59 ++++++++++++ src/main/resources/bootstrap-pro.yaml | 83 ++++++++++++++-- src/main/resources/bootstrap-test.yaml | 83 +++++++++++++++- src/main/resources/bootstrap.yaml | 1 - 29 files changed, 360 insertions(+), 443 deletions(-) delete mode 100644 src/main/java/com/telpo/dipperposition/controller/DipperAstPosAsyncTaskController.java delete mode 100644 src/main/java/com/telpo/dipperposition/controller/DipperAstTimeAsyncTaskController.java delete mode 100644 src/main/java/com/telpo/dipperposition/controller/DipperDataAsyncTaskController.java delete mode 100644 src/main/java/com/telpo/dipperposition/server/TimeAsyncServer.java create mode 100644 src/main/resources/application.properties diff --git a/Dockerfile b/Dockerfile index 839622d..190741e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,6 @@ ENV TimeZone=Asia/Shanghai ENV active=dev ENV JAVA_OPTS="-Xmx256M -Xms256M" RUN ln -snf /usr/share/zoneinfo/$TimeZone /etc/localtime && echo $TimeZone > /etc/timezone -ENTRYPOINT java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /dipperposition.jar --spring.profiles.active=$active \ No newline at end of file +ENTRYPOINT java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -Dio.netty.leakDetectionLevel=ADVANCED -jar /dipperposition.jar --spring.profiles.active=$active + +java -Xmx256M -Xms256M -Djava.security.egd=file:/dev/./urandom -Dio.netty.leakDetectionLevel=ADVANCED -jar /dipperposition.jar --spring.profiles.active= \ No newline at end of file diff --git a/dipper_position_run.sh b/dipper_position_run.sh index 79b07f2..fbea5dc 100644 --- a/dipper_position_run.sh +++ b/dipper_position_run.sh @@ -2,29 +2,29 @@ environment=$1 version=$2 echo "环境变量为${environment},版本为$version!" -if [[ ${environment} == 'production' ]]; then - echo "开始远程构建容器" - docker stop dipperposition_service || true - docker rm dipperposition_service || true - docker rmi -f $(docker images | grep registry.cn-shanghai.aliyuncs.com/telpo_platform/rzl_adapter | awk '{print $3}') - docker login --username=rzl_wangjx@1111649216405698 --password=telpo.123 registry.cn-shanghai.aliyuncs.com - docker pull registry.cn-shanghai.aliyuncs.com/telpo_platform/dipperposition_service:$version - docker run -e active=pro -v /home/data/dipperposition/log:/var/log/dipperposition --restart=always -p 8105:8105 -p 9011:9011 -p 9012:9012 -p 9013:9013 -d --name dipperposition_service registry.cn-shanghai.aliyuncs.com/telpo_platform/dipperposition_service:$version - #删除产生的None镜像 - docker rmi -f $(docker images | grep none | awk '{print $3}') - docker ps -a -else -if [[ ${environment} == 'test' ]]; then - #echo "开始远程构建容器" - docker stop dipperposition_service || true - docker rm dipperposition_service || true - docker rmi -f $(docker images | grep 139.224.254.18:5000/dipperposition_service | awk '{print $3}') - docker pull 139.224.254.18:5000/dipperposition_service:$version - docker run -v /home/data/dipperposition/log:/var/log/dipperposition -e active=test --restart=always -d --network host -p 9011:9011 --name dipperposition_service 139.224.254.18:5000/dipperposition_service:$version +#processID='ps -ef | grep dipperposition | awk '{print $2}' | awk NR==1' +ps -ef | grep dipperposition | awk '{print $2}' | xargs kill -9 +#echo $processID +#if [[ "$processID" != "" ]]; then +# kill -9 $processID +#fi + +if [[ ${environment} == 'pro' ]]; then + echo 'run in production environment' + cd /home/data/dipperposition + if [[ -f /home/linwl/dipperposition/dipperposition.jar ]]; then + echo 'mv /home/linwl/dipperposition/dipperposition.jar to destination' + mv /home/linwl/dipperposition/dipperposition.jar /home/data/dipperposition/dipperposition.jar + fi + + nohup java -Xmx2048M -Xms2048M -Djava.security.egd=file:/dev/./urandom -Dio.netty.leakDetectionLevel=ADVANCED -jar dipperposition.jar --spring.profiles.active=pro & - #删除产生的None镜像 - docker rmi -f $(docker images | grep none | awk '{print $3}') - docker ps -a fi +if [[ ${environment} == 'test' ]]; then + cd /home/data/dipperposition + if [[ -f /home/linwl/Work/DipperPosition/dipperposition.jar ]]; then + mv /home/linwl/Work/DipperPosition/dipperposition.jar /home/data/dipperposition/dipperposition.jar + fi + nohup java -Xmx128M -Xms128M -Djava.security.egd=file:/dev/./urandom -Dio.netty.leakDetectionLevel=ADVANCED -jar dipperposition.jar --spring.profiles.active=test & fi diff --git a/pom.xml b/pom.xml index 12008e3..cabac44 100644 --- a/pom.xml +++ b/pom.xml @@ -40,32 +40,10 @@ true - - com.telpo - common - 1.1.19 - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - com.alibaba.boot - nacos-config-spring-boot-starter - 0.2.7 - - - - com.alibaba.nacos - nacos-client + cn.hutool + hutool-core + 5.5.2 @@ -138,6 +116,11 @@ 2.0 + + org.springframework.data + spring-data-mongodb + 2.2.5.RELEASE + @@ -150,13 +133,6 @@ import - - com.alibaba.cloud - spring-cloud-alibaba-dependencies - ${spring-cloud-alibaba.version} - pom - import - diff --git a/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java b/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java index 691fbb1..452e6e9 100644 --- a/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java +++ b/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java @@ -1,12 +1,10 @@ package com.telpo.dipperposition; import com.telpo.dipperposition.server.DipperPositionServer; -import com.telpo.dipperposition.server.TimeAsyncServer; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.scheduling.annotation.EnableAsync; @@ -19,7 +17,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; * @create: 2020-06-18 16:39 */ @SpringBootApplication -@EnableDiscoveryClient @ConfigurationPropertiesScan @EnableAsync @EnableScheduling diff --git a/src/main/java/com/telpo/dipperposition/common/SocketClient.java b/src/main/java/com/telpo/dipperposition/common/SocketClient.java index b017c6a..dfb6947 100644 --- a/src/main/java/com/telpo/dipperposition/common/SocketClient.java +++ b/src/main/java/com/telpo/dipperposition/common/SocketClient.java @@ -38,7 +38,7 @@ public class SocketClient { } - public String sendCmd(String astCmd, String ackAckCheckRef) { + public byte[] sendCmd(String astCmd, String ackAckCheckRef) { try { OutputStream os=socket.getOutputStream(); PrintWriter pw=new PrintWriter(os); @@ -80,7 +80,8 @@ public class SocketClient { os.close(); //log.debug(ackResult); log.debug("接收服务器的信息:"+HexConvert.BinaryToHexString(in2b)); - return HexConvert.BinaryToHexString(in2b); + //return HexConvert.BinaryToHexString(in2b); + return in2b; } catch (IOException e) { log.error("Socket sendCmd Error:" + e.getMessage()); return null; diff --git a/src/main/java/com/telpo/dipperposition/config/AsyncExecutorConfig.java b/src/main/java/com/telpo/dipperposition/config/AsyncExecutorConfig.java index a339326..32fe03f 100644 --- a/src/main/java/com/telpo/dipperposition/config/AsyncExecutorConfig.java +++ b/src/main/java/com/telpo/dipperposition/config/AsyncExecutorConfig.java @@ -19,17 +19,19 @@ import java.util.concurrent.ThreadPoolExecutor; * @author: linwl * @create: 2020-07-11 09:17 */ +@Getter +@Setter @Configuration @Slf4j public class AsyncExecutorConfig implements AsyncConfigurer { - @Value("${async.pool.corePoolSize}") + @Value(value = "${async.pool.corePoolSize:4}") private int corePoolSize; - @Value("${async.pool.maxPoolSize}") + @Value(value = "${async.pool.maxPoolSize:8}") private int maxPoolSize; - @Value("${async.pool.queueCapacity}") + @Value(value = "${async.pool.queueCapacity:5000}") private int queueCapacity; @Bean(name = "asyncServiceExecutor") diff --git a/src/main/java/com/telpo/dipperposition/config/NettyServerConfig.java b/src/main/java/com/telpo/dipperposition/config/NettyServerConfig.java index 9d203c5..4e5a66d 100644 --- a/src/main/java/com/telpo/dipperposition/config/NettyServerConfig.java +++ b/src/main/java/com/telpo/dipperposition/config/NettyServerConfig.java @@ -1,17 +1,12 @@ package com.telpo.dipperposition.config; -import com.alibaba.nacos.api.config.annotation.NacosValue; -import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource; -import com.telpo.dipperposition.common.OkHttpUtil; import lombok.Getter; import lombok.Setter; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; -import javax.annotation.PostConstruct; - /** - * @program: gateway + * @program: NettyServerConfig * @description: jwt设置 * @author: linwl * @create: 2020-06-18 17:45 @@ -19,26 +14,18 @@ import javax.annotation.PostConstruct; @Getter @Setter @Configuration -@NacosPropertySource(dataId="dipperposition-service", autoRefreshed=true) public class NettyServerConfig { - @NacosValue(value = "${position-server.serverAddr}") + @Value(value = "${position-server.serverAddr}") private String serverAddr; - @NacosValue(value = "${position-server.timeAsycPort:9011}") + @Value(value = "${position-server.timeAsycPort:9011}") private String timeAsycServerPort; - @NacosValue(value = "${position-server.posAsycPort}") + @Value(value = "${position-server.posAsycPort:9013}") private String posAsycServerPort; - @NacosValue(value = "${position-server.starsAsycPort}") + @Value(value = "${position-server.starsAsycPort:9012}") private String starsAsycServerPort; -// public static NettyServerConfig nettyServerConfig; -// -// @PostConstruct -// public void init() { -// nettyServerConfig = this; -// } - } diff --git a/src/main/java/com/telpo/dipperposition/config/OkHttpConfig.java b/src/main/java/com/telpo/dipperposition/config/OkHttpConfig.java index 6fd53c8..185ced1 100644 --- a/src/main/java/com/telpo/dipperposition/config/OkHttpConfig.java +++ b/src/main/java/com/telpo/dipperposition/config/OkHttpConfig.java @@ -1,5 +1,7 @@ package com.telpo.dipperposition.config; +import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import okhttp3.ConnectionPool; import okhttp3.OkHttpClient; @@ -24,23 +26,25 @@ import java.util.concurrent.TimeUnit; * @author: linwl * @create: 2020-07-17 15:29 */ +@Getter +@Setter @Configuration @Slf4j public class OkHttpConfig { - @Value("${OkHttp-config.pool.max-conn}") + @Value(value = "${OkHttp-config.pool.max-conn}") private Integer maxConn; - @Value("${OkHttp-config.pool.keep-alive}") + @Value(value = "${OkHttp-config.pool.keep-alive}") private Integer keepAlive; - @Value("${OkHttp-config.read-timeout}") + @Value(value = "${OkHttp-config.read-timeout}") private long readTimeout; - @Value("${OkHttp-config.conn-timeout}") + @Value(value = "${OkHttp-config.conn-timeout}") private long connTimeout; - @Value("${OkHttp-config.write-timeout}") + @Value(value = "${OkHttp-config.write-timeout}") private long writeTimeout; @Bean diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java index e126a49..cc1e5b5 100644 --- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java +++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java @@ -1,16 +1,12 @@ package com.telpo.dipperposition.config; -import com.alibaba.nacos.api.config.annotation.NacosValue; -import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource; import lombok.Getter; import lombok.Setter; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; -import javax.annotation.PostConstruct; - /** - * @program: gateway + * @program: PositionConfig * @description: jwt设置 * @author: linwl * @create: 2020-06-18 17:45 @@ -18,32 +14,13 @@ import javax.annotation.PostConstruct; @Getter @Setter @Configuration -@NacosPropertySource(dataId="dipperposition-service", autoRefreshed=true) public class PositionConfig { - @NacosValue("${pos.centerProvinceFilePath}") - String centerProvinceFilePath; - - @NacosValue("${pos.ipPositionRequestPath}") - String ipPositionRequestPath; - @NacosValue("${pos.ipPositionRequestKey}") - String ipPositionRequestKey; - @NacosValue("${pos.centerProvince}") - String centerProvince; - - - @NacosValue("${pos.astServer}") - String astServer; - @NacosValue("${pos.astPosAstPort}") - int posAstPort; - @NacosValue("${pos.astTimeout}") - int astTimeout; - + @Value(value = "${pos.ipPositionRequestPath}") + private String ipPositionRequestPath; + @Value(value = "${pos.ipPositionRequestKey}") + private String ipPositionRequestKey; + @Value(value = "${pos.centerProvince}") + private String centerProvince; -// public static PositionConfig positionConfig; -// -// @PostConstruct -// public void init() { -// positionConfig = this; -// } } diff --git a/src/main/java/com/telpo/dipperposition/config/SchedulingExecutorConfig.java b/src/main/java/com/telpo/dipperposition/config/SchedulingExecutorConfig.java index 2bfd302..46dac6b 100644 --- a/src/main/java/com/telpo/dipperposition/config/SchedulingExecutorConfig.java +++ b/src/main/java/com/telpo/dipperposition/config/SchedulingExecutorConfig.java @@ -20,19 +20,19 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar; @Configuration public class SchedulingExecutorConfig implements SchedulingConfigurer { - @Value("${scheduler.pool.size}") + @Value(value = "${scheduler.pool.size}") private int pollSize; - @Value("${scheduler.pool.await-seconds}") + @Value(value = "${scheduler.pool.await-seconds}") private int awaitSeconds; - @Value("${pos.ast.server}") + @Value(value = "${pos.astServer}") private String astServer; - @Value("${pos.ast.ephAstPort}") - private int ephAstPort; - @Value("${pos.ast.ephAstHexPort}") - private int ephAstHexPort; - @Value("${pos.ast.timeout}") + @Value(value = "${pos.astPosAstPort}") + private int posAstPort; + @Value(value = "${pos.astEphAstHexPort}") + private int astEphAstHexPort; + @Value(value = "${pos.astTimeout}") private int astTimeout; @Override diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperAstPosAsyncTaskController.java b/src/main/java/com/telpo/dipperposition/controller/DipperAstPosAsyncTaskController.java deleted file mode 100644 index 19588a8..0000000 --- a/src/main/java/com/telpo/dipperposition/controller/DipperAstPosAsyncTaskController.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.telpo.dipperposition.controller; - -import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService; -import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.PostConstruct; - - -/** - * @program: DipperAstPosAsyncTaskController - * @description: 北斗定位 - * @author: linwl - * @create: 2020-07-10 14:01 - */ -@RestController -@Slf4j -public class DipperAstPosAsyncTaskController { - - @Autowired - IDipperAstPosAsyncTaskService dipperAstPosAsyncTaskService; - -// private DipperAstPosAsyncTaskController dipperAstPosAsyncTaskController; -// @PostConstruct -// public void init() { -// dipperAstPosAsyncTaskController = this; -// } - /* - * 拉取星历数据 - */ - public String pushAstPos(String ipAddress) { - return dipperAstPosAsyncTaskService.pushAstPos(ipAddress); - } - -} diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperAstTimeAsyncTaskController.java b/src/main/java/com/telpo/dipperposition/controller/DipperAstTimeAsyncTaskController.java deleted file mode 100644 index 8fbfc61..0000000 --- a/src/main/java/com/telpo/dipperposition/controller/DipperAstTimeAsyncTaskController.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.telpo.dipperposition.controller; - -import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService; -import com.telpo.dipperposition.service.IDipperDataAsyncTaskService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.PostConstruct; - - -/** - * @program: DipperPositionController - * @description: 北斗定位 - * @author: linwl - * @create: 2020-07-10 14:01 - */ -@RestController -@Slf4j -public class DipperAstTimeAsyncTaskController { - - @Autowired - IDipperAstTimeAsyncTaskService dipperTimeAsyncTaskService; - -// private DipperAstTimeAsyncTaskController dipperTimeAsyncTaskController; -// @PostConstruct -// public void init() { -// dipperTimeAsyncTaskController = this; -// } - /* - * 拉取星历数据 - */ - public String pushAstTime() { - return dipperTimeAsyncTaskService.pushAstTime(); - } - -} diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperDataAsyncTaskController.java b/src/main/java/com/telpo/dipperposition/controller/DipperDataAsyncTaskController.java deleted file mode 100644 index fbf8b6a..0000000 --- a/src/main/java/com/telpo/dipperposition/controller/DipperDataAsyncTaskController.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.telpo.dipperposition.controller; - -import com.telpo.dipperposition.service.IDipperDataAsyncTaskService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.PostConstruct; - - -/** - * @program: DipperPositionController - * @description: 北斗定位 - * @author: linwl - * @create: 2020-07-10 14:01 - */ -@RestController -@Slf4j -public class DipperDataAsyncTaskController { - @Value(value = "${position-server.serverAddr}") - private String serverAddr; - //RzlAccount rzlAccount; - - @Autowired - IDipperDataAsyncTaskService dipperDataAsyncTaskService; - -// private DipperDataAsyncTaskController dipperDataAsyncTaskController; -// @PostConstruct -// public void init() { -// dipperDataAsyncTaskController = this; -// } - /* - * 拉取星历数据 - */ - public void pullAstEPH() { - dipperDataAsyncTaskService.pullAstEPH(); - } -// -// /* -// * 获取星历数据 -// */ -// public String getAstEPH() { -// log.info("DipperDataAsyncTaskController serverAddr = " + serverAddr); -// return dipperDataAsyncTaskService.getAstEPH(); -// } - - - @RequestMapping("/getPos") - public String getPos() { - return "return serverAddr = " + serverAddr; - } - -} diff --git a/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java b/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java index c9cae7e..9ec061e 100644 --- a/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java +++ b/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java @@ -5,6 +5,7 @@ import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService; import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService; import com.telpo.dipperposition.service.IDipperDataAsyncTaskService; import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.CompositeByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.socket.SocketChannel; @@ -30,7 +31,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { private static String AST_TIME_CMD = "TIME"; private static String AST_POS_CMD = "POS"; private static String AST_EPH_CMD = "EPH"; - private static String AST_ALL_CMD = "all"; + private static String AST_ALL_CMD = "ALL"; private static String AST_TIME_CMD_BYTE = "54494d45"; private static String AST_POS_CMD_BYTE = "504f53"; private static String AST_EPH_CMD_BYTE = "455048"; @@ -71,23 +72,8 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { log.info("链接报告完毕"); //通知客户端链接建立成功 // 默认返回取得时间成功 - String ackAckCheckRef = "233E0101020004020A1D"; - -// if (Integer.parseInt(nettyServerConfig.getPosAsycServerPort()) == channel.localAddress().getPort()) { -// ackAckCheckRef = "233E010102000401091C"; -// } -// if (Integer.parseInt(nettyServerConfig.getStarsAsycServerPort()) == channel.localAddress().getPort()) { -// ackAckCheckRef = "233E010102000421293C"; -// } - - if (9013 == channel.localAddress().getPort()) { - ackAckCheckRef = "233E010102000401091C"; - } - if (9012 == channel.localAddress().getPort()) { - ackAckCheckRef = "233E010102000421293C"; - } - //String str = "通知客户端链接建立成功" + " " + LocalDateTime.now() + " " + channel.localAddress().getHostString() + - // "\r\n"; + // String ackAckCheckRef = "233E0101020004020A1D"; + String ackAckCheckRef = "23 3E 01 01 02 00 04 21 29 3C"; ByteBuf buf = Unpooled.buffer(ackAckCheckRef.getBytes().length); buf.writeBytes(ackAckCheckRef.getBytes(CharsetUtil.UTF_8)); ctx.writeAndFlush(buf); @@ -109,6 +95,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { //接收msg消息与上一章节相比,此处已经不需要自己进行解码} SocketChannel channel = (SocketChannel) ctx.channel(); + ByteBufAllocator bba = channel.config().getAllocator(); String ipAddress = channel.remoteAddress().getHostString(); log.info("接收到消息:" + msg + ",客户端IP:" + ipAddress); if(ipAddress.contains(":")) { @@ -125,9 +112,11 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { channelAns = nettyServerHandler.dipperTimeAsyncTaskService.pushAstTime(); //log.debug(channelAns); if (channelAns != null) { - buf = Unpooled.buffer(channelAns.getBytes().length); + buf = bba.buffer(channelAns.getBytes().length); + //Unpooled.buffer(channelAns.getBytes().length); buf.writeBytes(channelAns.getBytes(CharsetUtil.UTF_8)); - ctx.writeAndFlush(buf); + ctx.write(buf); + ctx.flush(); } } // 发送SDBP-AST-POS获取辅助位置信息 @@ -135,49 +124,72 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { channelAns = nettyServerHandler.dipperAstPosAsyncTaskService.pushAstPos(ipAddress); //log.debug(channelAns); if (channelAns != null) { - buf = Unpooled.buffer(channelAns.getBytes().length); + buf = bba.buffer(channelAns.getBytes().length); + //Unpooled.buffer(channelAns.getBytes().length); buf.writeBytes(channelAns.getBytes(CharsetUtil.UTF_8)); - ctx.writeAndFlush(buf); + ctx.write(buf); + ctx.flush(); } } // 从缓存获取SDBP-AST-EPH星历数 if (AST_EPH_CMD.equals(msg)) { - channelAns = nettyServerHandler.dipperDataAsyncTaskService.getAstEPH(); + //channelAns = nettyServerHandler.dipperDataAsyncTaskService.getAstEPH(); + byte[] returnBytes = nettyServerHandler.dipperDataAsyncTaskService.getAstEPH(); //log.debug(channelAns); - if (channelAns != null) { - buf = Unpooled.buffer(channelAns.getBytes().length); - buf.writeBytes(channelAns.getBytes(CharsetUtil.UTF_8)); - ctx.writeAndFlush(buf); - } + //if (channelAns != null) { + // buf = bba.buffer(channelAns.getBytes().length); + buf = bba.buffer(returnBytes.length); + //Unpooled.buffer(channelAns.getBytes().length); + buf.writeBytes(returnBytes); + ctx.write(buf); + ctx.flush(); + //} } // 最后把SDBP-AST-TIME、SDBP-AST-POS、SDBP-AST-EPH并包一起发给设备。 // 设备采用16进制获取数据,则代理服务器也是采用16进制返回数据。 // 通知客户端链消息发送成功 - if (AST_ALL_CMD.equals(msg)) { - CompositeByteBuf compositeByteBuf = Unpooled.compositeBuffer(); + if (AST_ALL_CMD.equals(msg.toString().toUpperCase())) { channelAns = nettyServerHandler.dipperTimeAsyncTaskService.pushAstTime(); if (channelAns != null) { - ByteBuf channelTimeAnsBuf = Unpooled.buffer(channelAns.getBytes().length); + log.debug("Time Buffer Length is:" + channelAns.getBytes().length); + ByteBuf channelTimeAnsBuf = bba.buffer(channelAns.getBytes().length); + //Unpooled.buffer(channelAns.getBytes().length); channelTimeAnsBuf.writeBytes(channelAns.getBytes(CharsetUtil.UTF_8)); - compositeByteBuf.addComponent(channelTimeAnsBuf); + // compositeByteBuf.addComponent(channelTimeAnsBuf); + ctx.write(channelTimeAnsBuf); + ctx.flush(); } channelAns = nettyServerHandler.dipperAstPosAsyncTaskService.pushAstPos(ipAddress); if (channelAns != null) { - ByteBuf channelPosAnsBuf = Unpooled.buffer(channelAns.getBytes().length); + log.debug("Pos Buffer Length is:" + channelAns.getBytes().length); + ByteBuf channelPosAnsBuf = bba.buffer(channelAns.getBytes().length); + //Unpooled.buffer(channelAns.getBytes().length); channelPosAnsBuf.writeBytes(channelAns.getBytes(CharsetUtil.UTF_8)); - compositeByteBuf.addComponent(channelPosAnsBuf); - } - channelAns = nettyServerHandler.dipperDataAsyncTaskService.getAstEPH(); - if (channelAns != null) { - ByteBuf channelPehAnsBuf = Unpooled.buffer(channelAns.getBytes().length); - channelPehAnsBuf.writeBytes(channelAns.getBytes(CharsetUtil.UTF_8)); - compositeByteBuf.addComponent(channelPehAnsBuf); + //compositeByteBuf.addComponent(channelPosAnsBuf); + ctx.write(channelPosAnsBuf); + ctx.flush(); } - ctx.writeAndFlush(compositeByteBuf); + byte[] returnBytes = nettyServerHandler.dipperDataAsyncTaskService.getAstEPH(); + //if (channelAns != null) { + log.debug("PEH Buffer Length is:" + returnBytes.length); + // 使用池化的堆内存,以减少内存碎片 + //ByteBuf channelPehAnsBuf = Unpooled.buffer(channelAns.getBytes().length); + //ByteBuf channelPehAnsBuf = bba.buffer(channelAns.getBytes().length); + ByteBuf channelPehAnsBuf = bba.buffer(returnBytes.length); + //channelPehAnsBuf.writeBytes(channelAns.getBytes(CharsetUtil.UTF_8)); + channelPehAnsBuf.writeBytes(returnBytes); + // compositeByteBuf.addComponent(channelPehAnsBuf); + // log.info("CompositeByteBuf Length is:" + compositeByteBuf.capacity()); + ctx.write(channelPehAnsBuf); + ctx.flush(); + //} + + // 写给下一个Handler,最后一个Handler将内容移出pipeline + // ctx.writeAndFlush(compositeByteBuf); } } diff --git a/src/main/java/com/telpo/dipperposition/handler/ServerChannelInitializer.java b/src/main/java/com/telpo/dipperposition/handler/ServerChannelInitializer.java index 95d98dd..a6fb9de 100644 --- a/src/main/java/com/telpo/dipperposition/handler/ServerChannelInitializer.java +++ b/src/main/java/com/telpo/dipperposition/handler/ServerChannelInitializer.java @@ -18,7 +18,9 @@ public class ServerChannelInitializer extends ChannelInitializer //添加编解码 socketChannel.pipeline().addLast("decoder", new StringDecoder(CharsetUtil.UTF_8)); socketChannel.pipeline().addLast("encoder", new StringEncoder(CharsetUtil.UTF_8)); + // pipeline的第一个ChannelHandler:ChannelInboundHandlerAdapter socketChannel.pipeline().addLast(new NettyServerHandler()); + // addLast后会自动创建ChannelHandlerContext } } diff --git a/src/main/java/com/telpo/dipperposition/mapper/IpProvinceMapper.java b/src/main/java/com/telpo/dipperposition/mapper/IpProvinceMapper.java index b794c95..8d176ce 100644 --- a/src/main/java/com/telpo/dipperposition/mapper/IpProvinceMapper.java +++ b/src/main/java/com/telpo/dipperposition/mapper/IpProvinceMapper.java @@ -1,13 +1,9 @@ package com.telpo.dipperposition.mapper; -import com.telpo.dipperposition.annotation.MongoSwitch; import com.telpo.dipperposition.entity.mongo.IpProvinceEntity; -import db.BaseMongoDbDao; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.stereotype.Repository; -import java.util.List; /** * @program: DataPushServer diff --git a/src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java b/src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java index e9d63e4..6d513bb 100644 --- a/src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java +++ b/src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java @@ -48,8 +48,9 @@ public class DipperPositionServer { .channel(NioServerSocketChannel.class) .childHandler(new ServerChannelInitializer()) .localAddress(socketAddress) - //设置队列大小 + //设置队列大小, 多少合适???? .option(ChannelOption.SO_BACKLOG, 1024) + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 3000) // 两小时内没有数据的通信时,TCP会自动发送一个活动探测数据报文 .childOption(ChannelOption.SO_KEEPALIVE, true); @@ -62,9 +63,9 @@ public class DipperPositionServer { //log.info("服务器: {}", myServerAddr); channelFuture.addListener(future -> { if (future.isSuccess()){ - System.out.println("start success"); + log.info("start success"); }else{ - System.out.println("start failed"); + log.info("start failed"); } }); channelFuture.channel().closeFuture().sync(); diff --git a/src/main/java/com/telpo/dipperposition/server/TimeAsyncServer.java b/src/main/java/com/telpo/dipperposition/server/TimeAsyncServer.java deleted file mode 100644 index c06344b..0000000 --- a/src/main/java/com/telpo/dipperposition/server/TimeAsyncServer.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.telpo.dipperposition.server; - -import com.alibaba.nacos.api.exception.NacosException; -import com.telpo.dipperposition.handler.ServerChannelInitializer; -import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelOption; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.nio.NioServerSocketChannel; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.env.ConfigurableEnvironment; - -import java.net.InetSocketAddress; - -/** - * @program: TimeAsyncServer - * @description: 北斗定位 - * @author: king - * @create: 2021-01-13 14:01 - */ -@Slf4j -public class TimeAsyncServer { - - // @Autowired PositionConfigInfo positionConfigInfo; - private String serverAddr; - private Integer serverPort; - private Integer timeAsycPort; - private Integer posAsycPort; - private Integer starsAsycPort; - - public TimeAsyncServer(ConfigurableEnvironment environment) throws NacosException { - - this.serverAddr = environment.getProperty("position-server.serverAddr"); - this.serverPort = Integer.parseInt(environment.getProperty("server.port")); - this.timeAsycPort = Integer.parseInt(environment.getProperty("position-server.timeAsycPort")); - this.posAsycPort = Integer.parseInt(environment.getProperty("position-server.posAsycPort")); - this.starsAsycPort = Integer.parseInt(environment.getProperty("position-server.starsAsycPort")); - } - - public void start() { - - //new 一个主线程组 - EventLoopGroup mainThreadGroup = new NioEventLoopGroup(1); - //new 一个工作线程组 - EventLoopGroup workThreadGroup = new NioEventLoopGroup(200); - //InetSocketAddress socketAddress = new InetSocketAddress(serverAddr,null); - ServerBootstrap bootstrap = new ServerBootstrap() - .group(mainThreadGroup, workThreadGroup) - .channel(NioServerSocketChannel.class) - .childHandler(new ServerChannelInitializer()) - //.localAddress(socketAddress) - //设置队列大小 - .option(ChannelOption.SO_BACKLOG, 1024) - // 两小时内没有数据的通信时,TCP会自动发送一个活动探测数据报文 - .childOption(ChannelOption.SO_KEEPALIVE, true); - - - //绑定端口,开始接收进来的连接 - try { - ChannelFuture channelFuture = bootstrap.bind(timeAsycPort).sync(); - log.info("时间辅助服务器启动开始监听端口: {}", timeAsycPort); - channelFuture.addListener(future -> { - if (future.isSuccess()){ - System.out.println("start success"); - }else{ - System.out.println("start failed"); - } - }); - - channelFuture.channel().closeFuture().sync(); - } catch (InterruptedException e) { - e.printStackTrace(); - } finally { - //关闭主线程组 - mainThreadGroup.shutdownGracefully(); - //关闭工作线程组 - workThreadGroup.shutdownGracefully(); - } - } -} diff --git a/src/main/java/com/telpo/dipperposition/service/IDipperDataAsyncTaskService.java b/src/main/java/com/telpo/dipperposition/service/IDipperDataAsyncTaskService.java index d5637f9..b60ffeb 100644 --- a/src/main/java/com/telpo/dipperposition/service/IDipperDataAsyncTaskService.java +++ b/src/main/java/com/telpo/dipperposition/service/IDipperDataAsyncTaskService.java @@ -26,6 +26,6 @@ public interface IDipperDataAsyncTaskService { * 根据IP获取EPH * */ - String getAstEPH(); + byte[] getAstEPH(); } diff --git a/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java b/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java index a8f0260..3095d86 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java @@ -1,9 +1,7 @@ package com.telpo.dipperposition.service.impl; -import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSONObject; import com.telpo.dipperposition.common.*; -import com.telpo.dipperposition.config.NettyServerConfig; import com.telpo.dipperposition.config.PositionConfig; import com.telpo.dipperposition.entity.mongo.IpProvinceEntity; import com.telpo.dipperposition.entity.mongo.ProvinceInfoEntity; @@ -11,21 +9,12 @@ import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService; import com.telpo.dipperposition.service.IProvinceInfoService; import com.telpo.dipperposition.service.IpProvinceService; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.ObjectUtils; -import org.apache.logging.log4j.util.PropertiesUtil; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; -import org.springframework.util.ResourceUtils; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.UnsupportedEncodingException; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.Objects; /** * @program: DipperAstPosAsyncTaskServiceImpl @@ -71,7 +60,7 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS JSONObject paramObject = new JSONObject(); String result = okHttpUtil.getJsonParams(buffer.toString(), paramObject.toJSONString()); if (ObjectUtils.isNotEmpty(result)) { - if (StringUtils.isEmpty(result)) { + if (ObjectUtils.isEmpty(result)) { log.debug("IP省份获取错误,结果为空"); return null; } else { @@ -226,7 +215,7 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS astCheckSumBuf.insert(0,"0"); } checkSum = astCheckSumBuf.toString(); - log.info(checkSum); + //log.info(checkSum); byte[] astPosCmdBytes = HexConvert.hexStringToBytes(astPosCmdBuf.toString()); StringBuilder astPosCmdNewBuf = new StringBuilder(); diff --git a/src/main/java/com/telpo/dipperposition/service/impl/DipperAstTimeAsyncTaskServiceImpl.java b/src/main/java/com/telpo/dipperposition/service/impl/DipperAstTimeAsyncTaskServiceImpl.java index 5c35041..65d35c9 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/DipperAstTimeAsyncTaskServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/DipperAstTimeAsyncTaskServiceImpl.java @@ -1,13 +1,8 @@ package com.telpo.dipperposition.service.impl; import com.telpo.dipperposition.common.HexConvert; -import com.telpo.dipperposition.common.SocketClient; -import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService; import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import java.time.LocalDateTime; diff --git a/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java b/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java index bfab90d..36583aa 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java @@ -29,13 +29,11 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi @Autowired private SchedulingExecutorConfig schedulingExecutorConfig; - - @Override - @Async("asyncServiceExecutor") + //@Async("asyncServiceExecutor") public void pullAstEPH() { // (1) 发送bds获取星历数据 - String dipperData = pullEPHFromDipper(); + byte[] dipperData = pullEPHFromDipper(); // (2) 获取星历数据 if (dipperData == null) { @@ -47,10 +45,11 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi } } - private String pullEPHFromDipper() { + private byte[] pullEPHFromDipper() { // 创建Socket客户端实例; - SocketClient client = new SocketClient(schedulingExecutorConfig.getAstServer(), schedulingExecutorConfig.getEphAstHexPort(),schedulingExecutorConfig.getAstTimeout()); + SocketClient client = new SocketClient(schedulingExecutorConfig.getAstServer(), + schedulingExecutorConfig.getAstEphAstHexPort(),schedulingExecutorConfig.getAstTimeout()); // astTimeCmd 组装 String astTimeCmd = DIPPER_ALL_DATA_REQ; @@ -65,14 +64,15 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi String hexIn = astTimeCmd + checkSum.substring(0,2) + " " + checkSum.substring(2,4); String ackAckCheckRef = "233E010102000421293C"; - String sendResult = client.sendCmd(hexIn, ackAckCheckRef); + byte[] sendResult = client.sendCmd(hexIn, ackAckCheckRef); client.closeConnection(); return sendResult; } @Override - public String getAstEPH(){ - return (String)redisUtil.get(DIPPER_DATA_KEY); + public byte[] getAstEPH(){ + // String dipperData = pullEPHFromDipper(); + return (byte[])redisUtil.get(DIPPER_DATA_KEY); } } diff --git a/src/main/java/com/telpo/dipperposition/service/impl/IpProvinceServiceImpl.java b/src/main/java/com/telpo/dipperposition/service/impl/IpProvinceServiceImpl.java index deb0626..a5e03cd 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/IpProvinceServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/IpProvinceServiceImpl.java @@ -1,22 +1,14 @@ package com.telpo.dipperposition.service.impl; -import cn.hutool.core.collection.CollectionUtil; import com.telpo.dipperposition.entity.mongo.IpProvinceEntity; -import com.telpo.dipperposition.entity.mongo.ProvinceInfoEntity; import com.telpo.dipperposition.mapper.IpProvinceMapper; import com.telpo.dipperposition.service.IpProvinceService; -import jdk.nashorn.internal.runtime.options.Option; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; -import tools.BeanTools; -import java.util.List; import java.util.Optional; /** diff --git a/src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java b/src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java index 668f2ad..b9e7baf 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java @@ -1,8 +1,5 @@ package com.telpo.dipperposition.service.impl; -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollectionUtil; -import com.telpo.dipperposition.entity.mongo.IpProvinceEntity; import com.telpo.dipperposition.entity.mongo.ProvinceInfoEntity; import com.telpo.dipperposition.mapper.ProvinceInfoMapper; import com.telpo.dipperposition.service.IProvinceInfoService; @@ -11,10 +8,7 @@ import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; -import tools.BeanTools; import java.util.List; import java.util.Optional; diff --git a/src/main/java/com/telpo/dipperposition/task/ScheduleService.java b/src/main/java/com/telpo/dipperposition/task/ScheduleService.java index 03e3315..70d31f1 100644 --- a/src/main/java/com/telpo/dipperposition/task/ScheduleService.java +++ b/src/main/java/com/telpo/dipperposition/task/ScheduleService.java @@ -1,10 +1,8 @@ package com.telpo.dipperposition.task; -import com.telpo.dipperposition.controller.DipperDataAsyncTaskController; import com.telpo.dipperposition.service.IDipperDataAsyncTaskService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -20,7 +18,7 @@ import org.springframework.stereotype.Component; public class ScheduleService { @Autowired - private DipperDataAsyncTaskController dipperDataAsyncTaskController; + private IDipperDataAsyncTaskService dipperDataAsyncTaskService; /* * 调用9012端口的接口获取星历数据。 @@ -33,7 +31,7 @@ public class ScheduleService { log.info("开始星历数据同步!"); // 获取推送失败的记录 try { - dipperDataAsyncTaskController.pullAstEPH(); + dipperDataAsyncTaskService.pullAstEPH(); } catch (Exception e) { log.error("执行定时获取星历数据发生异常:", e); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..0642c24 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,59 @@ +server.port=8105 +logging.config=classpath:log/logback-spring.xml +logging.level.com.telpo.dipperposition.service.impl=DEBUG +logging.level.com.telpo.dipperposition.service.mapper=DEBUG +spring.application.name=dipperposition-service + +spring.redis.database=1 +spring.redis.host=172.19.42.45 +#8090 +spring.redis.port=6389 +spring.redis.password=telpo#1234 +spring.redis.timeout=3000 +spring.redis.lettuce.pool.max-active=100 +# 连接池最大连接数(使用负值表示没有限制) +spring.redis.lettuce.pool.max-idle=100 +# 连接池中的最大空闲连接 +spring.redis.lettuce.pool.min-idle=50 +# 连接池中的最小空闲连接 +spring.redis.lettuce.pool.max-wait=6000 +# 连接池最大阻塞等待时间(使用负值表示没有限制) +spring.data.mongodb.host=172.19.42.45 +spring.data.mongodb.port=27017 +spring.data.mongodb.database=common +spring.data.mongodb.username=wangjx +spring.data.mongodb.password=wangjx#1234 + +position-server.serverAddr=172.19.42.45 +position-server.timeAsycPort=9011 +position-server.posAsycPort=9013 +position-server.starsAsycPort=9012 + +#等待任务完成退出最大秒数 +scheduler.pool.size=2 +scheduler.pool.await-seconds=600 +scheduler.task.cron=0 */30 * * * * + +pos.ipPositionRequestPath=https://restapi.amap.com/v3/ip +pos.ipPositionRequestKey=46eb0eba39494a6e9a90a0dc9e76639e +pos.centerProvince=湖北省 +pos.astServer=agnss.techtotop.com +pos.astPosAstPort=8012 +pos.astEphAstHexPort=9012 +pos.astTimeout=30000 + +OkHttp-config.pool.max-conn=200 +OkHttp-config.pool.keep-alive=5 +OkHttp-config.read-timeout=10 +OkHttp-config.conn-timeout=10 +OkHttp-config.write-timeout=10 + +async.pool.corePoolSize=4 +async.pool.maxPoolSize=8 +async.pool.queueCapacity=5000 + +mongo.datasource.dblist.uri=mongodb://wangjx:wangjx#1234@172.19.42.45:27017/common +mongo.datasource.dblist.database=common + + + diff --git a/src/main/resources/bootstrap-pro.yaml b/src/main/resources/bootstrap-pro.yaml index 721abc4..1c50d09 100644 --- a/src/main/resources/bootstrap-pro.yaml +++ b/src/main/resources/bootstrap-pro.yaml @@ -1,10 +1,79 @@ +server: + port: 8105 + +logging: + config: classpath:log/logback-spring.xml + level: + com: + telpo: + dipperposition: + service: + impl: debug + mapper: debug + org.springframework.data.mongodb.core.MongoTemplate: DEBUG spring: - main: - allow-bean-definition-overriding: true application: name: dipperposition-service - cloud: - nacos: - config: - server-addr: 172.19.42.38:8848 - file-extension: yml \ No newline at end of file + redis: + database: 1 + host: 172.19.42.45 + #8090 + port: 6379 + password: telpo#1234 + timeout: 3000 + lettuce: + pool: + max-active: 100 # 连接池最大连接数(使用负值表示没有限制) + max-idle: 100 # 连接池中的最大空闲连接 + min-idle: 50 # 连接池中的最小空闲连接 + max-wait: 6000 # 连接池最大阻塞等待时间(使用负值表示没有限制) + data: + mongodb: + host: 172.19.42.45 + port: 27017 + database: common + username: wangjx + password: wangjx#1234 + +mongo: + datasource: + dblist: + - uri: mongodb://wangjx:wangjx#1234@172.19.42.45:27015/common + database: common + +scheduler: + pool: + size: 2 + #等待任务完成退出最大秒数 + await-seconds: 600 + task: + cron: "0 */30 * * * *" + +pos: + ipPositionRequestPath: https://restapi.amap.com/v3/ip + ipPositionRequestKey: 46eb0eba39494a6e9a90a0dc9e76639e + centerProvince: 湖北省 + astServer: agnss.techtotop.com + astPosAstPort: 8012 + astEphAstHexPort: 9012 + astTimeout: 30000 + +position-server: + serverAddr: 172.19.42.45 + timeAsycPort: 9011 + posAsycPort: 9013 + starsAsycPort: 9012 + +OkHttp-config: + pool: + max-conn: 200 + keep-alive: 5 + read-timeout: 10 + conn-timeout: 10 + write-timeout: 10 + +async: + pool: + corePoolSize: 4 + maxPoolSize: 8 + queueCapacity: 5000 \ No newline at end of file diff --git a/src/main/resources/bootstrap-test.yaml b/src/main/resources/bootstrap-test.yaml index e8e687a..60cd53e 100644 --- a/src/main/resources/bootstrap-test.yaml +++ b/src/main/resources/bootstrap-test.yaml @@ -1,10 +1,87 @@ +server: + port: 8105 + +logging: + config: classpath:log/logback-spring.xml + level: + com: + telpo: + dipperposition: + service: + impl: debug + mapper: debug + org.springframework.data.mongodb.core.MongoTemplate: DEBUG spring: - main: - allow-bean-definition-overriding: true application: name: dipperposition-service cloud: nacos: config: server-addr: 172.19.42.44:8848 - file-extension: yml \ No newline at end of file + namespace: fee328ef-7348-4984-879a-fd75f9f59cd2 + redis: + database: 1 + host: 172.19.42.44 + #8090 + port: 8090 + password: telpo#1234 + timeout: 3000 + lettuce: + pool: + max-active: 100 # 连接池最大连接数(使用负值表示没有限制) + max-idle: 100 # 连接池中的最大空闲连接 + min-idle: 50 # 连接池中的最小空闲连接 + max-wait: 6000 # 连接池最大阻塞等待时间(使用负值表示没有限制) + data: + mongodb: + host: 172.19.42.40 + port: 27018 + database: common + username: wangjx + password: wangjx#1234 + +mongo: + datasource: + dblist: + - uri: mongodb://wangjx:wangjx#1234@172.19.42.40:27018/common + database: common + - uri: mongodb://wangjx:wangjx#1234@172.19.42.40:27018/basicdata + database: basicdata + +scheduler: + pool: + size: 2 + #等待任务完成退出最大秒数 + await-seconds: 600 + task: + cron: "0 */30 * * * *" + +pos: + centerProvinceFilePath: /csv/provinceLonAlt.csv + ipPositionRequestPath: https://restapi.amap.com/v3/ip + ipPositionRequestKey: 46eb0eba39494a6e9a90a0dc9e76639e + centerProvince: 湖北省 + astServer: agnss.techtotop.com + astPosAstPort: 8012 + astEphAstHexPort: 9012 + astTimeout: 30000 + +position-server: + serverAddr: 172.19.42.44 + timeAsycPort: 9011 + posAsycPort: 9013 + starsAsycPort: 9012 + +OkHttp-config: + pool: + max-conn: 200 + keep-alive: 5 + read-timeout: 10 + conn-timeout: 10 + write-timeout: 10 + +async: + pool: + corePoolSize: 4 + maxPoolSize: 8 + queueCapacity: 5000 \ No newline at end of file diff --git a/src/main/resources/bootstrap.yaml b/src/main/resources/bootstrap.yaml index b5569d8..c34181b 100644 --- a/src/main/resources/bootstrap.yaml +++ b/src/main/resources/bootstrap.yaml @@ -58,7 +58,6 @@ mongo: - uri: mongodb://wangjx:wangjx#1234@172.16.192.26:27017/common database: common - OkHttp-config: pool: max-conn: 200