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