Search in sources :

Example 1 with ServerGroup

use of com.ibeiliao.deployment.admin.vo.server.ServerGroup in project Corgi by kevinYin.

the class ModuleServiceTest method testCheckResinPort.

@Test
public void testCheckResinPort() {
    ProjectModule module = moduleService.getByModuleId(6);
    List<ServerGroup> serverGroups = serverGroupService.getByModuleIds(Lists.newArrayList(6), true);
    module.setServerGroups(serverGroups);
    module.setModuleId(0);
    module.getResinConf().setHttpPort(8087);
    module.getResinConf().setServerPort(6807);
    module.getResinConf().setWatchdogPort(6608);
    Map<String, String> resinPort2OccupyInfoMap = moduleService.checkResinPortOccupy(module);
    assert !resinPort2OccupyInfoMap.isEmpty();
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Test(org.junit.Test)

Example 2 with ServerGroup

use of com.ibeiliao.deployment.admin.vo.server.ServerGroup in project Corgi by kevinYin.

the class ServerServiceImpl method getByModuleId.

@Override
public List<Server> getByModuleId(int moduleId) {
    Assert.isTrue(moduleId > 0, "moduleId数值非法");
    List<ServerGroup> serverGroups = serverGroupService.getByModuleIds(Lists.newArrayList(moduleId), false);
    if (CollectionUtils.isEmpty(serverGroups)) {
        return Collections.emptyList();
    }
    List<Integer> groupIds = Lists.newArrayList();
    for (ServerGroup group : serverGroups) {
        groupIds.add(group.getGroupId());
    }
    List<ServerPO> serverPOs = serverDao.getByGroupIds(groupIds);
    if (CollectionUtils.isEmpty(serverPOs)) {
        return Collections.emptyList();
    }
    return VOUtil.fromList(serverPOs, Server.class);
}
Also used : ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) ServerPO(com.ibeiliao.deployment.admin.po.server.ServerPO)

Example 3 with ServerGroup

use of com.ibeiliao.deployment.admin.vo.server.ServerGroup in project Corgi by kevinYin.

the class CreateDeploymentController method queryModuleServer.

/**
 * 查询模块在某个环境的服务器列表
 *
 * @param moduleId 模块ID
 * @param envId    环境ID,必定大于0
 * @return
 */
@RequestMapping("queryModuleServer")
@ResponseBody
@MenuResource("查询模块服务器列表")
public RestResult<Map<String, Object>> queryModuleServer(int moduleId, int envId) {
    Assert.isTrue(moduleId > 0);
    Assert.isTrue(envId > 0);
    List<ServerGroup> groups = serverGroupService.getByModuleAndEnv(moduleId, envId);
    List<Integer> groupIds = new ArrayList<>(groups.size());
    for (ServerGroup group : groups) {
        groupIds.add(group.getGroupId());
    }
    List<Server> servers = serverService.getByGroupIds(groupIds);
    Map<String, Object> result = new HashMap<>(4);
    result.put("servers", servers);
    result.put("groups", groups);
    return new RestResult<>(result);
}
Also used : ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) RestResult(com.ibeiliao.deployment.admin.common.RestResult) Server(com.ibeiliao.deployment.admin.vo.server.Server) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with ServerGroup

use of com.ibeiliao.deployment.admin.vo.server.ServerGroup in project Corgi by kevinYin.

the class ProjectModuleServiceImpl method insertServerGroupAndServer.

private void insertServerGroupAndServer(List<ServerGroup> groups, int moduleId) {
    if (CollectionUtils.isEmpty(groups)) {
        return;
    }
    List<ServerGroup> needInsertGroups = Lists.newArrayList();
    List<ServerGroup> oldGroups = Lists.newArrayList();
    for (ServerGroup group : groups) {
        group.setModuleId(moduleId);
        if (group.getGroupId() == 0) {
            needInsertGroups.add(group);
        } else {
            oldGroups.add(group);
        }
    }
    List<ServerGroup> serverGroups = serverGroupService.batchInsertGroups(needInsertGroups);
    List<Server> servers = Lists.newArrayList();
    // 新增的group的server
    for (ServerGroup group : serverGroups) {
        List<Server> serverList = group.getServers();
        if (CollectionUtils.isNotEmpty(serverList)) {
            for (Server server : serverList) {
                server.setGroupId(group.getGroupId());
                servers.add(server);
            }
        }
    }
    // 旧的group新增的server
    for (ServerGroup oldGroup : oldGroups) {
        if (CollectionUtils.isNotEmpty(oldGroup.getServers())) {
            for (Server server : oldGroup.getServers()) {
                server.setGroupId(oldGroup.getGroupId());
                if (server.getServerId() == 0) {
                    servers.add(server);
                }
            }
        }
    }
    if (CollectionUtils.isNotEmpty(servers)) {
        serverService.batchInsertServer(servers);
    }
}
Also used : ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server)

Example 5 with ServerGroup

use of com.ibeiliao.deployment.admin.vo.server.ServerGroup in project Corgi by kevinYin.

the class ProjectModuleServiceImpl method saveServerGroupAndServer.

private void saveServerGroupAndServer(List<ServerGroup> groups, int moduleId) {
    if (CollectionUtils.isEmpty(groups)) {
        return;
    }
    List<ServerGroup> needUpdateGroups = Lists.newArrayList();
    List<Server> needUpdateServers = Lists.newArrayList();
    List<Integer> oldServerGroupIds = Lists.newArrayList();
    List<Integer> oldServerIds = Lists.newArrayList();
    for (ServerGroup group : groups) {
        group.setModuleId(moduleId);
        if (group.getGroupId() <= 0) {
            continue;
        }
        needUpdateGroups.add(group);
        oldServerGroupIds.add(group.getGroupId());
        if (CollectionUtils.isNotEmpty(group.getServers())) {
            for (Server server : group.getServers()) {
                if (server.getServerId() > 0) {
                    oldServerIds.add(server.getServerId());
                    needUpdateServers.add(server);
                }
                server.setIp(StringUtils.trimToEmpty(server.getIp()));
            }
        }
    }
    // 删除被删除的服务器组
    serverGroupService.deleteByOldGroupIds(oldServerGroupIds, moduleId);
    // 先删除提交后不存在的服务器
    serverService.deleteByServerGroupIdsAndServerIds(oldServerGroupIds, oldServerIds);
    // 更新服务器组和服务器
    for (ServerGroup group : needUpdateGroups) {
        serverGroupService.updateGroup(group);
    }
    for (Server server : needUpdateServers) {
        serverService.updateServer(server);
    }
    // 插入新增的服务器组合服务器
    insertServerGroupAndServer(groups, moduleId);
}
Also used : ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server)

Aggregations

ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)14 Server (com.ibeiliao.deployment.admin.vo.server.Server)11 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)3 ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)2 ResinConf (com.ibeiliao.deployment.transfer.vo.ResinConf)2 RestResult (com.ibeiliao.deployment.admin.common.RestResult)1 DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)1 ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)1 ModuleConfPO (com.ibeiliao.deployment.admin.po.project.ModuleConfPO)1 ProjectModulePO (com.ibeiliao.deployment.admin.po.project.ProjectModulePO)1 ServerPO (com.ibeiliao.deployment.admin.po.server.ServerPO)1 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)1 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)1 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)1 TransferRequest (com.ibeiliao.deployment.transfer.vo.TransferRequest)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Test (org.junit.Test)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1