|
@@ -19,9 +19,13 @@ import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.config.YamlMapFactoryBean; |
|
|
import org.springframework.beans.factory.config.YamlMapFactoryBean; |
|
|
|
|
|
import org.yaml.snakeyaml.Yaml; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
|
|
import java.io.FileInputStream; |
|
|
import java.io.InputStream; |
|
|
import java.io.InputStream; |
|
|
import java.net.InetSocketAddress; |
|
|
import java.net.InetSocketAddress; |
|
|
|
|
|
import java.util.Map; |
|
|
import java.util.Properties; |
|
|
import java.util.Properties; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -34,7 +38,7 @@ import java.util.Properties; |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
public class DipperPositionServer { |
|
|
public class DipperPositionServer { |
|
|
|
|
|
|
|
|
@Autowired PositionConfigInfo positionConfigInfo; |
|
|
|
|
|
|
|
|
// @Autowired PositionConfigInfo positionConfigInfo; |
|
|
private String serverAddr="172.16.192.26"; |
|
|
private String serverAddr="172.16.192.26"; |
|
|
private String timeAsycServerPort="9011"; |
|
|
private String timeAsycServerPort="9011"; |
|
|
private String posAsycServerPort="9013"; |
|
|
private String posAsycServerPort="9013"; |
|
@@ -42,6 +46,23 @@ public class DipperPositionServer { |
|
|
|
|
|
|
|
|
public DipperPositionServer() throws NacosException { |
|
|
public DipperPositionServer() throws NacosException { |
|
|
//String serverAddr = positionConfigInfo.getServerAddr(); |
|
|
//String serverAddr = positionConfigInfo.getServerAddr(); |
|
|
|
|
|
try { |
|
|
|
|
|
String serverAddr = "172.16.192.26"; |
|
|
|
|
|
String dataId = "dipperposition-service"; |
|
|
|
|
|
String group = "DEFAULT_GROUP"; |
|
|
|
|
|
Properties properties = new Properties(); |
|
|
|
|
|
properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr); |
|
|
|
|
|
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 m2 = (Map) m1.get("position-server"); |
|
|
|
|
|
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); |
|
|
} |
|
|
} |
|
|
/* |
|
|
/* |
|
|