Search in sources :

Example 1 with ModuleConfPO

use of com.ibeiliao.deployment.admin.po.project.ModuleConfPO in project Corgi by kevinYin.

the class ProjectModuleServiceImpl method loadModuleConf.

/**
 * 加载模块配置,比如 web 配置
 *
 * @param projectModule
 * @author linyi 2017/3/14
 */
private void loadModuleConf(ProjectModule projectModule) {
    ModuleConfPO moduleConf = moduleConfDao.get(Constants.CONF_TYPE_RESIN, projectModule.getModuleId());
    if (moduleConf != null && StringUtils.isNotEmpty(moduleConf.getConfValue())) {
        ResinConf resinConf = JSON.parseObject(moduleConf.getConfValue(), ResinConf.class);
        resinConf.setModuleId(projectModule.getModuleId());
        projectModule.setResinConf(resinConf);
    }
}
Also used : ResinConf(com.ibeiliao.deployment.transfer.vo.ResinConf) ModuleConfPO(com.ibeiliao.deployment.admin.po.project.ModuleConfPO)

Example 2 with ModuleConfPO

use of com.ibeiliao.deployment.admin.po.project.ModuleConfPO in project Corgi by kevinYin.

the class ProjectModuleServiceImpl method setResinConfCreated.

@Override
public void setResinConfCreated(int moduleId) {
    ModuleConfPO moduleConf = moduleConfDao.get(Constants.CONF_TYPE_RESIN_GEN_FLAG, moduleId);
    if (moduleConf == null) {
        moduleConf = new ModuleConfPO();
        moduleConf.setConfValue("1");
        moduleConf.setModuleId(moduleId);
        moduleConf.setConfType(Constants.CONF_TYPE_RESIN_GEN_FLAG);
        moduleConf.setCreateTime(new Date());
        moduleConf.setUpdateTime(moduleConf.getCreateTime());
        moduleConfDao.insert(moduleConf);
    }
}
Also used : ModuleConfPO(com.ibeiliao.deployment.admin.po.project.ModuleConfPO)

Example 3 with ModuleConfPO

use of com.ibeiliao.deployment.admin.po.project.ModuleConfPO in project Corgi by kevinYin.

the class ProjectModuleServiceImpl method saveResinConf.

/**
 * 保存 resin 配置
 *
 * @param projectModule
 * @author linyi 2017/3/14
 */
private void saveResinConf(ProjectModule projectModule) {
    if (projectModule.getModuleType() == ModuleType.WEB_PROJECT.getValue()) {
        ResinConf resinConf = projectModule.getResinConf();
        resinConf.setConfType(Constants.CONF_TYPE_RESIN);
        resinConf.setModuleId(projectModule.getModuleId());
        ModuleConfPO current = moduleConfDao.get(resinConf.getConfType(), projectModule.getModuleId());
        if (resinConf.getKeepaliveTimeout() <= 0) {
            resinConf.setKeepaliveTimeout(Constants.DEFAULT_KEEPALIVE_TIMEOUT);
        }
        if (resinConf.getSocketTimeout() <= 0) {
            resinConf.setSocketTimeout(Constants.DEFAULT_SOCKET_TIMEOUT);
        }
        if (current == null) {
            ModuleConfPO po = new ModuleConfPO();
            po.setConfType(resinConf.getConfType());
            po.setModuleId(projectModule.getModuleId());
            po.setCreateTime(new Date());
            po.setUpdateTime(po.getCreateTime());
            po.setConfValue(JSON.toJSONString(resinConf));
            moduleConfDao.insert(po);
        } else {
            current.setUpdateTime(new Date());
            current.setConfValue(JSON.toJSONString(resinConf));
            moduleConfDao.update(current);
        }
    }
}
Also used : ResinConf(com.ibeiliao.deployment.transfer.vo.ResinConf) ModuleConfPO(com.ibeiliao.deployment.admin.po.project.ModuleConfPO)

Example 4 with ModuleConfPO

use of com.ibeiliao.deployment.admin.po.project.ModuleConfPO in project Corgi by kevinYin.

the class ProjectModuleServiceImpl method getModuleConf.

private List<ModuleConfPO> getModuleConf(ProjectModule projectModule) {
    ResinConf resinConf = projectModule.getResinConf();
    String httpPort = "%\"httpPort\":" + resinConf.getHttpPort() + "%";
    String serverPort = "%\"serverPort\":" + resinConf.getServerPort() + "%";
    String watchDogPort = "%\"watchdogPort\":" + resinConf.getWatchdogPort() + "%";
    List<ModuleConfPO> matchModuleConfList = moduleConfDao.getByTypeAndValue(Constants.CONF_TYPE_RESIN, httpPort, serverPort, watchDogPort);
    if (CollectionUtils.isEmpty(matchModuleConfList)) {
        return Collections.emptyList();
    }
    if (projectModule.getModuleId() <= 0) {
        return matchModuleConfList;
    }
    List<ModuleConfPO> moduleConfPOS = Lists.newArrayList();
    for (ModuleConfPO confPO : matchModuleConfList) {
        if (confPO.getModuleId() != projectModule.getModuleId()) {
            moduleConfPOS.add(confPO);
        }
    }
    return moduleConfPOS;
}
Also used : ResinConf(com.ibeiliao.deployment.transfer.vo.ResinConf) ModuleConfPO(com.ibeiliao.deployment.admin.po.project.ModuleConfPO)

Example 5 with ModuleConfPO

use of com.ibeiliao.deployment.admin.po.project.ModuleConfPO in project Corgi by kevinYin.

the class ProjectModuleServiceImpl method buildOccupyInfoMap.

private Map<String, String> buildOccupyInfoMap(ProjectModule projectModule, List<Server> allServers) {
    List<ModuleConfPO> matchModuleConfList = getModuleConf(projectModule);
    if (CollectionUtils.isEmpty(matchModuleConfList)) {
        return Collections.emptyMap();
    }
    List<Integer> moduleIds = Lists.newArrayList();
    for (ModuleConfPO po : matchModuleConfList) {
        if (projectModule.getModuleId() > 0 && po.getModuleId() == projectModule.getModuleId()) {
            continue;
        }
        moduleIds.add(po.getModuleId());
    }
    List<ServerGroup> serverGroupList = serverGroupService.getByModuleIds(moduleIds, true);
    if (CollectionUtils.isEmpty(serverGroupList)) {
        return Collections.emptyMap();
    }
    List<ProjectModulePO> modulePOs = projectModuleDao.getByModuleIds(moduleIds);
    HashMap<Integer, ProjectModulePO> moduleId2ModuleMap = Maps.newHashMap();
    for (ProjectModulePO modulePO : modulePOs) {
        moduleId2ModuleMap.put(modulePO.getModuleId(), modulePO);
    }
    HashMap<Integer, ModuleConfPO> moduleId2ConfMap = Maps.newHashMap();
    for (ModuleConfPO confPO : matchModuleConfList) {
        moduleId2ConfMap.put(confPO.getModuleId(), confPO);
    }
    Set<String> moduleServerIps = Sets.newHashSet();
    for (Server server : allServers) {
        moduleServerIps.add(server.getIp());
    }
    HashMap<String, String> port2OccupyInfoMap = Maps.newHashMap();
    // 找到有相同的服务器,再看看是哪个端口有冲突
    for (ServerGroup group : serverGroupList) {
        List<Server> servers = group.getServers();
        if (CollectionUtils.isEmpty(servers)) {
            continue;
        }
        for (Server server : servers) {
            if (moduleServerIps.contains(server.getIp()) && moduleId2ModuleMap.get(group.getModuleId()) != null && moduleId2ConfMap.get(group.getModuleId()) != null) {
                ProjectModulePO modulePO = moduleId2ModuleMap.get(group.getModuleId());
                ModuleConfPO confPO = moduleId2ConfMap.get(group.getModuleId());
                ResinConf resinConf = projectModule.getResinConf();
                String occupyInfo = " 已被项目id为 " + modulePO.getProjectId() + " 的" + modulePO.getModuleNameZh() + " 模块所占用,相关服务器IP为 " + server.getIp();
                if (confPO.getConfValue().contains("\"httpPort\":" + resinConf.getHttpPort())) {
                    port2OccupyInfoMap.put("http端口" + resinConf.getHttpPort(), occupyInfo);
                }
                if (confPO.getConfValue().contains("\"serverPort\":" + resinConf.getServerPort())) {
                    port2OccupyInfoMap.put("服务器端口" + resinConf.getServerPort(), occupyInfo);
                }
                if (confPO.getConfValue().contains("\"watchdogPort\":" + resinConf.getWatchdogPort())) {
                    port2OccupyInfoMap.put("watchdog端口" + resinConf.getWatchdogPort(), occupyInfo);
                }
            }
        }
    }
    return port2OccupyInfoMap;
}
Also used : ResinConf(com.ibeiliao.deployment.transfer.vo.ResinConf) ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server) ModuleConfPO(com.ibeiliao.deployment.admin.po.project.ModuleConfPO) ProjectModulePO(com.ibeiliao.deployment.admin.po.project.ProjectModulePO)

Aggregations

ModuleConfPO (com.ibeiliao.deployment.admin.po.project.ModuleConfPO)5 ResinConf (com.ibeiliao.deployment.transfer.vo.ResinConf)4 ProjectModulePO (com.ibeiliao.deployment.admin.po.project.ProjectModulePO)1 Server (com.ibeiliao.deployment.admin.vo.server.Server)1 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)1