@@ -0,0 +1,33 @@ | |||||
package com.telpo.dipperposition.co; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import lombok.ToString; | |||||
import okhttp3.*; | |||||
import okhttp3.internal.ws.RealWebSocket; | |||||
import org.springframework.beans.factory.annotation.Value; | |||||
import org.springframework.context.annotation.Lazy; | |||||
import org.springframework.stereotype.Component; | |||||
import javax.net.SocketFactory; | |||||
/** | |||||
* @program: RzlAccount | |||||
* @description: 融智联账号配置 | |||||
* @author: king | |||||
* @create: 2021-01-12 14:02 | |||||
**/ | |||||
@Getter | |||||
@Setter | |||||
@Component | |||||
public class PositionConfigInfo { | |||||
private String serverAddr; | |||||
private String timeAsycServerPort; | |||||
private String posAsycServerPort; | |||||
private String starsAsycServerPort; | |||||
} |
@@ -1,42 +0,0 @@ | |||||
package com.telpo.dipperposition.co; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import lombok.ToString; | |||||
import org.springframework.beans.factory.annotation.Value; | |||||
import org.springframework.context.annotation.Lazy; | |||||
import org.springframework.stereotype.Component; | |||||
/** | |||||
* @program: RzlAccount | |||||
* @description: 融智联账号配置 | |||||
* @author: king | |||||
* @create: 2021-01-12 14:02 | |||||
**/ | |||||
@Lazy | |||||
@Getter | |||||
@Setter | |||||
@ToString | |||||
@Component | |||||
public class RzlAccount { | |||||
@Value("${position.hello}") | |||||
private String hello; | |||||
RzlAccount() | |||||
{ | |||||
} | |||||
private static RzlAccount instance; | |||||
public static RzlAccount getInstance(){ | |||||
if (instance==null){ | |||||
try { | |||||
Thread.sleep(100); | |||||
} catch (InterruptedException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
instance = new RzlAccount(); | |||||
} | |||||
return instance; | |||||
} | |||||
} |
@@ -1,10 +1,14 @@ | |||||
package com.telpo.dipperposition.config; | package com.telpo.dipperposition.config; | ||||
import com.telpo.dipperposition.co.PositionConfigInfo; | |||||
import lombok.Getter; | import lombok.Getter; | ||||
import lombok.Setter; | import lombok.Setter; | ||||
import lombok.ToString; | import lombok.ToString; | ||||
import okhttp3.OkHttpClient; | |||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.beans.factory.annotation.Value; | |||||
import org.springframework.context.ConfigurableApplicationContext; | import org.springframework.context.ConfigurableApplicationContext; | ||||
import org.springframework.context.annotation.Bean; | |||||
import org.springframework.context.annotation.Configuration; | import org.springframework.context.annotation.Configuration; | ||||
/** | /** | ||||
@@ -15,17 +19,28 @@ import org.springframework.context.annotation.Configuration; | |||||
*/ | */ | ||||
@Getter | @Getter | ||||
@Setter | @Setter | ||||
@ToString | |||||
@Configuration | @Configuration | ||||
public class PositionConfig { | public class PositionConfig { | ||||
@Autowired | |||||
private ConfigurableApplicationContext configurableApplicationContext; | |||||
//@Autowired | |||||
//private ConfigurableApplicationContext configurableApplicationContext; | |||||
//@Value(value = "${position.hello}") | //@Value(value = "${position.hello}") | ||||
private String hello; | |||||
//private String hello; | |||||
//@Value(value = "${spring.application.name}") | //@Value(value = "${spring.application.name}") | ||||
private String name; | |||||
//private String name; | |||||
@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() | PositionConfig() | ||||
{ | { | ||||
@@ -33,16 +48,14 @@ public class PositionConfig { | |||||
//name = configurableApplicationContext.getEnvironment().getProperty("spring.application.name"); | //name = configurableApplicationContext.getEnvironment().getProperty("spring.application.name"); | ||||
} | } | ||||
private static PositionConfig instance; | |||||
public static PositionConfig getInstance(){ | |||||
if (instance==null){ | |||||
try { | |||||
Thread.sleep(100); | |||||
} catch (InterruptedException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
instance = new PositionConfig(); | |||||
} | |||||
return instance; | |||||
@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; | |||||
} | } | ||||
} | } |
@@ -1,5 +1,6 @@ | |||||
package com.telpo.dipperposition.server; | package com.telpo.dipperposition.server; | ||||
import com.telpo.dipperposition.config.PositionConfig; | |||||
import com.telpo.dipperposition.handler.ServerChannelInitializer; | import com.telpo.dipperposition.handler.ServerChannelInitializer; | ||||
import com.telpo.dipperposition.service.IDipperDataAsyncTaskService; | import com.telpo.dipperposition.service.IDipperDataAsyncTaskService; | ||||
import io.netty.bootstrap.ServerBootstrap; | import io.netty.bootstrap.ServerBootstrap; | ||||
@@ -24,18 +25,8 @@ import java.net.InetSocketAddress; | |||||
@Slf4j | @Slf4j | ||||
public class DipperPositionServer { | public class DipperPositionServer { | ||||
@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; | |||||
@Autowired | |||||
PositionConfig positionConfig; | |||||
/* | /* | ||||
* 时间同步进程线程 | * 时间同步进程线程 | ||||
*/ | */ | ||||
@@ -45,7 +36,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(serverAddr, Integer.parseInt(timeAsycServerPort)); | |||||
InetSocketAddress socketAddress = new InetSocketAddress(positionConfig.getServerAddr(), | |||||
Integer.parseInt(positionConfig.getTimeAsycServerPort())); | |||||
ServerBootstrap bootstrap = new ServerBootstrap() | ServerBootstrap bootstrap = new ServerBootstrap() | ||||
.group(mainThreadGroup, workThreadGroup) | .group(mainThreadGroup, workThreadGroup) | ||||
.channel(NioServerSocketChannel.class) | .channel(NioServerSocketChannel.class) | ||||
@@ -83,7 +75,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(serverAddr, Integer.parseInt(posAsycServerPort)); | |||||
InetSocketAddress socketAddress = new InetSocketAddress(positionConfig.getServerAddr(), | |||||
Integer.parseInt(positionConfig.getPosAsycServerPort())); | |||||
ServerBootstrap bootstrap = new ServerBootstrap() | ServerBootstrap bootstrap = new ServerBootstrap() | ||||
.group(mainThreadGroup, workThreadGroup) | .group(mainThreadGroup, workThreadGroup) | ||||
.channel(NioServerSocketChannel.class) | .channel(NioServerSocketChannel.class) | ||||
@@ -122,7 +115,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(serverAddr, Integer.parseInt(starsAsycServerPort)); | |||||
InetSocketAddress socketAddress = new InetSocketAddress(positionConfig.getServerAddr(), | |||||
Integer.parseInt(positionConfig.getStarsAsycServerPort())); | |||||
ServerBootstrap bootstrap = new ServerBootstrap() | ServerBootstrap bootstrap = new ServerBootstrap() | ||||
.group(mainThreadGroup, workThreadGroup) | .group(mainThreadGroup, workThreadGroup) | ||||
.channel(NioServerSocketChannel.class) | .channel(NioServerSocketChannel.class) | ||||
@@ -7,7 +7,6 @@ import com.telpo.dipperposition.config.SchedulingExecutorConfig; | |||||
import com.telpo.dipperposition.service.IDipperDataAsyncTaskService; | import com.telpo.dipperposition.service.IDipperDataAsyncTaskService; | ||||
import lombok.extern.slf4j.Slf4j; | 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.scheduling.annotation.Async; | import org.springframework.scheduling.annotation.Async; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||