Authored by jack

增加日志

... ... @@ -123,7 +123,7 @@ public class RedisCtrl {
RedisInfo redisInfo = Constants.REDIS_INFO_MAP.get(entry.getKey());
DEBUG.info("Twemproxy {} contains redis {} ",twemproxy,redisInfo);
RedisVo redisVo = buildRedisVo(redisInfo);
redisInfoList.add(redisVo);
... ...
... ... @@ -3,7 +3,10 @@ package com.monitor.middleware.redis.task;
import com.monitor.middleware.redis.constants.Constants;
import com.monitor.middleware.redis.model.RedisInfo;
import com.sun.org.apache.xml.internal.resolver.helpers.Debug;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;
import java.text.DecimalFormat;
... ... @@ -15,6 +18,8 @@ import java.util.Map;
*/
public class RedisTask extends Task {
public static final Logger DEBUG = LoggerFactory.getLogger(RedisTask.class);
private Long requests = 0L;
public RedisTask(String url, Long requests) {
... ... @@ -27,31 +32,39 @@ public class RedisTask extends Task {
@Override
public void doTask() {
Jedis client = new Jedis(this.getIp(), this.getPort(), 2 * 1000);
String info = client.info();
DEBUG.info("Start to do redis {} task ", this.getIp() + ":" + this.getPort());
try {
Jedis client = new Jedis(this.getIp(), this.getPort(), 2 * 1000);
client.close();
String info = client.info();
Map<String, String> infoMap = buildInfo(info);
client.close();
RedisInfo redisInfo = buildRedisInfo(infoMap);
Map<String, String> infoMap = buildInfo(info);
redisInfo.setRequests(this.requests);
RedisInfo redisInfo = buildRedisInfo(infoMap);
long reqCaps = 0L;
redisInfo.setRequests(this.requests);
//每秒请求数
if (Constants.REDIS_INFO_MAP.containsKey(this.getUrl())) {
long reqCaps = 0L;
reqCaps = (this.requests - Constants.REDIS_INFO_MAP.get(this.getUrl()).getRequests()) / 60;
//每秒请求数
if (Constants.REDIS_INFO_MAP.containsKey(this.getUrl())) {
}
reqCaps = (this.requests - Constants.REDIS_INFO_MAP.get(this.getUrl()).getRequests()) / 60;
}
redisInfo.setReqCaps(reqCaps);
redisInfo.setReqCaps(reqCaps);
//save
Constants.REDIS_INFO_MAP.put(this.getUrl(), redisInfo);
} catch (Exception e) {
DEBUG.error("Failed to do redis {} task ,error {} ", this.getIp() + ":" + this.getPort(), e);
}
//save
Constants.REDIS_INFO_MAP.put(this.getUrl(), redisInfo);
}
... ...