Search in sources :

Example 1 with ServerDeployHistory

use of com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory in project Corgi by kevinYin.

the class DeployHistoryServiceImplTest method testGetDeployHistory.

private void testGetDeployHistory(int historyId, DeploymentOrder order) {
    DeployHistory history = deployHistoryService.getByHistoryId(historyId);
    assertNotNull(history);
    assertNotNull(history.getServerDeployHistories());
    assertTrue(history.getServerDeployHistories().size() == order.getServerId().length);
    Set<Integer> serverSet = new HashSet<>();
    for (int serverId : order.getServerId()) {
        serverSet.add(serverId);
    }
    for (ServerDeployHistory sdh : history.getServerDeployHistories()) {
        assertTrue(sdh.getHistoryId() == historyId);
        assertTrue(StringUtils.isNotEmpty(sdh.getServerIp()));
        assertTrue(StringUtils.isNotEmpty(sdh.getServerName()));
        assertTrue(sdh.getDeployStatus() == ServerDeployResult.WAITING_FOR_DEPLOYMENT.getValue());
        assertTrue(serverSet.contains(sdh.getServerId()));
    }
}
Also used : ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) HashSet(java.util.HashSet)

Example 2 with ServerDeployHistory

use of com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory in project Corgi by kevinYin.

the class DeployHistoryServiceImpl method fillLogIntoServerDeploy.

private void fillLogIntoServerDeploy(List<ServerDeployHistory> deployHistoryList) {
    List<Integer> serverDeployIds = Lists.newArrayList();
    for (ServerDeployHistory history : deployHistoryList) {
        serverDeployIds.add(history.getId());
    }
    List<ServerDeployLog> deployLogs = deployLogService.getByServerDeployHistoryIds(serverDeployIds);
    ArrayListMultimap<Integer, ServerDeployLog> serverDeployId2DeployLogsMap = ArrayListMultimap.create();
    for (ServerDeployLog deployLog : deployLogs) {
        serverDeployId2DeployLogsMap.put(deployLog.getServerDeployId(), deployLog);
    }
    for (ServerDeployHistory deployHistory : deployHistoryList) {
        if (serverDeployId2DeployLogsMap.get(deployHistory.getId()) != null) {
            deployHistory.setServerDeployLogs(serverDeployId2DeployLogsMap.get(deployHistory.getId()));
        }
    }
}
Also used : ServerDeployLog(com.ibeiliao.deployment.admin.vo.server.ServerDeployLog) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory)

Example 3 with ServerDeployHistory

use of com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory 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 4 with ServerDeployHistory

use of com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory in project Corgi by kevinYin.

the class DeployHistoryServiceImpl method createRollbackOrder.

@Override
public void createRollbackOrder(int historyId, long accountId, boolean isRollBack) {
    DeployHistory deployHistory = getByHistoryId(historyId);
    if (deployHistory == null) {
        throw new IllegalArgumentException("发布记录不存在");
    }
    AdminAccount account = adminAccountService.getById(accountId);
    DeploymentOrder order = new DeploymentOrder();
    VOUtil.copy(deployHistory, order);
    order.setAccountId(accountId);
    order.setRealName(account.getRealname());
    List<ServerDeployHistory> serverDeployHistories = deployHistory.getServerDeployHistories();
    int[] serverId = new int[serverDeployHistories.size()];
    for (int i = 0; i < serverId.length; i++) {
        serverId[i] = serverDeployHistories.get(i).getServerId();
    }
    order.setServerId(serverId);
    order.setRollbackToDeployId(historyId);
    if (isRollBack) {
        order.setTitle("回滚到" + historyId + "的版本");
    } else {
        order.setTitle("重发" + historyId + "的版本");
    }
    createDeploymentOrder(order);
}
Also used : ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount) DeploymentOrder(com.ibeiliao.deployment.admin.vo.deploy.DeploymentOrder) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)

Aggregations

ServerDeployHistory (com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory)4 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)3 DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)1 ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)1 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)1 DeploymentOrder (com.ibeiliao.deployment.admin.vo.deploy.DeploymentOrder)1 ServerDeployLog (com.ibeiliao.deployment.admin.vo.server.ServerDeployLog)1 HashSet (java.util.HashSet)1