|
|
@@ -31,12 +31,12 @@ public abstract class AbstractClusterSlaveService {
|
|
|
private final List<ClusterSlave> clientTasks = Collections.synchronizedList(new ArrayList<>());
|
|
|
|
|
|
@Getter
|
|
|
- private final AbstractClusterConfig clusterConfig;
|
|
|
+ protected final AbstractClusterConfig clusterConfig;
|
|
|
+ private final AbstractClusterMasterService masterService;
|
|
|
|
|
|
private ScheduledFuture<?> taskFuture = null;
|
|
|
private ClusterSlaveBootstrapFactory bootstrapFactory;
|
|
|
|
|
|
-
|
|
|
@PostConstruct
|
|
|
void init() {
|
|
|
this.bootstrapFactory = new ClusterSlaveBootstrapFactory(1, 5);
|
|
|
@@ -226,15 +226,13 @@ public abstract class AbstractClusterSlaveService {
|
|
|
public void onNotifyClusterNetworkState(ClusterNode clusterNode, boolean isActive) {
|
|
|
log.info("ClusterNodeId: {}, ClusterSlaveService.onNotifyClusterNetworkState: fromClusterNodeId: {}, isNetActive; {}",
|
|
|
this.clusterConfig.getId(), clusterNode.getId(), isActive);
|
|
|
- if (isActive) {
|
|
|
- // 네트워크가 연결되었으면 클러스터 메시지를 전송
|
|
|
- ClusterMessage clusterMsg = getClusterMessage();
|
|
|
- sendSyncData(clusterNode, clusterMsg);
|
|
|
- }
|
|
|
- else {
|
|
|
+
|
|
|
+ if (!isActive) {
|
|
|
// master 의 네트워크 상태를 확인하고 master 네트워크의 연결을 종료시킨다.
|
|
|
if (clusterNode.getElectionState().getState() != ClusterNET.CLOSED) {
|
|
|
Channel channel = clusterNode.getElectionState().getChannel();
|
|
|
+ log.info("ClusterNodeId: {}, ClusterSlaveService.onNotifyClusterNetworkState: fromClusterNodeId: {}, Try SlaveNetwork Close. channel: {}",
|
|
|
+ this.clusterConfig.getId(), clusterNode.getId(), channel);
|
|
|
if (channel != null) {
|
|
|
channel.flush();
|
|
|
channel.disconnect();
|
|
|
@@ -243,7 +241,21 @@ public abstract class AbstractClusterSlaveService {
|
|
|
clusterNode.getElectionState().disConnect();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ this.masterService.electionMasterCluster();
|
|
|
+
|
|
|
+ if (isActive) {
|
|
|
+ // 네트워크가 연결되었으면 클러스터 메시지를 전송
|
|
|
+ ClusterMessage clusterMsg = getClusterMessage();
|
|
|
+ sendSyncData(clusterNode, clusterMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isActive) {
|
|
|
+ this.masterService.onClusterChannelActive(clusterNode);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.masterService.onClusterChannelInactive(clusterNode);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|