提交 01091117 编写于 作者: doc_wei's avatar doc_wei

添加redis内存数量接口

上级 8a421a6f
......@@ -9,4 +9,6 @@ public interface SysRedisMonitorService {
public void queryRedisLogsList(InputObject inputObject, OutputObject outputObject) throws Exception;
public void queryRedisKeysList(InputObject inputObject, OutputObject outputObject) throws Exception;
}
......@@ -64,4 +64,24 @@ public class SysRedisMonitorServiceImpl implements SysRedisMonitorService{
outputObject.settotal(beans.size());
}
/**
*
* @Title: queryRedisKeysList
* @Description: 获取当前数据库中key的数量
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void queryRedisKeysList(InputObject inputObject, OutputObject outputObject) throws Exception {
List<Map<String, Object>> beans = jedisClientClusterService.getClusterNodes();
for(Map<String, Object> bean : beans){
bean.put("keys", jedisClientClusterService.dbSize(bean.get("ip").toString()));
}
outputObject.setBeans(beans);
outputObject.settotal(beans.size());
}
}
......@@ -34,11 +34,11 @@ public interface JedisClientClusterService {
*
* @Title: dbSize
* @Description: 获取占用内存大小
* @param @return
* @param @throws Exception 参数
* @param @param ip
* @param @return 参数
* @return Long 返回类型
* @throws
*/
public Long dbSize(String ip);
public Map<String, Object> dbSize(String ip);
}
......@@ -7,17 +7,13 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import com.alibaba.fastjson.JSON;
import com.skyeye.common.util.ToolUtil;
import com.skyeye.jedis.JedisClient;
import com.skyeye.jedis.JedisClientClusterService;
import redis.clients.jedis.Client;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
......@@ -234,7 +230,28 @@ public class JedisClientCluster implements JedisClient, JedisClientClusterServic
}
@Override
public Long dbSize(String ip) {
public Map<String, Object> dbSize(String ip) {
Jedis jedis = null;
try {
Map<String, JedisPool> jedisPools = jedisCluster.getClusterNodes();
Iterator<Map.Entry<String, JedisPool>> entries = jedisPools.entrySet().iterator();
while (entries.hasNext()) {
Entry<String, JedisPool> entry = entries.next();
if(entry.getKey().indexOf(ip) != -1){
jedis = entry.getValue().getResource();
//配置redis服务信息
Client client = jedis.getClient();
client.dbSize();
long dbSize = client.getIntegerReply();
jedis.close();
Map<String,Object> map = new HashMap<String, Object>();
map.put("createTime", ToolUtil.getTimeAndToString());
map.put("dbSize", dbSize);
return map;
}
}
} finally {
}
return null;
}
......
......@@ -48,4 +48,20 @@ public class SysRedisMonitorController {
sysRedisMonitorService.queryRedisLogsList(inputObject, outputObject);
}
/**
*
* @Title: queryRedisKeysList
* @Description: 获取当前数据库中key的数量
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/SysRedisMonitorController/queryRedisKeysList")
@ResponseBody
public void queryRedisKeysList(InputObject inputObject, OutputObject outputObject) throws Exception{
sysRedisMonitorService.queryRedisKeysList(inputObject, outputObject);
}
}
......@@ -160,7 +160,9 @@
<url id="redis001" path="/post/SysRedisMonitorController/queryRedisInfoList" val="获取redis服务器信息" allUse="1">
</url>
<url id="redis002" path="/post/SysRedisMonitorController/queryRedisLogsList" val="获取redis日志信息" allUse="0">
<url id="redis002" path="/post/SysRedisMonitorController/queryRedisLogsList" val="获取redis日志信息" allUse="1">
</url>
<url id="redis003" path="/post/SysRedisMonitorController/queryRedisKeysList" val="获取当前数据库中key的数量" allUse="0">
</url>
<!-- 系统角色用户管理结束 -->
......
......@@ -15,7 +15,7 @@
<ul class="winui-tab-nav">
<li class="winui-this"><i class="fa fa-bar-chart fa-fw"></i>redis服务器信息</li>
<li><i class="fa fa-line-chart fa-fw"></i>redis日志信息</li>
<li><i class="fa fa-area-chart fa-fw"></i>Area</li>
<li><i class="fa fa-area-chart fa-fw"></i>redis内存数量</li>
<li><i class="fa fa-pie-chart fa-fw"></i>Pie</li>
</ul>
</div>
......@@ -34,7 +34,9 @@
</div>
</div>
<div class="winui-tab-item">
<div id="area" style="width:100%;height:100%;">3</div>
<div id="area" style="width:100%;height:100%;">
</div>
</div>
<div class="winui-tab-item">
<div id="pie" style="width:100%;height:100%;">4</div>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册