...
|
...
|
@@ -10,6 +10,7 @@ import redis.clients.jedis.Jedis; |
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -21,11 +22,15 @@ public class RedisTask extends Task { |
|
|
|
|
|
private Long requests = 0L;
|
|
|
|
|
|
private Jedis client;
|
|
|
|
|
|
public RedisTask(String url, Long requests) {
|
|
|
|
|
|
super(url);
|
|
|
|
|
|
this.requests = requests;
|
|
|
|
|
|
client = new Jedis(this.getIp(), this.getPort(), 2 * 1000);
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -35,14 +40,8 @@ public class RedisTask extends Task { |
|
|
DEBUG.info("Start to do redis {} task ", this.getIp() + ":" + this.getPort());
|
|
|
|
|
|
try {
|
|
|
Jedis client = new Jedis(this.getIp(), this.getPort(), 2 * 1000);
|
|
|
|
|
|
String info = client.info();
|
|
|
|
|
|
DEBUG.info("Query redis {} info {} ", this.getIp() + ":" + this.getPort(), info);
|
|
|
|
|
|
client.close();
|
|
|
|
|
|
Map<String, String> infoMap = buildInfo(info);
|
|
|
|
|
|
RedisInfo redisInfo = buildRedisInfo(infoMap);
|
...
|
...
|
@@ -63,7 +62,12 @@ public class RedisTask extends Task { |
|
|
//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);
|
|
|
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
client.close();
|
|
|
}
|
|
|
|
|
|
}
|
...
|
...
|
@@ -92,6 +96,23 @@ public class RedisTask extends Task { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!infoMap.containsKey("maxmemory")) {
|
|
|
|
|
|
List<String> re = client.configGet("maxmemory");
|
|
|
|
|
|
if (null != re && 0 < re.size()) {
|
|
|
|
|
|
infoMap.put(re.get(0), re.get(1));
|
|
|
|
|
|
Long max_h = Long.valueOf(re.get(1)) / (1000 * 1000 * 1000);
|
|
|
|
|
|
infoMap.put("maxmemory_human", max_h + "G");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return infoMap;
|
|
|
}
|
|
|
|
...
|
...
|
|