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()));
}
}
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()));
}
}
}
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;
}
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);
}
Aggregations