Search in sources :

Example 1 with ClientCollectDataTypeEnum

use of com.sohu.tv.jedis.stat.enums.ClientCollectDataTypeEnum in project cachecloud by sohutv.

the class ClientReportCostDistriServiceImpl method batchSave.

@Override
public void batchSave(ClientReportBean clientReportBean) {
    try {
        // 1.client上报
        final String clientIp = clientReportBean.getClientIp();
        final long collectTime = clientReportBean.getCollectTime();
        final long reportTime = clientReportBean.getReportTimeStamp();
        final List<Map<String, Object>> datas = clientReportBean.getDatas();
        if (datas == null || datas.isEmpty()) {
            logger.warn("datas field {} is empty", clientReportBean);
            return;
        }
        // 2.结果集
        List<AppClientCostTimeStat> appClientCostTimeStatList = new ArrayList<AppClientCostTimeStat>();
        // 3.解析结果
        for (Map<String, Object> map : datas) {
            Integer clientDataType = MapUtils.getInteger(map, ClientReportConstant.CLIENT_DATA_TYPE, -1);
            ClientCollectDataTypeEnum clientCollectDataTypeEnum = ClientCollectDataTypeEnum.MAP.get(clientDataType);
            if (clientCollectDataTypeEnum == null) {
                continue;
            }
            if (ClientCollectDataTypeEnum.COST_TIME_DISTRI_TYPE.equals(clientCollectDataTypeEnum)) {
                AppClientCostTimeStat appClientCostTimeStat = generate(clientIp, collectTime, reportTime, map);
                if (appClientCostTimeStat != null) {
                    appClientCostTimeStatList.add(appClientCostTimeStat);
                }
            }
        }
        if (CollectionUtils.isNotEmpty(appClientCostTimeStatList)) {
            // 4.批量保存
            appClientCostTimeStatDao.batchSave(appClientCostTimeStatList);
            // 5.合并app统计结果
            List<AppClientCostTimeTotalStat> appClientCostTimeTotalStatList = mergeAppClientCostTimeStat(appClientCostTimeStatList);
            if (CollectionUtils.isNotEmpty(appClientCostTimeTotalStatList)) {
                appClientCostTimeTotalStatDao.batchSave(appClientCostTimeTotalStatList);
            }
            // 6.保存应用下节点和客户端关系
            appInstanceClientRelationService.batchSave(appClientCostTimeStatList);
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : ClientCollectDataTypeEnum(com.sohu.tv.jedis.stat.enums.ClientCollectDataTypeEnum) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) AppClientCostTimeStat(com.sohu.cache.entity.AppClientCostTimeStat) AppClientCostTimeTotalStat(com.sohu.cache.entity.AppClientCostTimeTotalStat)

Example 2 with ClientCollectDataTypeEnum

use of com.sohu.tv.jedis.stat.enums.ClientCollectDataTypeEnum in project cachecloud by sohutv.

the class ClientReportValueDistriServiceImplV2 method batchSave.

@Override
public void batchSave(ClientReportBean clientReportBean) {
    try {
        // 1.client上报
        final long collectTime = clientReportBean.getCollectTime();
        final long reportTime = clientReportBean.getReportTimeStamp();
        final List<Map<String, Object>> datas = clientReportBean.getDatas();
        if (datas == null || datas.isEmpty()) {
            logger.warn("datas field {} is empty", clientReportBean);
            return;
        }
        // 3.解析
        for (Map<String, Object> map : datas) {
            Integer clientDataType = MapUtils.getInteger(map, ClientReportConstant.CLIENT_DATA_TYPE, -1);
            ClientCollectDataTypeEnum clientCollectDataTypeEnum = ClientCollectDataTypeEnum.MAP.get(clientDataType);
            if (clientCollectDataTypeEnum == null) {
                continue;
            }
            if (ClientCollectDataTypeEnum.VALUE_LENGTH_DISTRI_TYPE.equals(clientCollectDataTypeEnum)) {
                AppClientValueDistriStatTotal appClientValueDistriStat = generate(collectTime, reportTime, map);
                if (appClientValueDistriStat != null) {
                    appClientValueStatDao.save(appClientValueDistriStat);
                }
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : ClientCollectDataTypeEnum(com.sohu.tv.jedis.stat.enums.ClientCollectDataTypeEnum) Map(java.util.Map) AppClientValueDistriStatTotal(com.sohu.cache.entity.AppClientValueDistriStatTotal)

Example 3 with ClientCollectDataTypeEnum

use of com.sohu.tv.jedis.stat.enums.ClientCollectDataTypeEnum in project cachecloud by sohutv.

the class ClientReportExceptionServiceImpl method batchSave.

@Override
public void batchSave(ClientReportBean clientReportBean) {
    try {
        // 1.client上报
        final String clientIp = clientReportBean.getClientIp();
        final long collectTime = clientReportBean.getCollectTime();
        final long reportTime = clientReportBean.getReportTimeStamp();
        final List<Map<String, Object>> datas = clientReportBean.getDatas();
        if (datas == null || datas.isEmpty()) {
            logger.warn("datas field {} is empty", clientReportBean);
            return;
        }
        // 2.结果集
        List<AppClientExceptionStat> appClientExceptionStatList = new ArrayList<AppClientExceptionStat>();
        // 3.解析
        for (Map<String, Object> map : datas) {
            Integer clientDataType = MapUtils.getInteger(map, ClientReportConstant.CLIENT_DATA_TYPE, -1);
            ClientCollectDataTypeEnum clientCollectDataTypeEnum = ClientCollectDataTypeEnum.MAP.get(clientDataType);
            if (clientCollectDataTypeEnum == null) {
                continue;
            }
            if (ClientCollectDataTypeEnum.EXCEPTION_TYPE.equals(clientCollectDataTypeEnum)) {
                AppClientExceptionStat appClientExceptionStat = generate(clientIp, collectTime, reportTime, map);
                if (appClientExceptionStat != null) {
                    appClientExceptionStatList.add(appClientExceptionStat);
                }
            }
        }
        // 4.批量保存
        if (CollectionUtils.isNotEmpty(appClientExceptionStatList)) {
            appClientExceptionStatDao.batchSave(appClientExceptionStatList);
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : AppClientExceptionStat(com.sohu.cache.entity.AppClientExceptionStat) ClientCollectDataTypeEnum(com.sohu.tv.jedis.stat.enums.ClientCollectDataTypeEnum) ArrayList(java.util.ArrayList) Map(java.util.Map) ClientInstanceException(com.sohu.cache.entity.ClientInstanceException)

Aggregations

ClientCollectDataTypeEnum (com.sohu.tv.jedis.stat.enums.ClientCollectDataTypeEnum)3 Map (java.util.Map)3 ArrayList (java.util.ArrayList)2 AppClientCostTimeStat (com.sohu.cache.entity.AppClientCostTimeStat)1 AppClientCostTimeTotalStat (com.sohu.cache.entity.AppClientCostTimeTotalStat)1 AppClientExceptionStat (com.sohu.cache.entity.AppClientExceptionStat)1 AppClientValueDistriStatTotal (com.sohu.cache.entity.AppClientValueDistriStatTotal)1 ClientInstanceException (com.sohu.cache.entity.ClientInstanceException)1 HashMap (java.util.HashMap)1