ソースを参照

修改到docker外运行环境

tags/v1.0.0^2
林万龙 3年前
コミット
910c8aa7b5
4個のファイルの変更68行の追加66行の削除
  1. +6
    -0
      pom.xml
  2. +33
    -0
      src/main/java/com/telpo/dipperposition/config/NettyServerConfig.java
  3. +17
    -33
      src/main/java/com/telpo/dipperposition/config/PositionConfig.java
  4. +12
    -33
      src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java

+ 6
- 0
pom.xml ファイルの表示

@@ -57,6 +57,12 @@
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>

<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>nacos-config-spring-boot-starter</artifactId>
<version>0.2.7</version>
</dependency>

<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>


+ 33
- 0
src/main/java/com/telpo/dipperposition/config/NettyServerConfig.java ファイルの表示

@@ -0,0 +1,33 @@
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.context.annotation.Configuration;

/**
* @program: gateway
* @description: jwt设置
* @author: linwl
* @create: 2020-06-18 17:45
*/
@Getter
@Setter
@Configuration
@NacosPropertySource(dataId="position-server", autoRefreshed=true)
public class NettyServerConfig {

@NacosValue(value = "${serverAddr}")
private String serverAddr;

@NacosValue(value = "${timeAsycPort:9011}")
private String timeAsycServerPort;

@NacosValue(value = "${posAsycPort}")
private String posAsycServerPort;

@NacosValue(value = "${starsAsycPort}")
private String starsAsycServerPort;

}

+ 17
- 33
src/main/java/com/telpo/dipperposition/config/PositionConfig.java ファイルの表示

@@ -1,5 +1,7 @@
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.co.PositionConfigInfo;
import lombok.Getter;
import lombok.Setter;
@@ -20,42 +22,24 @@ import org.springframework.context.annotation.Configuration;
@Getter
@Setter
@Configuration
@NacosPropertySource(dataId="pos", autoRefreshed=true)
public class PositionConfig {

//@Autowired
//private ConfigurableApplicationContext configurableApplicationContext;
//@Value(value = "${position.hello}")
//private String hello;
@NacosValue("${centerProvinceFilePath}")
String centerProvinceFilePath;

//@Value(value = "${spring.application.name}")
//private String name;
@NacosValue("${ipPositionRequestPath}")
String ipPositionRequestPath;
@NacosValue("${ipPositionRequestKey}")
String ipPositionRequestKey;
@NacosValue("${centerProvince}")
String centerProvince;

// @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;

PositionConfig()
{
//hello = configurableApplicationContext.getEnvironment().getProperty("position.hello");
//name = configurableApplicationContext.getEnvironment().getProperty("spring.application.name");
}
//
// @Bean (name = "positionConfigInfo")
// public PositionConfigInfo positionConfigInfo(){
// PositionConfigInfo configInfo = new PositionConfigInfo();
// configInfo.setServerAddr(this.serverAddr);
// configInfo.setTimeAsycServerPort(this.timeAsycServerPort);
// configInfo.setPosAsycServerPort(this.posAsycServerPort);
// configInfo.setStarsAsycServerPort(this.starsAsycServerPort);
// System.out.print(configInfo.toString());
// return configInfo;
// }
@NacosValue("${astServer}")
String astServer;
@NacosValue("${astPosAstPort}")
int posAstPort;
@NacosValue("${astTimeout}")
int astTimeout;
}

+ 12
- 33
src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java ファイルの表示

@@ -1,5 +1,7 @@
package com.telpo.dipperposition.handler;

import com.telpo.dipperposition.config.NettyServerConfig;
import com.telpo.dipperposition.config.PositionConfig;
import com.telpo.dipperposition.enums.DipperReturnValue;
import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService;
import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService;
@@ -36,33 +38,10 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
@Autowired
private IDipperDataAsyncTaskService dipperDataAsyncTaskService;

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

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

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


@Value("${pos.centerProvinceFilePath}")
String centerProvinceFilePath;

@Value("${pos.ipPositionRequestPath}")
String ipPositionRequestPath;
@Value("${pos.ipPositionRequestKey}")
String ipPositionRequestKey;
@Value("${pos.centerProvince}")
String centerProvince;


@Value("${pos.ast.server}")
String astServer;
@Value("${pos.ast.posAstPort}")
int posAstPort;
@Value("${pos.ast.timeout}")
int astTimeout;
@Autowired
private NettyServerConfig nettyServerConfig;
@Autowired
private PositionConfig positionConfig;
/**
* 客户端连接会触发
*/
@@ -79,10 +58,10 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
//通知客户端链接建立成功
// 默认返回取得时间成功
String ackAckCheckRef = "233E0101020004020A1D";
if (Integer.parseInt(posAsycServerPort) == channel.localAddress().getPort()) {
if (Integer.parseInt(nettyServerConfig.getPosAsycServerPort()) == channel.localAddress().getPort()) {
ackAckCheckRef = "233E010102000401091C";
}
if (Integer.parseInt(starsAsycServerPort) == channel.localAddress().getPort()) {
if (Integer.parseInt(nettyServerConfig.getStarsAsycServerPort()) == channel.localAddress().getPort()) {
ackAckCheckRef = "233E010102000421293C";
}
//String str = "通知客户端链接建立成功" + " " + LocalDateTime.now() + " " + channel.localAddress().getHostString() +
@@ -129,10 +108,10 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {

if (AST_POS_CMD.equals(recvmg)) {
channelAns = dipperAstPosAsyncTaskService.pushAstPos(ipAddress,
centerProvinceFilePath,
centerProvince,
ipPositionRequestPath,
ipPositionRequestKey);
positionConfig.getCenterProvinceFilePath(),
positionConfig.getCenterProvince(),
positionConfig.getIpPositionRequestPath(),
positionConfig.getIpPositionRequestKey());
buf = Unpooled.buffer(channelAns.getBytes().length);
}



読み込み中…
キャンセル
保存