use of com.ibeiliao.deployment.admin.vo.server.ServerGroup in project Corgi by kevinYin.
the class ModuleServiceTest method testCheckResinPort.
@Test
public void testCheckResinPort() {
ProjectModule module = moduleService.getByModuleId(6);
List<ServerGroup> serverGroups = serverGroupService.getByModuleIds(Lists.newArrayList(6), true);
module.setServerGroups(serverGroups);
module.setModuleId(0);
module.getResinConf().setHttpPort(8087);
module.getResinConf().setServerPort(6807);
module.getResinConf().setWatchdogPort(6608);
Map<String, String> resinPort2OccupyInfoMap = moduleService.checkResinPortOccupy(module);
assert !resinPort2OccupyInfoMap.isEmpty();
}
use of com.ibeiliao.deployment.admin.vo.server.ServerGroup in project Corgi by kevinYin.
the class ServerServiceImpl method getByModuleId.
@Override
public List<Server> getByModuleId(int moduleId) {
Assert.isTrue(moduleId > 0, "moduleId数值非法");
List<ServerGroup> serverGroups = serverGroupService.getByModuleIds(Lists.newArrayList(moduleId), false);
if (CollectionUtils.isEmpty(serverGroups)) {
return Collections.emptyList();
}
List<Integer> groupIds = Lists.newArrayList();
for (ServerGroup group : serverGroups) {
groupIds.add(group.getGroupId());
}
List<ServerPO> serverPOs = serverDao.getByGroupIds(groupIds);
if (CollectionUtils.isEmpty(serverPOs)) {
return Collections.emptyList();
}
return VOUtil.fromList(serverPOs, Server.class);
}
use of com.ibeiliao.deployment.admin.vo.server.ServerGroup 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.ServerGroup 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);
}
}
use of com.ibeiliao.deployment.admin.vo.server.ServerGroup in project Corgi by kevinYin.
the class ProjectModuleServiceImpl method saveServerGroupAndServer.
private void saveServerGroupAndServer(List<ServerGroup> groups, int moduleId) {
if (CollectionUtils.isEmpty(groups)) {
return;
}
List<ServerGroup> needUpdateGroups = Lists.newArrayList();
List<Server> needUpdateServers = Lists.newArrayList();
List<Integer> oldServerGroupIds = Lists.newArrayList();
List<Integer> oldServerIds = Lists.newArrayList();
for (ServerGroup group : groups) {
group.setModuleId(moduleId);
if (group.getGroupId() <= 0) {
continue;
}
needUpdateGroups.add(group);
oldServerGroupIds.add(group.getGroupId());
if (CollectionUtils.isNotEmpty(group.getServers())) {
for (Server server : group.getServers()) {
if (server.getServerId() > 0) {
oldServerIds.add(server.getServerId());
needUpdateServers.add(server);
}
server.setIp(StringUtils.trimToEmpty(server.getIp()));
}
}
}
// 删除被删除的服务器组
serverGroupService.deleteByOldGroupIds(oldServerGroupIds, moduleId);
// 先删除提交后不存在的服务器
serverService.deleteByServerGroupIdsAndServerIds(oldServerGroupIds, oldServerIds);
// 更新服务器组和服务器
for (ServerGroup group : needUpdateGroups) {
serverGroupService.updateGroup(group);
}
for (Server server : needUpdateServers) {
serverService.updateServer(server);
}
// 插入新增的服务器组合服务器
insertServerGroupAndServer(groups, moduleId);
}
Aggregations