|
|
@@ -2,6 +2,7 @@ package com.utic.its.common.xnet.client.handler;
|
|
|
|
|
|
import com.utic.its.common.dto.CenterDto;
|
|
|
import com.utic.its.common.repository.ApplicationRepository;
|
|
|
+import com.utic.its.common.utils.IpUtils;
|
|
|
import com.utic.its.common.xnet.client.ItsAsnClientBootstrapFactory;
|
|
|
import com.utic.its.common.xnet.client.ItsAsnCommClient;
|
|
|
import com.utic.its.common.xnet.client.codec.ItsAsnClientDecoder;
|
|
|
@@ -44,6 +45,7 @@ public class ItsAsnClient implements Callable<Object> {
|
|
|
private Bootstrap bootstrap = null;
|
|
|
private ChannelFuture channelFuture = null;
|
|
|
private String ipAddress;
|
|
|
+ private String prevIpAddress;
|
|
|
private int port;
|
|
|
|
|
|
private NioEventLoopGroup eventLoopGroup = null;
|
|
|
@@ -71,7 +73,16 @@ public class ItsAsnClient implements Callable<Object> {
|
|
|
|
|
|
this.ipAddress = this.center.getIpAddress();
|
|
|
this.port = this.center.getCommPort();
|
|
|
-
|
|
|
+ String ipAddress2 = this.center.getIpAddress2();
|
|
|
+ if (IpUtils.isUsableIp(ipAddress2) && !this.center.getIpAddress().equals(ipAddress2)) {
|
|
|
+ // 이중화 IP Address 가 존재함
|
|
|
+ if (this.ipAddress.equals(this.prevIpAddress)) {
|
|
|
+ // 이전에 사용한 IP Address 가 첫번째 주소였다면 이번에는 2번째 주소를 할당해서 연결을 시도한다.
|
|
|
+ this.ipAddress = ipAddress2;
|
|
|
+ }
|
|
|
+ log.info("ItsAsnClient >>>>>>>>Start: Dual Ip Address: [{}], ipAddress1/2: {}/{}",
|
|
|
+ this.center.getCenterId(), this.center.getIpAddress(), this.center.getIpAddress2());
|
|
|
+ }
|
|
|
if (this.clusterId > 0) {
|
|
|
log.info("ItsAsnClient >>>>>>>>Start: [{}, {}], {}, clusterId {}, realClusterId: {}",
|
|
|
this.center.getCenterId(), this.ipAddress, this.port, this.center.getClusterId(), this.center.getRealClusterId());
|
|
|
@@ -146,7 +157,7 @@ public class ItsAsnClient implements Callable<Object> {
|
|
|
|
|
|
/**
|
|
|
* 연결 성공시 처리 이벤트
|
|
|
- * @param channel
|
|
|
+ * @param channel: Opened netty channel
|
|
|
*/
|
|
|
protected void channelOpen(Channel channel) {
|
|
|
MDC.put("id", this.center.getLogKey());
|
|
|
@@ -167,12 +178,13 @@ public class ItsAsnClient implements Callable<Object> {
|
|
|
|
|
|
/**
|
|
|
* 연결 종료시 처리 이벤트
|
|
|
- * @param channel
|
|
|
+ * @param channel: Closed netty channel
|
|
|
*/
|
|
|
protected synchronized void channelClosed(Channel channel) {
|
|
|
try {
|
|
|
MDC.put("id", this.center.getLogKey());
|
|
|
|
|
|
+ this.prevIpAddress = this.ipAddress; // 현재 연결한 ip address 를 백업받아 놓는다.
|
|
|
log.warn("ItsAsnClient channelClosed: [{}, {}], {}, Channel: {}, RetryConnectSeconds: {} seconds.",
|
|
|
this.center.getCenterId(), this.center.getIpAddress(), this.center.getCommPort(), channel, this.retryConnectSeconds);
|
|
|
|