TopoSwitchCtrl.java
3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package com.ui.ctrl;
import com.ui.contants.HttpUriContants;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 限流调整
*
* @author bblu 2016-10-26
*/
@Controller
@RequestMapping("topoSwitch")
public class TopoSwitchCtrl {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
HttpRestClient httpRestClient;
@Autowired
TopoSwitchUtil topoSwitchUtil;
@RequestMapping(value = "toTopoSwitch")
public ModelAndView toTopoSwitch() {
ModelAndView mdv = new ModelAndView("switch/switch_topology");
return mdv;
}
@RequestMapping(value = "toAppTopoSwitch")
public ModelAndView toAppTopoSwitch() {
ModelAndView mdv = new ModelAndView("switch/switch_topology_app");
return mdv;
}
/**
* 展示当前配置
*
* @return ModelAndView
*/
@RequestMapping(value = "getNgixnStatus")
@ResponseBody
public BaseResponse getNgixnStatus() {
Map<String, Object> resultMap = new HashMap<>();
try{
//nginx
BaseResponse<Map<String, List<Map<String, Object>>>> response = httpRestClient.exchangeForget(HttpUriContants.VIEW_NGINX_CONF, new ParameterizedTypeReference<BaseResponse<Map<String, List<Map<String, Object>>>>>() {
}, null);
Map<String, List<Map<String, Object>>> map = response.getData();
List<Map<String, Object>> qcloudList = map.get("qcloudList");
List<Map<String, Object>> qcloudaz2List = map.get("qcloudaz2List");
List<String> az1HostIps=(List<String>)(map.get("gatewayServerHosts").get(0).get("az1ServerHosts"));
List<String> az2HostIps=(List<String>)(map.get("gatewayServerHosts").get(0).get("az2ServerHosts"));
List<String> grayHostIps=(List<String>)(map.get("gatewayServerHosts").get(0).get("grayServerHosts"));
List<String> ls=topoSwitchUtil.getNginxLocationType(az1HostIps,az2HostIps,grayHostIps,qcloudList);
String qqApiNginx = ls.get(0);
String qqGrayNginx = ls.get(1);
ls=topoSwitchUtil.getNginxLocationType(az1HostIps,az2HostIps,grayHostIps,qcloudaz2List);
String az2ApiNginx = ls.get(0);
String az2GrayNginx = ls.get(1);
resultMap.put("az2ApiNginx", az2ApiNginx);
resultMap.put("az2GrayNginx", az2GrayNginx);
resultMap.put("qqApiNginx", qqApiNginx);
resultMap.put("qqGrayNginx", qqGrayNginx);
resultMap.put("defaultDns", httpRestClient.defaultGet(HttpUriContants.CENTERSWITCH_DEFAULT_DNS,String.class));
resultMap.put("luaType", topoSwitchUtil.getLuaType());
}catch (Exception e){
logger.error(" TopoSwitchCtrl - getNgixnStatus - err", e);
}
return new BaseResponse(resultMap);
}
}