Search in sources :

Example 6 with DeployHistoryPO

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

the class DeployHistoryServiceImpl method createDeploymentOrder.

@Override
@Transactional
public void createDeploymentOrder(DeploymentOrder order) {
    validateParameterAndModule(order);
    // 检查服务器是否存在 & 环境是否为 envId
    List<Server> servers = checkServerStatus(order);
    checkProjectAuthorization(order);
    checkIfDeployingModuleWithEnv(order);
    logger.info("创建上线单 | order: " + JSON.toJSONString(order));
    ProjectModule module = projectModuleService.getByModuleId(order.getModuleId());
    DeployHistoryPO deployHistory = new DeployHistoryPO();
    VOUtil.copy(order, deployHistory);
    deployHistory.setCreateTime(new Date());
    deployHistory.setProjectId(module.getProjectId());
    deployHistory.setModuleName(module.getModuleName());
    deployHistory.setResult(DeployResult.NONE.getValue());
    // 如果模块需要审核,进入审核,否则进入发布阶段
    if (needAudit(module, deployHistory)) {
        deployHistory.setDeployStatus(DeployStatus.WAITING_FOR_AUDIT.getValue());
    } else {
        deployHistory.setDeployStatus(DeployStatus.WAITING_FOR_DEPLOYMENT.getValue());
    }
    deployHistory.setSuccessCount(0);
    deployHistory.setDeployServers(order.getServerId().length);
    if (!deployHistory.getTagName().startsWith("/")) {
        deployHistory.setTagName("/" + deployHistory.getTagName());
    }
    // 判断是不是回滚的请求
    if (deployHistory.getRollbackToDeployId() > 0) {
        deployHistory.setIsRollback(Constants.TRUE);
    }
    deployHistoryDao.insert(deployHistory);
    saveDeployServers(deployHistory, order, servers);
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) Server(com.ibeiliao.deployment.admin.vo.server.Server) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with DeployHistoryPO

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

the class DeployHistoryServiceImpl method audit.

@Override
public void audit(long accountId, int historyId) {
    DeployHistoryPO po = readAndGetPermission(accountId, historyId);
    if (po.getDeployStatus() != DeployStatus.WAITING_FOR_AUDIT.getValue()) {
        throw new IllegalStateException("项目状态已改变,请先刷新页面");
    }
    int rows = deployHistoryDao.auditDeploy(historyId, DeployStatus.WAITING_FOR_DEPLOYMENT.getValue(), po.getDeployStatus(), accountId, new Date());
    logger.info("审核发布记录成功 | accountId: {}, historyId: {}, rows: {}", accountId, historyId, rows);
}
Also used : ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)

Example 8 with DeployHistoryPO

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

the class DeployHistoryServiceImpl method reject.

@Override
public void reject(long accountId, int historyId) {
    DeployHistoryPO po = readAndGetPermission(accountId, historyId);
    if (po.getDeployStatus() != DeployStatus.WAITING_FOR_AUDIT.getValue()) {
        throw new IllegalStateException("项目状态已改变,请先刷新页面");
    }
    int rows = deployHistoryDao.updateResultAndStatus(historyId, DeployResult.FAILURE.getValue(), 0, 0, DeployStatus.AUDIT_REJECTED.getValue(), po.getDeployStatus());
    logger.info("取消发布记录成功 | accountId: {}, historyId: {}, rows: {}", accountId, historyId, rows);
}
Also used : ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)

Example 9 with DeployHistoryPO

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

the class DeployHistoryServiceImpl method getByServerDeployHistoryId.

@Override
public DeployHistory getByServerDeployHistoryId(int serverDeployHistoryId) {
    ServerDeployHistoryPO po = serverDeployHistoryDao.get(serverDeployHistoryId);
    DeployHistory history = null;
    if (po != null) {
        DeployHistoryPO deployPo = deployHistoryDao.get(po.getHistoryId());
        history = new DeployHistory();
        VOUtil.copy(deployPo, history);
    }
    return history;
}
Also used : ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO) 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 10 with DeployHistoryPO

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

the class DeployHistoryServiceImpl method systemCancel.

@Override
public void systemCancel(int historyId) {
    DeployHistoryPO po = deployHistoryDao.get(historyId);
    Date now = new Date();
    if (po != null && po.getDeployStatus() == DeployStatus.DEPLOYING.getValue() && (now.getTime() - po.getCreateTime().getTime()) / 1000 > Constants.DEPLOY_TASK_TIMEOUT) {
        int rows = deployHistoryDao.auditDeploy(historyId, DeployStatus.CANCELLED.getValue(), po.getDeployStatus(), Constants.SYSTEM_ACCOUNT_ID, now);
        logger.info("系统取消发布记录成功 | historyId: {}, rows: {}", historyId, rows);
        // 这里要 end ...
        moduleStatusManagementService.endModuleDeploy(po.getModuleId(), po.getEnvId());
    }
}
Also used : ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)

Aggregations

DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)13 ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)10 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)2 ServerDeployHistory (com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory)2 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)2 Server (com.ibeiliao.deployment.admin.vo.server.Server)2 Test (org.junit.Test)2 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)1 Project (com.ibeiliao.deployment.admin.vo.project.Project)1 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)1 Date (java.util.Date)1 Transactional (org.springframework.transaction.annotation.Transactional)1