|
|
@@ -4,11 +4,7 @@ import com.alibaba.nacos.api.NacosFactory; |
|
|
|
import com.alibaba.nacos.api.PropertyKeyConst; |
|
|
|
import com.alibaba.nacos.api.config.ConfigService; |
|
|
|
import com.alibaba.nacos.api.exception.NacosException; |
|
|
|
import com.telpo.dipperposition.co.PositionConfigInfo; |
|
|
|
import com.telpo.dipperposition.config.AsyncExecutorConfig; |
|
|
|
import com.telpo.dipperposition.config.PositionConfig; |
|
|
|
import com.telpo.dipperposition.handler.ServerChannelInitializer; |
|
|
|
import com.telpo.dipperposition.service.IDipperDataAsyncTaskService; |
|
|
|
import io.netty.bootstrap.ServerBootstrap; |
|
|
|
import io.netty.channel.ChannelFuture; |
|
|
|
import io.netty.channel.ChannelOption; |
|
|
@@ -19,6 +15,8 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.yaml.snakeyaml.Yaml; |
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
import java.net.Inet4Address; |
|
|
|
import java.net.InetAddress; |
|
|
|
import java.net.InetSocketAddress; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Properties; |
|
|
@@ -34,31 +32,35 @@ import java.util.Properties; |
|
|
|
public class DipperPositionServer { |
|
|
|
|
|
|
|
// @Autowired PositionConfigInfo positionConfigInfo; |
|
|
|
private String serverAddr="172.16.192.26"; |
|
|
|
private String timeAsycServerPort="9011"; |
|
|
|
private String posAsycServerPort="9013"; |
|
|
|
private String starsAsycServerPort="9012"; |
|
|
|
private String serverAddr; |
|
|
|
private String timeAsycPort; |
|
|
|
private String posAsycPort; |
|
|
|
private String starsAsycPort; |
|
|
|
|
|
|
|
public DipperPositionServer() throws NacosException { |
|
|
|
//String serverAddr = positionConfigInfo.getServerAddr(); |
|
|
|
try { |
|
|
|
String serverAddr = "172.16.192.26"; |
|
|
|
InetAddress ip4 = Inet4Address.getLocalHost(); |
|
|
|
String dataId = "dipperposition-service"; |
|
|
|
String group = "DEFAULT_GROUP"; |
|
|
|
Properties properties = new Properties(); |
|
|
|
properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr); |
|
|
|
properties.put(PropertyKeyConst.SERVER_ADDR, ip4); |
|
|
|
ConfigService configService = NacosFactory.createConfigService(properties); |
|
|
|
String content = configService.getConfig(dataId, group, 5000); |
|
|
|
|
|
|
|
ByteArrayInputStream tInputStringStream = new ByteArrayInputStream(content.getBytes()); |
|
|
|
Yaml yaml = new Yaml(); |
|
|
|
Map m1 = (Map) yaml.load(tInputStringStream); |
|
|
|
Map m1 = yaml.load(tInputStringStream); |
|
|
|
Map m2 = (Map) m1.get("position-server"); |
|
|
|
log.info("Map server is:" + m2.get("serverAddr")); |
|
|
|
this.serverAddr = (String)m2.get("serverAddr"); |
|
|
|
this.timeAsycPort = (String)m2.get("timeAsycPort"); |
|
|
|
this.posAsycPort = (String)m2.get("posAsycPort"); |
|
|
|
this.starsAsycPort = (String)m2.get("starsAsycPort"); |
|
|
|
//log.info("Map server is:" + m2.get("serverAddr")); |
|
|
|
} catch (Exception ex) { |
|
|
|
ex.printStackTrace(); |
|
|
|
} |
|
|
|
log.info("Config serverAddr is " + serverAddr); |
|
|
|
//log.info("Config serverAddr is " + serverAddr); |
|
|
|
} |
|
|
|
/* |
|
|
|
* 时间同步进程线程 |
|
|
@@ -70,7 +72,7 @@ public class DipperPositionServer { |
|
|
|
//new 一个工作线程组 |
|
|
|
EventLoopGroup workThreadGroup = new NioEventLoopGroup(200); |
|
|
|
InetSocketAddress socketAddress = new InetSocketAddress(serverAddr, |
|
|
|
Integer.parseInt(timeAsycServerPort)); |
|
|
|
Integer.parseInt(timeAsycPort)); |
|
|
|
ServerBootstrap bootstrap = new ServerBootstrap() |
|
|
|
.group(mainThreadGroup, workThreadGroup) |
|
|
|
.channel(NioServerSocketChannel.class) |
|
|
@@ -109,7 +111,7 @@ public class DipperPositionServer { |
|
|
|
//new 一个工作线程组 |
|
|
|
EventLoopGroup workThreadGroup = new NioEventLoopGroup(200); |
|
|
|
InetSocketAddress socketAddress = new InetSocketAddress(serverAddr, |
|
|
|
Integer.parseInt(posAsycServerPort)); |
|
|
|
Integer.parseInt(posAsycPort)); |
|
|
|
ServerBootstrap bootstrap = new ServerBootstrap() |
|
|
|
.group(mainThreadGroup, workThreadGroup) |
|
|
|
.channel(NioServerSocketChannel.class) |
|
|
@@ -149,7 +151,7 @@ public class DipperPositionServer { |
|
|
|
//new 一个工作线程组 |
|
|
|
EventLoopGroup workThreadGroup = new NioEventLoopGroup(200); |
|
|
|
InetSocketAddress socketAddress = new InetSocketAddress(serverAddr, |
|
|
|
Integer.parseInt(starsAsycServerPort)); |
|
|
|
Integer.parseInt(starsAsycPort)); |
|
|
|
ServerBootstrap bootstrap = new ServerBootstrap() |
|
|
|
.group(mainThreadGroup, workThreadGroup) |
|
|
|
.channel(NioServerSocketChannel.class) |
|
|
|