Search in sources :

Example 1 with RedisInfo

use of com.albedo.java.modules.monitor.domain.RedisInfo in project albedo by somowhere.

the class RedisServiceImpl method getRedisInfo.

/**
 * Redis详细信息
 */
@Override
public IPage<RedisInfo> getRedisInfo() {
    Properties info = redisConnectionFactory.getConnection().info();
    List<RedisInfo> infoList = new ArrayList<>();
    RedisInfo redisInfo;
    for (Map.Entry<Object, Object> entry : info.entrySet()) {
        redisInfo = new RedisInfo();
        redisInfo.setKey(StringUtil.toString(entry.getKey()));
        redisInfo.setValue(StringUtil.toString(entry.getValue()));
        infoList.add(redisInfo);
    }
    return new PageModel<>(infoList, infoList.size());
}
Also used : ArrayList(java.util.ArrayList) JSONObject(cn.hutool.json.JSONObject) PageModel(com.albedo.java.common.core.vo.PageModel) Properties(java.util.Properties) RedisInfo(com.albedo.java.modules.monitor.domain.RedisInfo) BeanMap(org.springframework.cglib.beans.BeanMap) Map(java.util.Map)

Example 2 with RedisInfo

use of com.albedo.java.modules.monitor.domain.RedisInfo in project albedo by somowhere.

the class RedisServiceImpl method getMapForReport.

/**
 * 查询redis信息for报表
 *
 * @param reportSearchType
 * @return
 */
@Override
public Map<String, JSONArray> getMapForReport(ReportSearchType reportSearchType) {
    Map<String, JSONArray> mapJson = Maps.newHashMap();
    JSONArray json = new JSONArray();
    if (ReportSearchType.INFO.equals(reportSearchType)) {
        List<RedisInfo> redisInfo = getRedisInfo().getRecords();
        for (RedisInfo info : redisInfo) {
            Map<String, Object> map = Maps.newHashMap();
            BeanMap beanMap = BeanMap.create(info);
            for (Object key : beanMap.keySet()) {
                map.put(key + "", beanMap.get(key));
            }
            json.add(map);
        }
        mapJson.put("data", json);
        return mapJson;
    }
    for (int i = 0, size = 5; i < size; i++) {
        JSONObject jo = new JSONObject();
        if (ReportSearchType.KEY.equals(reportSearchType)) {
            jo.putOpt("value", getKeySize());
        } else {
            Integer usedMemory = Integer.valueOf(getUsedMemory());
            jo.putOpt("value", usedMemory / 1000);
        }
        String createTime = DateUtil.formatTime(DateUtil.date(System.currentTimeMillis() - (4 - i) * 1000));
        jo.putOpt("name", createTime);
        json.add(jo);
    }
    mapJson.put("data", json);
    return mapJson;
}
Also used : BeanMap(org.springframework.cglib.beans.BeanMap) JSONObject(cn.hutool.json.JSONObject) JSONArray(cn.hutool.json.JSONArray) JSONObject(cn.hutool.json.JSONObject) RedisInfo(com.albedo.java.modules.monitor.domain.RedisInfo)

Aggregations

JSONObject (cn.hutool.json.JSONObject)2 RedisInfo (com.albedo.java.modules.monitor.domain.RedisInfo)2 BeanMap (org.springframework.cglib.beans.BeanMap)2 JSONArray (cn.hutool.json.JSONArray)1 PageModel (com.albedo.java.common.core.vo.PageModel)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Properties (java.util.Properties)1