|
@@ -4,6 +4,7 @@ import com.ui.contants.HttpUriContants; |
|
@@ -4,6 +4,7 @@ import com.ui.contants.HttpUriContants; |
4
|
import com.ui.http.HttpRestClient;
|
4
|
import com.ui.http.HttpRestClient;
|
5
|
import com.ui.model.BaseResponse;
|
5
|
import com.ui.model.BaseResponse;
|
6
|
import com.ui.model.domain.CenterSwitchModel;
|
6
|
import com.ui.model.domain.CenterSwitchModel;
|
|
|
7
|
+import org.apache.commons.lang.StringUtils;
|
7
|
import org.slf4j.Logger;
|
8
|
import org.slf4j.Logger;
|
8
|
import org.slf4j.LoggerFactory;
|
9
|
import org.slf4j.LoggerFactory;
|
9
|
import org.springframework.beans.factory.annotation.Autowired;
|
10
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -56,6 +57,54 @@ public class CenterSwitchCtrl { |
|
@@ -56,6 +57,54 @@ public class CenterSwitchCtrl { |
56
|
return new ModelAndView("switch/new_center_switch");
|
57
|
return new ModelAndView("switch/new_center_switch");
|
57
|
}
|
58
|
}
|
58
|
|
59
|
|
|
|
60
|
+ @RequestMapping("/switchMysqlCheckStatus")
|
|
|
61
|
+ @ResponseBody
|
|
|
62
|
+ public BaseResponse switchMysqlCheckStatus(){
|
|
|
63
|
+ BaseResponse baseResponse = httpClient.defaultPost(HttpUriContants.CENTERSWITCH_SWITCH_CHECK_MYSQL_STATUS, null, BaseResponse.class);
|
|
|
64
|
+ String checkStatus=(String)baseResponse.getData();
|
|
|
65
|
+ String desc[]=checkStatus.split("</br>");
|
|
|
66
|
+ int count=0;
|
|
|
67
|
+ int dbnums=0;
|
|
|
68
|
+ for(String str:desc){
|
|
|
69
|
+ if(StringUtils.isBlank(str)||str.indexOf("begin")>=0||str.indexOf("end")>=0){
|
|
|
70
|
+ continue;
|
|
|
71
|
+ }
|
|
|
72
|
+ log.error("mysqlstatus==="+str);
|
|
|
73
|
+ if(count==0){
|
|
|
74
|
+ if(str.startsWith("172")||str.startsWith("10")){
|
|
|
75
|
+ dbnums++;
|
|
|
76
|
+ count++;
|
|
|
77
|
+ }else{
|
|
|
78
|
+ baseResponse.setCode(201);
|
|
|
79
|
+ baseResponse.setMessage("db状态校验不通过");
|
|
|
80
|
+ break;
|
|
|
81
|
+ }
|
|
|
82
|
+ }else if(count==1||count==2){
|
|
|
83
|
+ if(str.equalsIgnoreCase("yes")){
|
|
|
84
|
+ count++;
|
|
|
85
|
+ }else{
|
|
|
86
|
+ baseResponse.setCode(202);
|
|
|
87
|
+ baseResponse.setMessage("db状态校验不通过");
|
|
|
88
|
+ break;
|
|
|
89
|
+ }
|
|
|
90
|
+ }else if(count==3){
|
|
|
91
|
+ if(str.equalsIgnoreCase("0")){
|
|
|
92
|
+ count=0;
|
|
|
93
|
+ }else{
|
|
|
94
|
+ baseResponse.setCode(203);
|
|
|
95
|
+ baseResponse.setMessage("db状态校验不通过");
|
|
|
96
|
+ break;
|
|
|
97
|
+ }
|
|
|
98
|
+ }
|
|
|
99
|
+
|
|
|
100
|
+ }
|
|
|
101
|
+ if(dbnums<=0){
|
|
|
102
|
+ baseResponse.setCode(204);
|
|
|
103
|
+ baseResponse.setMessage("db状态校验不通过,dbnum is 0");
|
|
|
104
|
+ }
|
|
|
105
|
+ return baseResponse;
|
|
|
106
|
+ }
|
|
|
107
|
+
|
59
|
@RequestMapping("/doExeAndCheck")
|
108
|
@RequestMapping("/doExeAndCheck")
|
60
|
public BaseResponse doExeAndCheck(CenterSwitchModel centerSwitchModel){
|
109
|
public BaseResponse doExeAndCheck(CenterSwitchModel centerSwitchModel){
|
61
|
BaseResponse baseResponse = httpClient.defaultPost(HttpUriContants.CENTERSWITCH_SWITCH_CHECK, centerSwitchModel, BaseResponse.class);
|
110
|
BaseResponse baseResponse = httpClient.defaultPost(HttpUriContants.CENTERSWITCH_SWITCH_CHECK, centerSwitchModel, BaseResponse.class);
|