Authored by qinchao

增加方法刷新 cobar

package com.ui.User;
import com.ui.http.HttpRestClient;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* Created by craig.qin
*/
@Component
public class DnsRefreshLocal {
@Autowired
HttpRestClient httpClient;
public String dnsJustForShell(String domain, String cloud, String type, String operate, String record, String value) {
if (StringUtils.isBlank(domain) || StringUtils.isBlank(cloud) || StringUtils.isBlank(operate)) {
return "param error";
}
Map<String, String> map=new HashMap<>();
map.put("domain",domain);
map.put("cloud",cloud);
map.put("operate",operate);
map.put("record",StringUtils.isBlank(record)?"":record);
map.put("type",StringUtils.isBlank(type)?"":type);
map.put("value",StringUtils.isBlank(value)?"":value);
return httpClient.defaultGet("/internalDns/justForShell",String.class,map);
}
public String dnsJustForShellUpdate( String cloud, String record, String value) {
String domain="yohoops.org";
String operate="update";
String type="";
return this.dnsJustForShell(domain,cloud,type,operate,record,value);
}
public String dnsJustForShellCommit( String cloud) {
String domain="yohoops.org";
String operate="commit";
return this.dnsJustForShell(domain,cloud,"",operate,"","");
}
}
... ...
package com.ui.ctrl;
import com.ui.User.DnsRefreshLocal;
import com.ui.contants.HttpUriContants;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
... ... @@ -28,7 +29,7 @@ public class MysqlMonitorCtrl {
HttpRestClient httpRestClient;
@Autowired
OuterIntfCtrl outerIntfCtrl;
DnsRefreshLocal dnsRefreshLocal;
@RequestMapping("/toMysqlMonitor")
public ModelAndView toMysqlMonitor() {
... ... @@ -110,11 +111,11 @@ public class MysqlMonitorCtrl {
for(String cloud:cloud_array){
String record="write."+app;
String value=ip;
outerIntfCtrl.dnsJustForShellUpdate(cloud,record,value);
dnsRefreshLocal.dnsJustForShellUpdate(cloud,record,value);
infos.add("修改cloud"+cloud+"域名 "+record +"->"+ip);
infos.add("开始当前云刷新dns");
outerIntfCtrl.dnsJustForShellCommit(cloud);
dnsRefreshLocal.dnsJustForShellCommit(cloud);
infos.add("域名刷新完成");
}
... ...
... ... @@ -3,6 +3,7 @@ package com.ui.ctrl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ui.User.DnsRefreshLocal;
import com.ui.User.UserAuthLocal;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
... ... @@ -48,6 +49,9 @@ public class OuterIntfCtrl {
@Autowired
UserAuthLocal userAuthLocal;
@Autowired
DnsRefreshLocal dnsRefreshLocal;
/**
* 对外接口,通用指标上报
*/
... ... @@ -296,35 +300,19 @@ public class OuterIntfCtrl {
@RequestMapping("/dnsJustForShell")
@ResponseBody
public String dnsJustForShell(String domain, String cloud, String type, String operate, String record, String value) {
if (StringUtils.isBlank(domain) || StringUtils.isBlank(cloud) || StringUtils.isBlank(operate)) {
return "param error";
}
Map<String, String> map=new HashMap<>();
map.put("domain",domain);
map.put("cloud",cloud);
map.put("operate",operate);
map.put("record",StringUtils.isBlank(record)?"":record);
map.put("type",StringUtils.isBlank(type)?"":type);
map.put("value",StringUtils.isBlank(value)?"":value);
return httpClient.defaultGet("/internalDns/justForShell",String.class,map);
return dnsRefreshLocal.dnsJustForShell(domain, cloud, type, operate, record, value);
}
@RequestMapping("/dnsJustForShellUpdate")
@ResponseBody
public String dnsJustForShellUpdate( String cloud, String record, String value) {
String domain="yohoops.org";
String operate="update";
String type="";
return this.dnsJustForShell(domain,cloud,type,operate,record,value);
return dnsRefreshLocal.dnsJustForShellUpdate(cloud,record,value);
}
@RequestMapping("/dnsJustForShellCommit")
@ResponseBody
public String dnsJustForShellCommit( String cloud) {
String domain="yohoops.org";
String operate="commit";
return this.dnsJustForShell(domain,cloud,"",operate,"","");
return dnsRefreshLocal.dnsJustForShellCommit(cloud);
}
... ...