|
|
@@ -152,6 +152,37 @@ public class RotaUticClientRestController {
|
|
|
return ResponseEntity.ok(result);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping(value = "/api/init/failback")
|
|
|
+ public ResponseEntity<?> failback() {
|
|
|
+ int resetCount = 0;
|
|
|
+ List<String> keySet = new ArrayList<>(ApplicationRepository.CENTER_MAP.keySet());
|
|
|
+ Collections.sort(keySet);
|
|
|
+ for (String key : keySet) {
|
|
|
+ CenterDto region = ApplicationRepository.CENTER_MAP.get(key);
|
|
|
+ if (region == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.clusterConfig.isEnabled()) {
|
|
|
+ if (region.getNetState().isAlive() &&
|
|
|
+ region.getActiveClusterId() > 0 &&
|
|
|
+ this.clusterConfig.getId() != region.getRealClusterId()) {
|
|
|
+ // 네트워크가 연결된 상태이면서 실제 연결된 네트워크가 현재 노드가 아닌경우
|
|
|
+ try {
|
|
|
+ if (region.getNetState().getChannel() != null) {
|
|
|
+ region.getNetState().getChannel().disconnect();
|
|
|
+ region.getNetState().getChannel().close();
|
|
|
+ region.getNetState().disConnect();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ // no logging
|
|
|
+ }
|
|
|
+ resetCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResponseEntity.ok("communication connect cluster reset failback ok. cluster: " + this.clusterConfig.getId() + ", reset count: " + resetCount);
|
|
|
+ }
|
|
|
@GetMapping(value = "/api/init/reset")
|
|
|
public ResponseEntity<?> reset() {
|
|
|
int resetCount = 0;
|
|
|
@@ -164,21 +195,18 @@ public class RotaUticClientRestController {
|
|
|
}
|
|
|
|
|
|
if (this.clusterConfig.isEnabled()) {
|
|
|
- if (region.getNetState().isAlive() && this.clusterConfig.getId() != region.getActiveClusterId()) {
|
|
|
- // 네트워크가 연결된 상태이면서 실제 연결된 네트워크가 현재 노드가 아닌경우
|
|
|
- if (this.clusterConfig.getId() != region.getRealClusterId()) {
|
|
|
- // 다른 노드에서 작업을 수행하기로 설정된 지역센터의 연결을 종료한다.
|
|
|
- try {
|
|
|
- if (region.getNetState().getChannel() != null) {
|
|
|
- region.getNetState().getChannel().disconnect();
|
|
|
- region.getNetState().getChannel().close();
|
|
|
- region.getNetState().disConnect();
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- // no logging
|
|
|
+ if (region.getNetState().isAlive() && region.getActiveClusterId() > 0) {
|
|
|
+ // 네트워크가 연결된 상태이면서 실제 연결된 네트워크가 존재하는 경우
|
|
|
+ try {
|
|
|
+ if (region.getNetState().getChannel() != null) {
|
|
|
+ region.getNetState().getChannel().disconnect();
|
|
|
+ region.getNetState().getChannel().close();
|
|
|
+ region.getNetState().disConnect();
|
|
|
}
|
|
|
- resetCount++;
|
|
|
+ } catch (Exception e) {
|
|
|
+ // no logging
|
|
|
}
|
|
|
+ resetCount++;
|
|
|
}
|
|
|
}
|
|
|
}
|