Search in sources :

Example 1 with CostTimeDetailStatModel

use of com.sohu.tv.jedis.stat.model.CostTimeDetailStatModel in project cachecloud by sohutv.

the class ClientDataCollectReportExecutor method collectReportCostTimeData.

/**
     * 收集耗时
     * 
     * @param lastMinute
     */
private List<Map<String, Object>> collectReportCostTimeData(String lastMinute) {
    try {
        //1. 收集数据
        Map<CostTimeDetailStatKey, AtomicLongMap<Integer>> map = UsefulDataCollector.getCostTimeLastMinute(lastMinute);
        if (map == null || map.isEmpty()) {
            return Collections.emptyList();
        }
        // 2. 组装数据
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        for (Entry<CostTimeDetailStatKey, AtomicLongMap<Integer>> entry : map.entrySet()) {
            CostTimeDetailStatKey costTimeDetailStatKey = entry.getKey();
            AtomicLongMap<Integer> statMap = entry.getValue();
            CostTimeDetailStatModel model = UsefulDataCollector.generateCostTimeDetailStatKey(statMap);
            Map<String, Object> tempMap = new HashMap<String, Object>();
            tempMap.put(ClientReportConstant.COST_COUNT, model.getTotalCount());
            tempMap.put(ClientReportConstant.COST_COMMAND, costTimeDetailStatKey.getCommand());
            tempMap.put(ClientReportConstant.COST_HOST_PORT, costTimeDetailStatKey.getHostPort());
            tempMap.put(ClientReportConstant.COST_TIME_90_MAX, model.getNinetyPercentMax());
            tempMap.put(ClientReportConstant.COST_TIME_99_MAX, model.getNinetyNinePercentMax());
            tempMap.put(ClientReportConstant.COST_TIME_100_MAX, model.getHundredMax());
            tempMap.put(ClientReportConstant.COST_TIME_MEAN, model.getMean());
            tempMap.put(ClientReportConstant.COST_TIME_MEDIAN, model.getMedian());
            tempMap.put(ClientReportConstant.CLIENT_DATA_TYPE, ClientCollectDataTypeEnum.COST_TIME_DISTRI_TYPE.getValue());
            list.add(tempMap);
        }
        return list;
    } catch (Exception e) {
        UsefulDataCollector.collectException(e, "", System.currentTimeMillis(), ClientExceptionType.CLIENT_EXCEPTION_TYPE);
        logger.error("collectReportCostTimeData:" + e.getMessage(), e);
        return Collections.emptyList();
    }
}
Also used : CostTimeDetailStatKey(com.sohu.tv.jedis.stat.model.CostTimeDetailStatKey) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AtomicLongMap(com.sohu.tv.jedis.stat.utils.AtomicLongMap) ParseException(java.text.ParseException) CostTimeDetailStatModel(com.sohu.tv.jedis.stat.model.CostTimeDetailStatModel) HashMap(java.util.HashMap) Map(java.util.Map) AtomicLongMap(com.sohu.tv.jedis.stat.utils.AtomicLongMap)

Example 2 with CostTimeDetailStatModel

use of com.sohu.tv.jedis.stat.model.CostTimeDetailStatModel in project cachecloud by sohutv.

the class UsefulDataCollectorTest method testGenerateCostTimeDetailStatKey.

@Test
public void testGenerateCostTimeDetailStatKey() {
    AtomicLongMap<Integer> map = AtomicLongMap.create();
    map.addAndGet(5, 300);
    map.addAndGet(2, 100);
    map.addAndGet(1, 500);
    map.addAndGet(4, 300);
    map.addAndGet(10, 30);
    map.addAndGet(30, 2);
    CostTimeDetailStatModel model = UsefulDataCollector.generateCostTimeDetailStatKey(map);
    logger.info(model.toString());
}
Also used : CostTimeDetailStatModel(com.sohu.tv.jedis.stat.model.CostTimeDetailStatModel) Test(org.junit.Test)

Example 3 with CostTimeDetailStatModel

use of com.sohu.tv.jedis.stat.model.CostTimeDetailStatModel in project cachecloud by sohutv.

the class UsefulDataCollector method generateCostTimeDetailStatKey.

/**
     * 产生耗时详细分布
     * 
     * @param statMap
     */
public static CostTimeDetailStatModel generateCostTimeDetailStatKey(AtomicLongMap<Integer> statMap) {
    CostTimeDetailStatModel model = new CostTimeDetailStatModel();
    model.setMean(getMeanValue(statMap));
    model.setMedian(fillCostTimeDetailStatModel(model, statMap, 50));
    model.setNinetyPercentMax(fillCostTimeDetailStatModel(model, statMap, 90));
    model.setNinetyNinePercentMax(fillCostTimeDetailStatModel(model, statMap, 99));
    model.setHundredMax(fillCostTimeDetailStatModel(model, statMap, 100));
    // model.setTotalCount(getTotalValue(statMap));
    return model;
}
Also used : CostTimeDetailStatModel(com.sohu.tv.jedis.stat.model.CostTimeDetailStatModel)

Aggregations

CostTimeDetailStatModel (com.sohu.tv.jedis.stat.model.CostTimeDetailStatModel)3 CostTimeDetailStatKey (com.sohu.tv.jedis.stat.model.CostTimeDetailStatKey)1 AtomicLongMap (com.sohu.tv.jedis.stat.utils.AtomicLongMap)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1