use of com.ibeiliao.deployment.admin.vo.server.ServerGroup in project Corgi by kevinYin.
the class ProjectModuleServiceImpl method checkResinPortOccupy.
@Override
public Map<String, String> checkResinPortOccupy(ProjectModule projectModule) {
if (projectModule.getModuleType() == ModuleType.SERVICE.getValue() || projectModule.getResinConf() == null) {
return Collections.emptyMap();
}
List<ServerGroup> serverGroups = projectModule.getServerGroups();
if (CollectionUtils.isEmpty(serverGroups)) {
return Collections.emptyMap();
}
List<Server> allServers = Lists.newArrayList();
for (ServerGroup group : serverGroups) {
if (CollectionUtils.isNotEmpty(group.getServers())) {
allServers.addAll(group.getServers());
}
}
if (CollectionUtils.isEmpty(allServers)) {
return Collections.emptyMap();
}
return buildOccupyInfoMap(projectModule, allServers);
}
use of com.ibeiliao.deployment.admin.vo.server.ServerGroup in project Corgi by kevinYin.
the class InitTestDataService method createModule.
private ProjectModule createModule(long accountId, Project project, List<ProjectEnv> envs) {
ProjectModule module = new ProjectModule();
module.setProjectId(project.getProjectId());
module.setCompileShell("mvn -P=dev");
module.setNeedAudit(Constants.TRUE);
module.setModuleName("test-module");
module.setModuleNameZh("测试模块");
module.setModuleType(ModuleType.SERVICE.getValue());
module.setLogName("");
module.setPreShell("");
module.setPostShell("");
module.setRestartShell("/usr/local/resinpro/bin/resin.sh restart");
module.setRepoUrl("https://a.b.com/test-project");
module.setRepoType(ModuleRepoType.SVN.getValue());
module.setSrcPath("");
module.setStopShell("");
module.setSvnAccount("test-account");
module.setSvnPassword("test-password");
module.setNeedAudit(Constants.TRUE);
ProjectEnv env = envs.get(0);
List<ServerGroup> serverGroups = new ArrayList<>();
ServerGroup group1 = new ServerGroup();
group1.setEnvId(env.getEnvId());
group1.setGroupName("dev test");
serverGroups.add(group1);
projectModuleService.saveProjectModule(accountId, module);
List<Server> servers = new ArrayList<>();
final int MAX_SERVERS = 8;
for (int i = 0; i < MAX_SERVERS; i++) {
servers.add(createServer(i));
}
group1.setServers(servers);
module.setServerGroups(serverGroups);
projectModuleService.saveProjectModule(accountId, module);
ProjectModule tmpModule = projectModuleService.getByModuleId(module.getModuleId());
Assert.notNull(tmpModule);
Assert.isTrue(tmpModule.getNeedAudit() == Constants.TRUE);
// 要重新读一次数据
List<ServerGroup> newServerGroups = serverGroupService.getByModuleIds(Lists.newArrayList(module.getModuleId()), false);
module.setServerGroups(newServerGroups);
for (ServerGroup tmpGroup : newServerGroups) {
List<Integer> groupIds = new LinkedList<>();
groupIds.add(tmpGroup.getGroupId());
List<Server> newServers = serverService.getByGroupIds(groupIds);
tmpGroup.setServers(newServers);
}
return module;
}
use of com.ibeiliao.deployment.admin.vo.server.ServerGroup in project Corgi by kevinYin.
the class ModuleServiceTest method fillServerGroupInfo.
private void fillServerGroupInfo(ProjectModule module) {
ServerGroup group = new ServerGroup();
group.setGroupId(129);
group.setModuleId(43);
group.setCreateTime(new Date());
group.setEnvId(1);
group.setGroupName("online01111");
Server server1 = new Server();
server1.setServerId(22);
server1.setGroupId(129);
server1.setCreateTime(new Date());
server1.setServerName("server00008888");
server1.setIp("192.168.0.1");
Server server2 = new Server();
server2.setGroupId(129);
server2.setCreateTime(new Date());
server2.setServerName("server000099");
server2.setIp("192.168.0.4");
group.setServers(Lists.newArrayList(server1, server2));
module.setServerGroups(Lists.newArrayList(group));
}
use of com.ibeiliao.deployment.admin.vo.server.ServerGroup in project Corgi by kevinYin.
the class ServerGroupServiceImpl method fillInServer.
private void fillInServer(List<ServerGroup> groups) {
List<Integer> groupIds = Lists.newArrayList();
for (ServerGroup group : groups) {
groupIds.add(group.getGroupId());
}
List<Server> servers = serverService.getByGroupIds(groupIds);
if (CollectionUtils.isEmpty(servers)) {
return;
}
ArrayListMultimap<Integer, Server> groupId2ServersMap = ArrayListMultimap.create();
for (Server server : servers) {
groupId2ServersMap.put(server.getGroupId(), server);
}
for (ServerGroup group : groups) {
if (groupId2ServersMap.get(group.getGroupId()) != null) {
group.setServers(groupId2ServersMap.get(group.getGroupId()));
}
}
}
Aggregations