Search in sources :

Example 6 with AppAudit

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

the class InstanceManageController method doInitInstanceConfigChange.

/**
     * 处理实例配置修改
     * 
     * @param appAuditId 审批id
     */
@RequestMapping(value = "/initInstanceConfigChange")
public ModelAndView doInitInstanceConfigChange(HttpServletRequest request, HttpServletResponse response, Model model, Long appAuditId) {
    // 申请原因
    AppAudit appAudit = appService.getAppAuditById(appAuditId);
    model.addAttribute("appAudit", appAudit);
    // 用第一个参数存实例id
    Long instanceId = NumberUtils.toLong(appAudit.getParam1());
    Map<String, String> redisConfigList = redisCenter.getRedisConfigList(instanceId.intValue());
    model.addAttribute("redisConfigList", redisConfigList);
    // 实例
    InstanceInfo instanceInfo = instanceStatsCenter.getInstanceInfo(instanceId);
    model.addAttribute("instanceInfo", instanceInfo);
    model.addAttribute("appId", appAudit.getAppId());
    model.addAttribute("appAuditId", appAuditId);
    // 修改配置的键值对
    model.addAttribute("instanceConfigKey", appAudit.getParam2());
    model.addAttribute("instanceConfigValue", appAudit.getParam3());
    return new ModelAndView("manage/appAudit/initInstanceConfigChange");
}
Also used : AppAudit(com.sohu.cache.entity.AppAudit) ModelAndView(org.springframework.web.servlet.ModelAndView) InstanceInfo(com.sohu.cache.entity.InstanceInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with AppAudit

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

the class AppDeployCenterImpl method allocateResourceApp.

@Override
public boolean allocateResourceApp(Long appAuditId, List<String> nodeInfoList, AppUser auditUser) {
    if (appAuditId == null || appAuditId <= 0L) {
        logger.error("appAuditId is null");
        return false;
    }
    if (nodeInfoList == null || nodeInfoList.isEmpty()) {
        logger.error("nodeInfoList is null");
        return false;
    }
    AppAudit appAudit = appAuditDao.getAppAudit(appAuditId);
    if (appAudit == null) {
        logger.error("appAudit:id={} is not exist", appAuditId);
        return false;
    }
    long appId = appAudit.getAppId();
    AppDesc appDesc = appService.getByAppId(appId);
    if (appDesc == null) {
        logger.error("appDesc:id={} is not exist");
        return false;
    }
    int type = appDesc.getType();
    List<String[]> nodes = new ArrayList<String[]>();
    for (String nodeInfo : nodeInfoList) {
        nodeInfo = StringUtils.trim(nodeInfo);
        if (StringUtils.isBlank(nodeInfo)) {
            continue;
        }
        String[] array = nodeInfo.split(":");
        //            if (array.length < 2) {
        //                logger.error("error nodeInfo:{}", Arrays.toString(array));
        //                continue;
        //            }
        nodes.add(array);
    }
    boolean isAudited = false;
    if (TypeUtil.isRedisType(type)) {
        if (TypeUtil.isRedisCluster(type)) {
            isAudited = deployCluster(appId, nodes);
        } else if (nodes.size() > 0) {
            if (TypeUtil.isRedisSentinel(type)) {
                isAudited = deploySentinel(appId, nodes);
            } else {
                isAudited = deployStandalone(appId, nodes.get(0));
            }
        } else {
            logger.error("nodeInfoList={} is error");
        }
    } else {
        logger.error("unknown type : {}", type);
        return false;
    }
    //审核通过
    if (isAudited) {
        // 改变审核状态
        appAuditDao.updateAppAudit(appAudit.getId(), AppCheckEnum.APP_ALLOCATE_RESOURCE.value());
    }
    return true;
}
Also used : AppAudit(com.sohu.cache.entity.AppAudit) ArrayList(java.util.ArrayList) AppDesc(com.sohu.cache.entity.AppDesc)

Example 8 with AppAudit

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

the class AppDeployCenterImpl method checkHorizontalNodes.

@Override
public DataFormatCheckResult checkHorizontalNodes(Long appAuditId, String masterSizeSlave) {
    if (appAuditId == null) {
        logger.error("appAuditId is null");
        return DataFormatCheckResult.fail("审核id不能为空!");
    }
    if (StringUtils.isBlank(masterSizeSlave)) {
        logger.error("masterSizeSlave is null");
        return DataFormatCheckResult.fail("添加节点不能为空!");
    }
    AppAudit appAudit = appAuditDao.getAppAudit(appAuditId);
    if (appAudit == null) {
        logger.error("appAudit:id={} is not exist", appAuditId);
        return DataFormatCheckResult.fail(String.format("审核id=%s不存在", appAuditId));
    }
    long appId = appAudit.getAppId();
    AppDesc appDesc = appService.getByAppId(appId);
    if (appDesc == null) {
        logger.error("appDesc:id={} is not exist");
        return DataFormatCheckResult.fail(String.format("appId=%s不存在", appId));
    }
    //节点数组 master:memSize:slave
    String[] array = masterSizeSlave.split(ConstUtils.COLON);
    if (array == null || array.length == 0) {
        return DataFormatCheckResult.fail(String.format("添加节点%s格式错误", masterSizeSlave));
    }
    //检查格式
    String masterHost = null;
    String memSize = null;
    String slaveHost = null;
    if (array.length == 2) {
        masterHost = array[0];
        memSize = array[1];
    } else if (array.length == 3) {
        masterHost = array[0];
        memSize = array[1];
        slaveHost = array[2];
    } else {
        return DataFormatCheckResult.fail(String.format("添加节点%s, 格式错误!", masterSizeSlave));
    }
    //检查主节点机器是否存在
    if (!checkHostExist(masterHost)) {
        return DataFormatCheckResult.fail(String.format("%s中的ip=%s不存在,请在机器管理中添加!", masterSizeSlave, masterHost));
    }
    //检查memSize格式
    if (StringUtils.isNotBlank(memSize) && !NumberUtils.isDigits(memSize)) {
        return DataFormatCheckResult.fail(String.format("%s中的中的memSize=%s不是整数!", masterSizeSlave, memSize));
    }
    //检查从节点格式
    if (StringUtils.isNotBlank(slaveHost) && !checkHostExist(slaveHost)) {
        return DataFormatCheckResult.fail(String.format("%s中的ip=%s不存在,请在机器管理中添加!", masterSizeSlave, slaveHost));
    }
    return DataFormatCheckResult.success("添加节点格式正确,可以开始部署了!");
}
Also used : AppAudit(com.sohu.cache.entity.AppAudit) AppDesc(com.sohu.cache.entity.AppDesc)

Example 9 with AppAudit

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

the class AppAuditDaoTest method testInsert.

@Test
public void testInsert() {
    int memSize = 4;
    AppDesc appDesc = appDao.getAppDescById(10132L);
    AppUser appUser = appUserDao.get(10016L);
    AppAudit appAudit = new AppAudit();
    appAudit.setAppId(appDesc.getAppId());
    appAudit.setUserId(appUser.getId());
    appAudit.setUserName(appUser.getName());
    appAudit.setModifyTime(new Date());
    appAudit.setParam1(String.valueOf(memSize));
    appAudit.setParam2(appDesc.getTypeDesc());
    appAudit.setInfo("应用申请:类型:" + appDesc.getTypeDesc() + ";初始申请空间:" + memSize + ";");
    appAudit.setStatus(AppStatusEnum.STATUS_INITIALIZE.getStatus());
    appAudit.setType(AppAuditType.APP_AUDIT.getValue());
    appAuditDao.insertAppAudit(appAudit);
}
Also used : AppAudit(com.sohu.cache.entity.AppAudit) AppUser(com.sohu.cache.entity.AppUser) AppDesc(com.sohu.cache.entity.AppDesc) Date(java.util.Date) BaseTest(com.sohu.test.BaseTest) Test(org.junit.Test)

Aggregations

AppAudit (com.sohu.cache.entity.AppAudit)9 AppDesc (com.sohu.cache.entity.AppDesc)4 AppUser (com.sohu.cache.entity.AppUser)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 BaseTest (com.sohu.test.BaseTest)2 Date (java.util.Date)2 Test (org.junit.Test)2 AppAuditLog (com.sohu.cache.entity.AppAuditLog)1 InstanceInfo (com.sohu.cache.entity.InstanceInfo)1 SuccessEnum (com.sohu.cache.web.enums.SuccessEnum)1 ArrayList (java.util.ArrayList)1