use of com.sohu.cache.entity.AppDesc in project cachecloud by sohutv.
the class ClientManageController method fillAppInfoMap.
private void fillAppInfoMap(Model model) {
List<AppDesc> appDescList = appService.getAllAppDesc();
// 所有应用id和负责人对应关系
Map<Long, String> appIdOwnerMap = new HashMap<Long, String>();
for (AppDesc appDesc : appDescList) {
appIdOwnerMap.put(appDesc.getAppId(), appDesc.getOfficer());
}
model.addAttribute("appIdOwnerMap", appIdOwnerMap);
// 所有应用id和应用名对应关系
Map<Long, String> appIdNameMap = new HashMap<Long, String>();
for (AppDesc appDesc : appDescList) {
appIdNameMap.put(appDesc.getAppId(), appDesc.getName());
}
model.addAttribute("appIdNameMap", appIdNameMap);
}
use of com.sohu.cache.entity.AppDesc in project cachecloud by sohutv.
the class ImportAppController method genAppDesc.
/**
* 生成AppDesc
*
* @param request
* @return
*/
private AppDesc genAppDesc(HttpServletRequest request) {
// 当前用户
AppUser currentUser = getUserInfo(request);
// 当前时间
Date date = new Date();
// 组装Appdesc
AppDesc appDesc = new AppDesc();
appDesc.setName(request.getParameter("name"));
appDesc.setIntro(request.getParameter("intro"));
appDesc.setOfficer(request.getParameter("officer"));
appDesc.setType(NumberUtils.toInt(request.getParameter("type")));
appDesc.setIsTest(NumberUtils.toInt(request.getParameter("isTest")));
appDesc.setMemAlertValue(NumberUtils.toInt(request.getParameter("memAlertValue")));
appDesc.setUserId(currentUser.getId());
appDesc.setStatus(2);
appDesc.setCreateTime(date);
appDesc.setPassedTime(date);
appDesc.setVerId(1);
return appDesc;
}
use of com.sohu.cache.entity.AppDesc in project cachecloud by sohutv.
the class ImportAppController method add.
@RequestMapping(value = "/add")
public ModelAndView add(HttpServletRequest request, HttpServletResponse response, Model model) {
AppDesc appDesc = genAppDesc(request);
String appInstanceInfo = request.getParameter("appInstanceInfo");
logger.warn("appDesc:" + appDesc);
logger.warn("appInstanceInfo: " + appInstanceInfo);
// 不需要对格式进行检验,check已经做过了。
boolean isSuccess = importAppCenter.importAppAndInstance(appDesc, appInstanceInfo);
logger.warn("import app result is {}", isSuccess);
model.addAttribute("status", isSuccess ? 1 : 0);
return new ModelAndView("");
}
use of com.sohu.cache.entity.AppDesc in project cachecloud by sohutv.
the class AppDataMigrateController method appInstanceList.
/**
* 通过应用id获取可用的Redis实例信息
* @return
*/
@RequestMapping(value = "/appInstanceList")
public ModelAndView appInstanceList(HttpServletRequest request, HttpServletResponse response, Model model) {
String appIdStr = request.getParameter("appId");
long appId = NumberUtils.toLong(appIdStr);
AppDesc appDesc = appService.getByAppId(appId);
StringBuffer instances = new StringBuffer();
List<InstanceInfo> instanceList = appService.getAppInstanceInfo(appId);
if (CollectionUtils.isNotEmpty(instanceList)) {
for (int i = 0; i < instanceList.size(); i++) {
InstanceInfo instanceInfo = instanceList.get(i);
if (instanceInfo == null) {
continue;
}
if (instanceInfo.isOffline()) {
continue;
}
// 如果是sentinel类型的应用只出master
if (TypeUtil.isRedisSentinel(appDesc.getType())) {
if (TypeUtil.isRedisSentinel(instanceInfo.getType())) {
continue;
}
if (!redisCenter.isMaster(instanceInfo.getIp(), instanceInfo.getPort())) {
continue;
}
}
instances.append(instanceInfo.getIp() + ":" + instanceInfo.getPort());
if (i != instanceList.size() - 1) {
instances.append(ConstUtils.NEXT_LINE);
}
}
}
model.addAttribute("instances", instances.toString());
model.addAttribute("appType", appDesc == null ? -1 : appDesc.getType());
return new ModelAndView("");
}
use of com.sohu.cache.entity.AppDesc in project cachecloud by sohutv.
the class AppClientDataShowController method doCostDistribute.
/**
* 应用客户端耗时统计
*/
@RequestMapping("/costDistribute")
public ModelAndView doCostDistribute(HttpServletRequest request, HttpServletResponse response, Model model) {
// 1.应用信息
Long appId = NumberUtils.toLong(request.getParameter("appId"));
if (appId <= 0) {
return new ModelAndView("");
}
AppDesc appDesc = appService.getByAppId(appId);
model.addAttribute("appDesc", appDesc);
model.addAttribute("appId", appId);
// 2.获取时间区间
TimeBetween timeBetween = new TimeBetween();
try {
timeBetween = fillWithCostDateFormat(request, model);
} catch (ParseException e) {
logger.error(e.getMessage(), e);
}
long startTime = timeBetween.getStartTime();
long endTime = timeBetween.getEndTime();
Date startDate = timeBetween.getStartDate();
// 3.所有命令和第一个命令
List<String> allCommands = clientReportCostDistriService.getAppDistinctCommand(appId, startTime, endTime);
model.addAttribute("allCommands", allCommands);
// 4.所有客户端和实例对应关系
List<AppInstanceClientRelation> appInstanceClientRelationList = appInstanceClientRelationService.getAppInstanceClientRelationList(appId, startDate);
model.addAttribute("appInstanceClientRelationList", appInstanceClientRelationList);
String firstCommand = request.getParameter("firstCommand");
if (StringUtils.isBlank(firstCommand) && CollectionUtils.isNotEmpty(allCommands)) {
firstCommand = allCommands.get(0);
model.addAttribute("firstCommand", firstCommand);
} else {
model.addAttribute("firstCommand", firstCommand);
}
// 5.1 应用下客户端和实例的全局耗时统计列表
List<AppClientCostTimeTotalStat> appChartStatList = clientReportCostDistriService.getAppClientCommandTotalStat(appId, firstCommand, startTime, endTime);
Map<String, Object> resultMap = new HashMap<String, Object>();
// 5.2 简化字段
List<Map<String, Object>> app = new ArrayList<Map<String, Object>>();
for (AppClientCostTimeTotalStat appClientCostTimeTotalStat : appChartStatList) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("timeStamp", appClientCostTimeTotalStat.getTimeStamp());
map.put("count", appClientCostTimeTotalStat.getTotalCount());
map.put("mean", appClientCostTimeTotalStat.getMean());
map.put("median", appClientCostTimeTotalStat.getMedian());
map.put("max90", appClientCostTimeTotalStat.getNinetyPercentMax());
map.put("max99", appClientCostTimeTotalStat.getNinetyNinePercentMax());
map.put("max100", appClientCostTimeTotalStat.getHundredMax());
map.put("maxInst", appClientCostTimeTotalStat.getMaxInstanceHost() + ":" + appClientCostTimeTotalStat.getMaxInstancePort());
map.put("maxClient", appClientCostTimeTotalStat.getMaxClientIp());
app.add(map);
}
resultMap.put("app", app);
model.addAttribute("appChartStatListJson", JSONObject.toJSONString(resultMap));
return new ModelAndView("client/clientCostDistribute");
}
Aggregations