Search in sources :

Example 11 with AppDetailVO

use of com.sohu.cache.web.vo.AppDetailVO in project cachecloud by sohutv.

the class AppClientConnInspector method inspect.

@Override
public boolean inspect(Map<InspectParamEnum, Object> paramMap) {
    Long appId = MapUtils.getLong(paramMap, InspectParamEnum.SPLIT_KEY);
    AppDetailVO appDetailVO = appStatsCenter.getAppDetail(appId);
    if (appDetailVO == null) {
        logger.warn("appId {} appDetailVO is empty", appId);
        return true;
    }
    List<InstanceInfo> appInstanceInfoList = (List<InstanceInfo>) paramMap.get(InspectParamEnum.INSTANCE_LIST);
    if (CollectionUtils.isEmpty(appInstanceInfoList)) {
        logger.warn("appId {} instanceList is empty", appId);
        return true;
    }
    // 报警阀值
    int appClientConnThreshold = getClientConnThreshold(appDetailVO.getAppDesc());
    int appClientConnNum = appDetailVO.getConn();
    // 阀值乘以分片个数
    int instanceCount = appInstanceInfoList.size();
    if (appClientConnNum > appClientConnThreshold * instanceCount) {
        alertAppClientConn(appDetailVO, appClientConnThreshold, instanceCount);
    } else {
        for (InstanceInfo instanceInfo : appInstanceInfoList) {
            if (instanceInfo == null) {
                continue;
            }
            if (instanceInfo.isOffline()) {
                continue;
            }
            if (!TypeUtil.isRedisType(instanceInfo.getType())) {
                continue;
            }
            // 忽略sentinel观察者
            if (TypeUtil.isRedisSentinel(instanceInfo.getType())) {
                continue;
            }
            long instanceId = instanceInfo.getId();
            InstanceStats instanceStats = instanceStatsCenter.getInstanceStats(instanceId);
            if (instanceStats == null) {
                continue;
            }
            double instanceClientConnNum = instanceStats.getCurrConnections();
            // 大于标准值
            if (instanceClientConnNum > appClientConnThreshold) {
                alertInstanceClientConn(instanceStats, appDetailVO, appClientConnThreshold);
            }
        }
    }
    return true;
}
Also used : InstanceStats(com.sohu.cache.entity.InstanceStats) AppDetailVO(com.sohu.cache.web.vo.AppDetailVO) List(java.util.List) InstanceInfo(com.sohu.cache.entity.InstanceInfo)

Example 12 with AppDetailVO

use of com.sohu.cache.web.vo.AppDetailVO in project cachecloud by sohutv.

the class AppStatsCenterImplTest method getAppDetail.

@Test
public void getAppDetail() {
    long appId = 10015L;
    long begin = System.currentTimeMillis();
    AppDetailVO resultVO = appStatsCenter.getAppDetail(appId);
    logger.info("cost=" + (System.currentTimeMillis() - begin));
    logger.info("result={}", resultVO);
}
Also used : AppDetailVO(com.sohu.cache.web.vo.AppDetailVO) BaseTest(com.sohu.test.BaseTest) Test(org.junit.Test)

Aggregations

AppDetailVO (com.sohu.cache.web.vo.AppDetailVO)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 ArrayList (java.util.ArrayList)4 AppDailyData (com.sohu.cache.entity.AppDailyData)2 AppDesc (com.sohu.cache.entity.AppDesc)2 InstanceInfo (com.sohu.cache.entity.InstanceInfo)2 InstanceStats (com.sohu.cache.entity.InstanceStats)2 Date (java.util.Date)2 List (java.util.List)2 HighchartPoint (com.sohu.cache.web.chart.model.HighchartPoint)1 Page (com.sohu.cache.web.util.Page)1 BaseTest (com.sohu.test.BaseTest)1 DecimalFormat (java.text.DecimalFormat)1 Test (org.junit.Test)1