Search in sources :

Example 1 with HighchartPoint

use of com.sohu.cache.web.chart.model.HighchartPoint in project cachecloud by sohutv.

the class AppController method assembleMutiStatAppStatsJsonMinute.

/**
     * 多命令组装
     * @param appStats
     * @param statNameList
     * @param startDate
     * @return
     */
private String assembleMutiStatAppStatsJsonMinute(List<AppStats> appStats, List<String> statNameList, Date startDate) {
    if (appStats == null || appStats.isEmpty()) {
        return "[]";
    }
    Map<String, List<HighchartPoint>> map = new HashMap<String, List<HighchartPoint>>();
    for (String statName : statNameList) {
        List<HighchartPoint> list = new ArrayList<HighchartPoint>();
        for (AppStats stat : appStats) {
            try {
                HighchartPoint highchartPoint = HighchartPoint.getFromAppStats(stat, statName, startDate, 0);
                if (highchartPoint == null) {
                    continue;
                }
                list.add(highchartPoint);
            } catch (ParseException e) {
                logger.info(e.getMessage(), e);
            }
        }
        map.put(statName, list);
    }
    net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(map);
    return jsonObject.toString();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ParseException(java.text.ParseException) HighchartPoint(com.sohu.cache.web.chart.model.HighchartPoint)

Example 2 with HighchartPoint

use of com.sohu.cache.web.chart.model.HighchartPoint in project cachecloud by sohutv.

the class AppController method assembleMutilDateAppCommandJsonMinute.

private String assembleMutilDateAppCommandJsonMinute(List<AppCommandStats> appCommandStats, Date startDate, Date endDate) {
    if (appCommandStats == null || appCommandStats.isEmpty()) {
        return "[]";
    }
    Map<String, List<HighchartPoint>> map = new HashMap<String, List<HighchartPoint>>();
    Date currentDate = DateUtils.addDays(endDate, -1);
    int diffDays = 0;
    while (currentDate.getTime() >= startDate.getTime()) {
        List<HighchartPoint> list = new ArrayList<HighchartPoint>();
        for (AppCommandStats stat : appCommandStats) {
            try {
                HighchartPoint highchartPoint = HighchartPoint.getFromAppCommandStats(stat, currentDate, diffDays);
                if (highchartPoint == null) {
                    continue;
                }
                list.add(highchartPoint);
            } catch (ParseException e) {
                logger.info(e.getMessage(), e);
            }
        }
        String formatDate = DateUtil.formatDate(currentDate, "yyyy-MM-dd");
        map.put(formatDate, list);
        currentDate = DateUtils.addDays(currentDate, -1);
        diffDays++;
    }
    net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(map);
    return jsonObject.toString();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HighchartPoint(com.sohu.cache.web.chart.model.HighchartPoint) Date(java.util.Date) HighchartPoint(com.sohu.cache.web.chart.model.HighchartPoint) ArrayList(java.util.ArrayList) List(java.util.List) ParseException(java.text.ParseException)

Example 3 with HighchartPoint

use of com.sohu.cache.web.chart.model.HighchartPoint in project cachecloud by sohutv.

the class AppController method assembleMutilDateAppStatsJsonMinute.

/**
     * 多时间组装
     * @param appStats
     * @param statName
     * @param startDate
     * @param endDate
     * @return
     */
private String assembleMutilDateAppStatsJsonMinute(List<AppStats> appStats, String statName, Date startDate, Date endDate) {
    if (appStats == null || appStats.isEmpty()) {
        return "[]";
    }
    Map<String, List<HighchartPoint>> map = new HashMap<String, List<HighchartPoint>>();
    Date currentDate = DateUtils.addDays(endDate, -1);
    int diffDays = 0;
    while (currentDate.getTime() >= startDate.getTime()) {
        List<HighchartPoint> list = new ArrayList<HighchartPoint>();
        for (AppStats stat : appStats) {
            try {
                HighchartPoint highchartPoint = HighchartPoint.getFromAppStats(stat, statName, currentDate, diffDays);
                if (highchartPoint == null) {
                    continue;
                }
                list.add(highchartPoint);
            } catch (ParseException e) {
                logger.info(e.getMessage(), e);
            }
        }
        String formatDate = DateUtil.formatDate(currentDate, "yyyy-MM-dd");
        map.put(formatDate, list);
        currentDate = DateUtils.addDays(currentDate, -1);
        diffDays++;
    }
    net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(map);
    return jsonObject.toString();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HighchartPoint(com.sohu.cache.web.chart.model.HighchartPoint) Date(java.util.Date) HighchartPoint(com.sohu.cache.web.chart.model.HighchartPoint) ArrayList(java.util.ArrayList) List(java.util.List) ParseException(java.text.ParseException)

Aggregations

HighchartPoint (com.sohu.cache.web.chart.model.HighchartPoint)3 ParseException (java.text.ParseException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Date (java.util.Date)2