Search in sources :

Example 1 with ServerDeployHistoryPO

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

the class ServerDeployHistoryDaoTest method testInsertUpdate.

@Test
public void testInsertUpdate() {
    int historyId = (int) (System.currentTimeMillis() / 1000);
    ServerDeployHistoryPO po = new ServerDeployHistoryPO();
    po.setHistoryId(historyId);
    po.setServerId(1);
    po.setServerIp("127.0.0.1");
    po.setServerName("localhost");
    po.setDeployStatus(DeployStatus.DEPLOYING.getValue());
    po.setStartupTime(null);
    serverDeployHistoryDao.insert(po);
    List<ServerDeployHistoryPO> list = serverDeployHistoryDao.getByHistoryId(historyId);
    assertNotNull(list);
    assertTrue(list.size() == 1);
    int rows = serverDeployHistoryDao.updateStatus(po.getId(), DeployStatus.DEPLOYED.getValue(), new Date());
    assertTrue(rows == 1);
    rows = serverDeployHistoryDao.updateAllStatus(historyId, DeployStatus.CANCELLED.getValue(), new Date());
    assertTrue(rows == 1);
}
Also used : ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) Date(java.util.Date) Test(org.junit.Test)

Example 2 with ServerDeployHistoryPO

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

the class DeployLogServiceImpl method rebuildServerDeployId.

private void rebuildServerDeployId(List<ServerCollectLog> logs) {
    List<String> ips = Lists.newArrayList();
    for (ServerCollectLog log : logs) {
        if (StringUtils.isNotBlank(log.getServerIp())) {
            ips.add(log.getServerIp().trim());
        }
    }
    List<Integer> historyIds = Lists.newArrayList();
    for (ServerCollectLog log : logs) {
        if (log.getId() >= 0) {
            historyIds.add(log.getId());
        }
    }
    if (CollectionUtils.isEmpty(ips) || CollectionUtils.isEmpty(historyIds)) {
        return;
    }
    List<ServerDeployHistoryPO> deployHistoryPOs = serverDeployHistoryDao.getByHistoryIdsAndIps(historyIds, ips);
    if (CollectionUtils.isEmpty(deployHistoryPOs)) {
        return;
    }
    HashMap<String, Integer> historyIdIp2ServerDeployIdMap = Maps.newHashMap();
    for (ServerDeployHistoryPO po : deployHistoryPOs) {
        historyIdIp2ServerDeployIdMap.put(po.getHistoryId() + "_" + po.getServerIp(), po.getId());
    }
    for (ServerCollectLog log : logs) {
        Integer serverDeployId = historyIdIp2ServerDeployIdMap.get(log.getId() + "_" + log.getServerIp());
        if (serverDeployId != null) {
            log.setId(serverDeployId);
        }
    }
}
Also used : ServerCollectLog(com.ibeiliao.deployment.common.vo.ServerCollectLog) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)

Example 3 with ServerDeployHistoryPO

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

the class DeployHistoryServiceImpl method getProjectByServerDeployIds.

@Override
public List<Project> getProjectByServerDeployIds(List<Integer> serverDeployIdList) {
    if (!CollectionUtils.isEmpty(serverDeployIdList)) {
        Set<Integer> projectIdSet = new HashSet<>();
        for (Integer serverDeployId : serverDeployIdList) {
            ServerDeployHistoryPO po = serverDeployHistoryDao.get(serverDeployId);
            if (po != null) {
                DeployHistoryPO historyPO = deployHistoryDao.get(po.getHistoryId());
                projectIdSet.add(historyPO.getProjectId());
            }
        }
        if (!CollectionUtils.isEmpty(projectIdSet)) {
            List<Project> projects = new ArrayList<>();
            for (Integer id : projectIdSet) {
                Project project = projectService.getProject(id);
                projects.add(project);
            }
            return projects;
        }
    }
    return Collections.emptyList();
}
Also used : Project(com.ibeiliao.deployment.admin.vo.project.Project) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)

Example 4 with ServerDeployHistoryPO

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

the class DeployHistoryServiceImpl method getByHistoryId.

@Override
public DeployHistory getByHistoryId(int historyId) {
    DeployHistoryPO po = deployHistoryDao.get(historyId);
    if (po == null) {
        return null;
    }
    List<ServerDeployHistoryPO> servers = serverDeployHistoryDao.getByHistoryId(historyId);
    DeployHistory history = new DeployHistory();
    VOUtil.copy(po, history);
    List<ServerDeployHistory> deployHistoryList = VOUtil.fromList(servers, ServerDeployHistory.class);
    fillLogIntoServerDeploy(deployHistoryList);
    history.setServerDeployHistories(deployHistoryList);
    fillNames(history);
    return history;
}
Also used : ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)

Example 5 with ServerDeployHistoryPO

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

the class DeployHistoryServiceImpl method saveDeployServers.

private void saveDeployServers(DeployHistoryPO po, DeploymentOrder order, List<Server> servers) {
    Map<Integer, Server> serverMap = new HashMap<>(servers.size() * 4 / 3);
    for (Server server : servers) {
        serverMap.put(server.getServerId(), server);
    }
    for (int serverId : order.getServerId()) {
        ServerDeployHistoryPO serverDeployHistoryPO = new ServerDeployHistoryPO();
        serverDeployHistoryPO.setHistoryId(po.getHistoryId());
        serverDeployHistoryPO.setServerId(serverId);
        Server server = serverMap.get(serverId);
        serverDeployHistoryPO.setServerName(server.getServerName());
        serverDeployHistoryPO.setServerIp(server.getIp());
        serverDeployHistoryPO.setDeployStatus(ServerDeployResult.WAITING_FOR_DEPLOYMENT.getValue());
        serverDeployHistoryDao.insert(serverDeployHistoryPO);
    }
}
Also used : Server(com.ibeiliao.deployment.admin.vo.server.Server) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)

Aggregations

ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)7 DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)4 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)2 ServerDeployHistory (com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory)2 Server (com.ibeiliao.deployment.admin.vo.server.Server)2 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)1 Project (com.ibeiliao.deployment.admin.vo.project.Project)1 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)1 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)1 ServerCollectLog (com.ibeiliao.deployment.common.vo.ServerCollectLog)1 Date (java.util.Date)1 Test (org.junit.Test)1