...
|
...
|
@@ -24,20 +24,20 @@ import java.util.concurrent.Executors; |
|
|
* Created by yoho on 2016/9/20.
|
|
|
*/
|
|
|
public class TwemproxyTask extends Task {
|
|
|
|
|
|
private static final String STANDALONE = "0.0.0.0";
|
|
|
|
|
|
private int monitPort;
|
|
|
|
|
|
private String name;
|
|
|
|
|
|
private int moId;
|
|
|
private MObjectInfo moInfo;
|
|
|
|
|
|
@Getter
|
|
|
@Setter
|
|
|
private List<MObjectInfo> mObjectInfoList;
|
|
|
|
|
|
|
|
|
public TwemproxyTask(String url, int monitPort, String name, int moId, AlarmMsgService alarmMsgService,
|
|
|
public TwemproxyTask(String url, int monitPort, String name, MObjectInfo moInfo, AlarmMsgService alarmMsgService,
|
|
|
SnsMobileConfig snsMobileConfig) {
|
|
|
|
|
|
super(url, alarmMsgService, snsMobileConfig);
|
...
|
...
|
@@ -46,7 +46,7 @@ public class TwemproxyTask extends Task { |
|
|
|
|
|
this.name = name;
|
|
|
|
|
|
this.moId = moId;
|
|
|
this.moInfo = moInfo;
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
@@ -54,6 +54,13 @@ public class TwemproxyTask extends Task { |
|
|
@Override
|
|
|
public void doTask() {
|
|
|
|
|
|
//独立redis的伪twemproxy
|
|
|
if (StringUtils.equals(STANDALONE, moInfo.getMoHostIp())) {
|
|
|
doAloneTask();
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
String info = TelnetUtils.getResult(this.getIp(), this.monitPort);
|
|
|
|
|
|
TwemproxyInfo twemproxyInfo = null;
|
...
|
...
|
@@ -67,13 +74,13 @@ public class TwemproxyTask extends Task { |
|
|
this.getAlarmMsgService().sendSms("Twemproxy", "Failed to query Twemproxy " + this.getUrl() + " monitor info.", this.getSnsMobileConfig().getRedisMobile());
|
|
|
|
|
|
DEBUG.error("Failed to query twemproxy {} monitor info...error {} ", this.getUrl(), e);
|
|
|
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
twemproxyInfo.setType(name);
|
|
|
|
|
|
twemproxyInfo.setMoId(String.valueOf(this.moId));
|
|
|
twemproxyInfo.setMoId(String.valueOf(this.moInfo.getMoId()));
|
|
|
|
|
|
//构建redis与twemproxy的关系
|
|
|
Map<String, String> relationMaps = new HashMap<>();
|
...
|
...
|
@@ -192,4 +199,48 @@ public class TwemproxyTask extends Task { |
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
//伪twemproxy构造
|
|
|
private void doAloneTask() {
|
|
|
TwemproxyInfo twemproxyInfo = new TwemproxyInfo(STANDALONE, 6379);
|
|
|
|
|
|
twemproxyInfo.setUpTime(0);
|
|
|
|
|
|
twemproxyInfo.setType(name);
|
|
|
|
|
|
twemproxyInfo.setMoId(String.valueOf(this.moInfo.getMoId()));
|
|
|
|
|
|
twemproxyInfo.setCurrConnections(0);
|
|
|
|
|
|
twemproxyInfo.setState("OK");
|
|
|
|
|
|
Map<String, Long> requestMap = new HashMap<>();
|
|
|
|
|
|
for (MObjectInfo mObjectInfo : mObjectInfoList) {
|
|
|
|
|
|
String tags[] = mObjectInfo.getMoTags().split(",");
|
|
|
|
|
|
String port = "";
|
|
|
|
|
|
for (String tag : tags) {
|
|
|
|
|
|
if (tag.startsWith("port:")) {
|
|
|
port = tag.split(":", 2)[1];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(port)) {
|
|
|
|
|
|
requestMap.put(mObjectInfo.getMoHostIp() + ":" + port, 0L);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
twemproxyInfo.setRequestMap(requestMap);
|
|
|
|
|
|
//存储
|
|
|
Constants.TWEMPROXY_INFO_MAP.put(this.getUrl(), twemproxyInfo);
|
|
|
|
|
|
dispatchRedisTask(twemproxyInfo);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|