Authored by jack

增加独立redis监控

... ... @@ -96,8 +96,10 @@ public class OverViewJob implements Callable {
if (null != oneView) {
InterVar.overViewMaps.put(moId, overViewModel);
} else {
if (InterVar.overViewMaps.containsKey(moId)) {
InterVar.overViewMaps.get(moId).setState(overViewModel.getState());
}
}
DEBUG.info("End to execute over view job in moid {}", this.moId);
}
... ...
... ... @@ -94,7 +94,7 @@ public class QueueViewJob implements Callable {
return;
} catch (Exception e) {
DEBUG.error("Failed to execute monitor task , error {} ", e);
DEBUG.error("Failed to execute queue view task , error {} ", e);
return;
}
... ...
... ... @@ -67,6 +67,13 @@ public class TwemproxyInfo {
}
}
public TwemproxyInfo(String ip, int port) {
this.ip = ip;
this.port = port;
}
public void buildServersInfoByRelations(Map<String, String> relationMaps) {
... ...
... ... @@ -164,7 +164,7 @@ public class RedisMonitorImpl {
return null;
}
TwemproxyTask twemproxyTask = new TwemproxyTask(url, mPort, name, mObjectInfo.getMoId(), alarmMsgService, snsMobileConfig);
TwemproxyTask twemproxyTask = new TwemproxyTask(url, mPort, name, mObjectInfo, alarmMsgService, snsMobileConfig);
twemproxyTask.setMObjectInfoList(mObjectInfos);
... ...
... ... @@ -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;
... ... @@ -73,7 +80,7 @@ public class TwemproxyTask extends Task {
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);
}
}
... ...