use of com.ibeiliao.deployment.admin.vo.server.Server in project Corgi by kevinYin.
the class DeployHistoryServiceImplTest method getServerIds.
private int[] getServerIds(InitTestDataService.InitData data) {
List<Server> servers = data.module.getServerGroups().get(0).getServers();
int[] serverIds = new int[servers.size()];
int count = 0;
for (Server server : servers) {
serverIds[count++] = server.getServerId();
}
return serverIds;
}
use of com.ibeiliao.deployment.admin.vo.server.Server in project Corgi by kevinYin.
the class InitTestDataService method createServer.
private Server createServer(int i) {
i = i + 1;
Server server = new Server();
server.setIp("12.34.56." + (10 + i));
server.setServerName("test-server-" + i);
return server;
}
use of com.ibeiliao.deployment.admin.vo.server.Server 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);
}
use of com.ibeiliao.deployment.admin.vo.server.Server in project Corgi by kevinYin.
the class CreateDeploymentController method queryModuleServer.
/**
* 查询模块在某个环境的服务器列表
*
* @param moduleId 模块ID
* @param envId 环境ID,必定大于0
* @return
*/
@RequestMapping("queryModuleServer")
@ResponseBody
@MenuResource("查询模块服务器列表")
public RestResult<Map<String, Object>> queryModuleServer(int moduleId, int envId) {
Assert.isTrue(moduleId > 0);
Assert.isTrue(envId > 0);
List<ServerGroup> groups = serverGroupService.getByModuleAndEnv(moduleId, envId);
List<Integer> groupIds = new ArrayList<>(groups.size());
for (ServerGroup group : groups) {
groupIds.add(group.getGroupId());
}
List<Server> servers = serverService.getByGroupIds(groupIds);
Map<String, Object> result = new HashMap<>(4);
result.put("servers", servers);
result.put("groups", groups);
return new RestResult<>(result);
}
use of com.ibeiliao.deployment.admin.vo.server.Server in project Corgi by kevinYin.
the class ProjectModuleServiceImpl method insertServerGroupAndServer.
private void insertServerGroupAndServer(List<ServerGroup> groups, int moduleId) {
if (CollectionUtils.isEmpty(groups)) {
return;
}
List<ServerGroup> needInsertGroups = Lists.newArrayList();
List<ServerGroup> oldGroups = Lists.newArrayList();
for (ServerGroup group : groups) {
group.setModuleId(moduleId);
if (group.getGroupId() == 0) {
needInsertGroups.add(group);
} else {
oldGroups.add(group);
}
}
List<ServerGroup> serverGroups = serverGroupService.batchInsertGroups(needInsertGroups);
List<Server> servers = Lists.newArrayList();
// 新增的group的server
for (ServerGroup group : serverGroups) {
List<Server> serverList = group.getServers();
if (CollectionUtils.isNotEmpty(serverList)) {
for (Server server : serverList) {
server.setGroupId(group.getGroupId());
servers.add(server);
}
}
}
// 旧的group新增的server
for (ServerGroup oldGroup : oldGroups) {
if (CollectionUtils.isNotEmpty(oldGroup.getServers())) {
for (Server server : oldGroup.getServers()) {
server.setGroupId(oldGroup.getGroupId());
if (server.getServerId() == 0) {
servers.add(server);
}
}
}
}
if (CollectionUtils.isNotEmpty(servers)) {
serverService.batchInsertServer(servers);
}
}
Aggregations