use of com.sohu.cache.entity.AppDesc in project cachecloud by sohutv.
the class ImportAppCenterTest method testCheckWrongMaxMemory.
/**
* 最大内存检查
*/
@Test
public void testCheckWrongMaxMemory() {
// 应用信息
AppDesc appDesc = new AppDesc();
appDesc.setName("carlosfu8");
// 实例信息
String appInstanceInfo = "10.10.53.159:6379:aa";
ImportAppResult importAppResult = importAppCenter.check(appDesc, appInstanceInfo);
logger.info("importAppResult: {}", importAppResult);
}
use of com.sohu.cache.entity.AppDesc 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;
}
use of com.sohu.cache.entity.AppDesc in project cachecloud by sohutv.
the class AppDailyDataCenterImpl method sendAppDailyEmail.
@Override
public int sendAppDailyEmail() {
Date endDate = new Date();
Date startDate = DateUtils.addDays(endDate, -1);
int successCount = 0;
List<AppDesc> appDescList = appService.getAllAppDesc();
for (AppDesc appDesc : appDescList) {
try {
boolean result = sendAppDailyEmail(appDesc.getAppId(), startDate, endDate);
if (result) {
successCount++;
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
return successCount;
}
use of com.sohu.cache.entity.AppDesc in project cachecloud by sohutv.
the class RedisClientController method handleRedisApp.
/**
* 检查客户端相关参数
* @param appId 应用id
* @param request
* @param model
* @param type 应用类型
* @param isCheckAppKey 是否检测appKey
* @return
*/
private boolean handleRedisApp(long appId, HttpServletRequest request, Model model, int type, boolean isCheckAppKey) {
AppDesc appDesc = appDao.getAppDescById(appId);
if (appDesc == null) {
model.addAttribute("status", ClientStatusEnum.ERROR.getStatus());
model.addAttribute("message", String.format("appId:%s 不存在", appId));
return false;
} else if (appDesc.getType() != type) {
model.addAttribute("status", ClientStatusEnum.ERROR.getStatus());
model.addAttribute("message", String.format("appId:%s 类型不符,期望类型:%s,实际类型%s,请联系管理员!", appId, type, appDesc.getType()));
return false;
} else if (isCheckAppKey) {
String appKey = request.getParameter("appKey");
if (StringUtils.isBlank(appKey)) {
model.addAttribute("status", ClientStatusEnum.ERROR.getStatus());
model.addAttribute("message", String.format("appId=%s,appKey参数为空", appId));
return false;
}
if (!appKey.equals(appDesc.getAppKey())) {
model.addAttribute("status", ClientStatusEnum.ERROR.getStatus());
model.addAttribute("message", String.format("appId=%s,appKey:%s错误,与服务端不匹配", appId, appKey));
return false;
}
}
return true;
}
use of com.sohu.cache.entity.AppDesc in project cachecloud by sohutv.
the class AppMemInspector method inspect.
@Override
public boolean inspect(Map<InspectParamEnum, Object> paramMap) {
Long appId = MapUtils.getLong(paramMap, InspectParamEnum.SPLIT_KEY);
List<AppDesc> appDescList = new ArrayList<AppDesc>();
AppDesc app = appDao.getAppDescById(appId);
if (app != null) {
appDescList.add(app);
}
if (CollectionUtils.isEmpty(appDescList)) {
logger.error("appList is empty, appId={}", appId);
return true;
}
for (AppDesc appDesc : appDescList) {
//测试不检查
if (appDesc.getIsTest() == 1) {
continue;
}
long checkAppId = appDesc.getAppId();
AppDetailVO appDetailVO = appStatsCenter.getAppDetail(checkAppId);
if (appDetailVO == null) {
continue;
}
double appMemUsePercent = appDetailVO.getMemUsePercent();
int appUseSetMemAlertValue = appDesc.getMemAlertValue();
// 先检查应用的内存使用率是否超过阀值,如果没有再检查分片
if (appMemUsePercent > appUseSetMemAlertValue) {
// 报警
alertAppMemUse(appDetailVO);
} else {
List<InstanceInfo> appInstanceInfoList = (List<InstanceInfo>) paramMap.get(InspectParamEnum.INSTANCE_LIST);
if (CollectionUtils.isNotEmpty(appInstanceInfoList)) {
for (InstanceInfo instanceInfo : appInstanceInfoList) {
if (instanceInfo == null) {
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 instanceMemUsePercent = instanceStats.getMemUsePercent();
// 大于标准值
if (instanceMemUsePercent > appUseSetMemAlertValue) {
alertInstanceMemUse(instanceStats, appDetailVO);
}
}
}
}
}
return true;
}
Aggregations