Search in sources :

Example 1 with AppDailyData

use of com.sohu.cache.entity.AppDailyData in project cachecloud by sohutv.

the class AppDailyDataCenterImpl method generateAppDaily.

@Override
public AppDailyData generateAppDaily(long appId, Date startDate, Date endDate) {
    Assert.isTrue(appId > 0L);
    AppDetailVO appDetailVO = appStatsCenter.getAppDetail(appId);
    if (appDetailVO == null) {
        logger.error("appId={} not exist", appId);
        return null;
    }
    AppDesc appDesc = appDetailVO.getAppDesc();
    if (appDesc.isOffline()) {
        return null;
    }
    if (appDesc.isTest()) {
        return null;
    }
    AppDailyData appDailyData = new AppDailyData();
    appDailyData.setStartDate(startDate);
    appDailyData.setEndDate(endDate);
    // 应用详情
    appDailyData.setAppDetailVO(appDetailVO);
    // 慢查询
    int slowLogCount = getSlowLogCount(appId, startDate, endDate);
    appDailyData.setSlowLogCount(slowLogCount);
    // 客户端异常数
    int clientExceptionCount = getClientExceptionCount(appId, startDate, endDate);
    appDailyData.setClientExceptionCount(clientExceptionCount);
    // 客户端值分布
    Map<String, Long> valueSizeDistributeCountMap = getAppClientValueSizeDistributeCountMap(appId, startDate, endDate);
    appDailyData.setValueSizeDistributeCountMap(valueSizeDistributeCountMap);
    // 应用相关统计
    Map<String, Object> appMinuteStatMap = getAppMinuteStat(appId, startDate, endDate);
    appDailyData.setMaxMinuteClientCount(MapUtils.getIntValue(appMinuteStatMap, "maxClientCount"));
    appDailyData.setAvgMinuteClientCount(MapUtils.getIntValue(appMinuteStatMap, "avgClientCount"));
    appDailyData.setMaxMinuteCommandCount(MapUtils.getIntValue(appMinuteStatMap, "maxCommandCount"));
    appDailyData.setAvgMinuteCommandCount(MapUtils.getIntValue(appMinuteStatMap, "avgCommandCount"));
    appDailyData.setMaxMinuteHitRatio(remainNumberTwoPoint(MapUtils.getDoubleValue(appMinuteStatMap, "maxHitRatio") * 100.0));
    appDailyData.setMinMinuteHitRatio(remainNumberTwoPoint(MapUtils.getDoubleValue(appMinuteStatMap, "minHitRatio") * 100.0));
    appDailyData.setAvgHitRatio(remainNumberTwoPoint(MapUtils.getDoubleValue(appMinuteStatMap, "avgHitRatio") * 100.0));
    appDailyData.setAvgUsedMemory(MapUtils.getLongValue(appMinuteStatMap, "avgUsedMemory") / 1024 / 1024);
    appDailyData.setMaxUsedMemory(MapUtils.getLongValue(appMinuteStatMap, "maxUsedMemory") / 1024 / 1024);
    appDailyData.setExpiredKeysCount(MapUtils.getIntValue(appMinuteStatMap, "expiredKeys"));
    appDailyData.setEvictedKeysCount(MapUtils.getIntValue(appMinuteStatMap, "evictedKeys"));
    appDailyData.setAvgMinuteNetOutputByte(remainNumberTwoPoint(MapUtils.getDoubleValue(appMinuteStatMap, "avgNetInputByte") / 1024.0 / 1024.0));
    appDailyData.setMaxMinuteNetOutputByte(remainNumberTwoPoint(MapUtils.getDoubleValue(appMinuteStatMap, "maxNetInputByte") / 1024.0 / 1024.0));
    appDailyData.setAvgMinuteNetInputByte(remainNumberTwoPoint(MapUtils.getDoubleValue(appMinuteStatMap, "avgNetOutputByte") / 1024.0 / 1024.0));
    appDailyData.setMaxMinuteNetInputByte(remainNumberTwoPoint(MapUtils.getDoubleValue(appMinuteStatMap, "maxNetOutputByte") / 1024.0 / 1024.0));
    appDailyData.setAvgObjectSize(MapUtils.getIntValue(appMinuteStatMap, "avgObjectSize"));
    appDailyData.setMaxObjectSize(MapUtils.getIntValue(appMinuteStatMap, "maxObjectSize"));
    return appDailyData;
}
Also used : AppDetailVO(com.sohu.cache.web.vo.AppDetailVO) AppDesc(com.sohu.cache.entity.AppDesc) AppDailyData(com.sohu.cache.entity.AppDailyData)

Example 2 with AppDailyData

use of com.sohu.cache.entity.AppDailyData in project cachecloud by sohutv.

the class AppEmailUtil method noticeAppResult.

/**
     * 应用状态通知
     * @param appDesc
     * @param appAudit
     */
public void noticeAppResult(AppDesc appDesc, AppAudit appAudit) {
    List<String> ccEmailList = getCCEmailList(appDesc, appAudit);
    String mailContent = VelocityUtils.createText(velocityEngine, appDesc, appAudit, new AppDailyData(), new ArrayList<InstanceAlertValueResult>(), "appAudit.vm", "UTF-8");
    AppUser appUser = userService.get(appDesc.getUserId());
    emailComponent.sendMail("【CacheCloud】状态通知", mailContent, Arrays.asList(appUser.getEmail()), ccEmailList);
}
Also used : InstanceAlertValueResult(com.sohu.cache.entity.InstanceAlertValueResult) AppUser(com.sohu.cache.entity.AppUser) AppDailyData(com.sohu.cache.entity.AppDailyData)

Example 3 with AppDailyData

use of com.sohu.cache.entity.AppDailyData in project cachecloud by sohutv.

the class AppDailyDataCenterImpl method sendAppDailyEmail.

@Override
public boolean sendAppDailyEmail(long appId, Date startDate, Date endDate) {
    try {
        AppDailyData appDailyData = generateAppDaily(appId, startDate, endDate);
        if (appDailyData == null) {
            return false;
        }
        AppDetailVO appDetailVO = appDailyData.getAppDetailVO();
        noticeAppDaily(startDate, appDetailVO, appDailyData);
        return true;
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return false;
    }
}
Also used : AppDetailVO(com.sohu.cache.web.vo.AppDetailVO) AppDailyData(com.sohu.cache.entity.AppDailyData)

Aggregations

AppDailyData (com.sohu.cache.entity.AppDailyData)3 AppDetailVO (com.sohu.cache.web.vo.AppDetailVO)2 AppDesc (com.sohu.cache.entity.AppDesc)1 AppUser (com.sohu.cache.entity.AppUser)1 InstanceAlertValueResult (com.sohu.cache.entity.InstanceAlertValueResult)1