Search in sources :

Example 21 with AppDesc

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);
}
Also used : HashMap(java.util.HashMap) AppDesc(com.sohu.cache.entity.AppDesc)

Example 22 with AppDesc

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;
}
Also used : AppUser(com.sohu.cache.entity.AppUser) AppDesc(com.sohu.cache.entity.AppDesc) Date(java.util.Date)

Example 23 with 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("");
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) AppDesc(com.sohu.cache.entity.AppDesc) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 24 with AppDesc

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("");
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) AppDesc(com.sohu.cache.entity.AppDesc) InstanceInfo(com.sohu.cache.entity.InstanceInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 25 with AppDesc

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");
}
Also used : HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) AppDesc(com.sohu.cache.entity.AppDesc) Date(java.util.Date) AppInstanceClientRelation(com.sohu.cache.entity.AppInstanceClientRelation) JSONObject(com.alibaba.fastjson.JSONObject) ParseException(java.text.ParseException) HashMap(java.util.HashMap) Map(java.util.Map) AppClientCostTimeTotalStat(com.sohu.cache.entity.AppClientCostTimeTotalStat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AppDesc (com.sohu.cache.entity.AppDesc)47 BaseTest (com.sohu.test.BaseTest)18 Test (org.junit.Test)18 ImportAppResult (com.sohu.cache.constant.ImportAppResult)15 InstanceInfo (com.sohu.cache.entity.InstanceInfo)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ModelAndView (org.springframework.web.servlet.ModelAndView)7 Date (java.util.Date)5 Jedis (redis.clients.jedis.Jedis)5 AppAudit (com.sohu.cache.entity.AppAudit)4 InstanceStats (com.sohu.cache.entity.InstanceStats)3 IdempotentConfirmer (com.sohu.cache.util.IdempotentConfirmer)3 ParseException (java.text.ParseException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 AppUser (com.sohu.cache.entity.AppUser)2 AppDetailVO (com.sohu.cache.web.vo.AppDetailVO)2 JSONObject (com.alibaba.fastjson.JSONObject)1 AppClientCostTimeTotalStat (com.sohu.cache.entity.AppClientCostTimeTotalStat)1 AppClientExceptionStat (com.sohu.cache.entity.AppClientExceptionStat)1