Authored by jack

增加日志

@@ -10,6 +10,8 @@ import com.monitor.middleware.redis.model.TwemproxyInfo; @@ -10,6 +10,8 @@ import com.monitor.middleware.redis.model.TwemproxyInfo;
10 import com.monitor.middleware.redis.model.TwemproxyVo; 10 import com.monitor.middleware.redis.model.TwemproxyVo;
11 import com.monitor.model.response.BaseResponse; 11 import com.monitor.model.response.BaseResponse;
12 import org.apache.commons.lang.StringUtils; 12 import org.apache.commons.lang.StringUtils;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
13 import org.springframework.beans.factory.annotation.Autowired; 15 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.web.bind.annotation.RequestMapping; 16 import org.springframework.web.bind.annotation.RequestMapping;
15 import org.springframework.web.bind.annotation.RequestParam; 17 import org.springframework.web.bind.annotation.RequestParam;
@@ -25,6 +27,7 @@ import java.util.Map; @@ -25,6 +27,7 @@ import java.util.Map;
25 @RestController 27 @RestController
26 @RequestMapping(value = "redisMonitor") 28 @RequestMapping(value = "redisMonitor")
27 public class RedisCtrl { 29 public class RedisCtrl {
  30 + public static final Logger DEBUG = LoggerFactory.getLogger(RedisCtrl.class);
28 31
29 @Autowired 32 @Autowired
30 IMObjectInfoService imObjectInfoService; 33 IMObjectInfoService imObjectInfoService;
@@ -109,17 +112,28 @@ public class RedisCtrl { @@ -109,17 +112,28 @@ public class RedisCtrl {
109 112
110 List<RedisVo> redisInfoList = new ArrayList<>(); 113 List<RedisVo> redisInfoList = new ArrayList<>();
111 114
112 - TwemproxyInfo twemproxyInfo = Constants.TWEMPROXY_INFO_MAP.get(twemproxy); 115 + try {
  116 + TwemproxyInfo twemproxyInfo = Constants.TWEMPROXY_INFO_MAP.get(twemproxy);
113 117
114 - for (Map.Entry<String, Long> entry : twemproxyInfo.getRequestMap().entrySet()) { 118 + DEBUG.info("Query twemproxyinfo {} by key {}", twemproxyInfo, twemproxy);
115 119
116 - RedisInfo redisInfo = Constants.REDIS_INFO_MAP.get(entry.getKey());  
117 120
118 - RedisVo redisVo = buildRedisVo(redisInfo); 121 + for (Map.Entry<String, Long> entry : twemproxyInfo.getRequestMap().entrySet()) {
119 122
120 - redisInfoList.add(redisVo); 123 + RedisInfo redisInfo = Constants.REDIS_INFO_MAP.get(entry.getKey());
  124 +
  125 + DEBUG.info("Twemproxy {} contains redis {} ",twemproxy,redisInfo);
  126 +
  127 + RedisVo redisVo = buildRedisVo(redisInfo);
  128 +
  129 + redisInfoList.add(redisVo);
  130 + }
  131 +
  132 + } catch (Exception e) {
  133 + e.printStackTrace();
121 } 134 }
122 135
  136 +
123 response.setData(redisInfoList); 137 response.setData(redisInfoList);
124 138
125 return response; 139 return response;
@@ -161,7 +175,7 @@ public class RedisCtrl { @@ -161,7 +175,7 @@ public class RedisCtrl {
161 175
162 redisVo.setRequestSec(String.valueOf(redisInfo.getReqCaps())); 176 redisVo.setRequestSec(String.valueOf(redisInfo.getReqCaps()));
163 177
164 - redisVo.setHitRate(redisInfo.getHitRate()+" %"); 178 + redisVo.setHitRate(redisInfo.getHitRate() + " %");
165 179
166 return redisVo; 180 return redisVo;
167 181