|
|
@@ -5,7 +5,6 @@ import cn.reghao.devops.common.msg.constant.NodeStatus;
|
|
|
import cn.reghao.devops.web.mgr.app.db.repository.AppDeployingRepository;
|
|
|
import cn.reghao.devops.web.mgr.app.db.repository.config.AppDeployConfigRepository;
|
|
|
import cn.reghao.devops.web.mgr.app.db.repository.log.DeployLogRepository;
|
|
|
-import cn.reghao.devops.web.mgr.app.model.po.AppBuilding;
|
|
|
import cn.reghao.devops.web.mgr.app.model.po.AppDeploying;
|
|
|
import cn.reghao.devops.web.mgr.app.model.po.AppDeployingNode;
|
|
|
import cn.reghao.devops.web.mgr.app.model.po.config.AppConfig;
|
|
|
@@ -13,14 +12,13 @@ import cn.reghao.devops.web.mgr.app.model.po.config.AppDeployConfig;
|
|
|
import cn.reghao.devops.web.mgr.app.db.query.AppDeployQuery;
|
|
|
import cn.reghao.devops.web.mgr.app.model.po.log.BuildLog;
|
|
|
import cn.reghao.devops.web.mgr.app.model.po.log.DeployLog;
|
|
|
-import cn.reghao.devops.web.mgr.app.model.vo.AppDeployConfigVo;
|
|
|
-import cn.reghao.devops.web.mgr.app.model.vo.AppDeployingVO;
|
|
|
+import cn.reghao.devops.web.mgr.app.model.vo.AppDeployingNodeVO;
|
|
|
+import cn.reghao.devops.web.mgr.app.model.vo.AppRunningNode;
|
|
|
import cn.reghao.devops.web.mgr.app.model.vo.AppRunning;
|
|
|
-import cn.reghao.devops.web.mgr.app.model.vo.AppRunningVO;
|
|
|
import cn.reghao.devops.web.mgr.machine.db.query.MachineQuery;
|
|
|
import cn.reghao.devops.web.mgr.machine.model.po.MachineHost;
|
|
|
-import cn.reghao.jutil.jdk.db.PageList;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
@@ -55,28 +53,56 @@ public class AppDeployQueryImpl implements AppDeployQuery {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<AppDeployConfig> findByAppId(String appId, Pageable pageable) {
|
|
|
+ public List<AppDeployConfig> getByAppId(String appId) {
|
|
|
+ PageRequest pageRequest = PageRequest.of(0, 10);
|
|
|
Specification<AppDeployConfig> specification = (root, query, cb) -> {
|
|
|
Join<AppDeployConfig, AppConfig> innerJoin = root.join("appConfig", JoinType.INNER);
|
|
|
Predicate predicate = cb.equal(innerJoin.get("appId"), appId);
|
|
|
return cb.and(predicate);
|
|
|
};
|
|
|
|
|
|
- return deployConfigRepository.findAll(specification, pageable);
|
|
|
+ return deployConfigRepository.findAll(specification, pageRequest).getContent();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int countByApp(AppConfig appConfig) {
|
|
|
- return deployConfigRepository.countByAppConfig(appConfig);
|
|
|
+ public List<AppDeployingNodeVO> get(String appId) {
|
|
|
+ AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
|
|
|
+ if (appDeploying == null) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ BuildLog buildLog = appDeploying.getBuildLog();
|
|
|
+ return appDeploying.getDeployingNodes().stream().map(appDeployingNode -> {
|
|
|
+ MachineHost machineHost = appDeployingNode.getDeployConfig().getMachineHost();
|
|
|
+ String machineStatus = machineQuery.isAgentOnline(machineHost.getMachineId())
|
|
|
+ ? NodeStatus.Online.name() : NodeStatus.Offline.name();
|
|
|
+ return new AppDeployingNodeVO(appDeployingNode, buildLog, machineStatus);
|
|
|
+ }).sorted(Comparator.comparing(AppDeployingNodeVO::getDeployTime).reversed()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<AppInfo> getAppsByMachineId(String machineId) {
|
|
|
+ return deployingRepository.findAll().stream()
|
|
|
+ .filter(appDeploying -> {
|
|
|
+ MachineHost machineHost = appDeploying.getDeployingNodes().get(0).getDeployConfig().getMachineHost();
|
|
|
+ return machineHost.getMachineId().equals(machineId);
|
|
|
+ })
|
|
|
+ .map(appDeploying -> {
|
|
|
+ AppDeployConfig deployConfig = appDeploying.getDeployingNodes().get(0).getDeployConfig();
|
|
|
+ String packType = deployConfig.getAppConfig().getPackerConfig().getType();
|
|
|
+ String appId = deployConfig.getAppConfig().getAppId();
|
|
|
+ return new AppInfo(packType, appId);
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int countByMachine(MachineHost machineHost) {
|
|
|
- return deployConfigRepository.countByMachineHost(machineHost);
|
|
|
+ public int countByApp(AppConfig appConfig) {
|
|
|
+ return deployConfigRepository.countByAppConfig(appConfig);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public AppDeployConfig findByAppIdAndMachineId(String appId, String machineId) {
|
|
|
+ public AppDeployConfig getByAppIdAndMachineId(String appId, String machineId) {
|
|
|
Specification<AppDeployConfig> specification = (root, query, cb) -> {
|
|
|
Join<AppDeployConfig, AppConfig> innerJoin = root.join("appConfig", JoinType.INNER);
|
|
|
Predicate predicate = cb.equal(innerJoin.get("appId"), appId);
|
|
|
@@ -99,38 +125,6 @@ public class AppDeployQueryImpl implements AppDeployQuery {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<AppInfo> getAppsByMachineId(String machineId) {
|
|
|
- return deployingRepository.findAll().stream()
|
|
|
- .filter(appDeploying -> {
|
|
|
- MachineHost machineHost = appDeploying.getDeployingNodes().get(0).getDeployConfig().getMachineHost();
|
|
|
- return machineHost.getMachineId().equals(machineId);
|
|
|
- })
|
|
|
- .map(appDeploying -> {
|
|
|
- AppDeployConfig deployConfig = appDeploying.getDeployingNodes().get(0).getDeployConfig();
|
|
|
- String packType = deployConfig.getAppConfig().getPackerConfig().getType();
|
|
|
- String appId = deployConfig.getAppConfig().getAppId();
|
|
|
- return new AppInfo(packType, appId);
|
|
|
- })
|
|
|
- .collect(Collectors.toList());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<AppDeployingVO> get(String appId, AppBuilding appBuilding) {
|
|
|
- AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
|
|
|
- if (appDeploying == null) {
|
|
|
- return Collections.emptyList();
|
|
|
- }
|
|
|
-
|
|
|
- BuildLog buildLog = appDeploying.getBuildLog();
|
|
|
- return appDeploying.getDeployingNodes().stream().map(appDeployingNode -> {
|
|
|
- MachineHost machineHost = appDeployingNode.getDeployConfig().getMachineHost();
|
|
|
- String machineStatus = machineQuery.isAgentOnline(machineHost.getMachineId())
|
|
|
- ? NodeStatus.Online.name() : NodeStatus.Offline.name();
|
|
|
- return new AppDeployingVO(appDeployingNode, buildLog, machineStatus);
|
|
|
- }).sorted(Comparator.comparing(AppDeployingVO::getDeployTime).reversed()).collect(Collectors.toList());
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public boolean isDeploying(String appId, String machineId) {
|
|
|
AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
|
|
|
@@ -147,15 +141,9 @@ public class AppDeployQueryImpl implements AppDeployQuery {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<AppDeployConfigVo> indexPage(String appId, PageRequest pageRequest) {
|
|
|
- return findByAppId(appId, pageRequest).map(AppDeployConfigVo::new);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public PageList<AppRunningVO> getAppRunningByPage(String env, String appType, int pageNumber, int pageSize) {
|
|
|
- PageRequest pageRequest = PageRequest.of(pageNumber-1, pageSize);
|
|
|
- Page<AppDeploying> page = deployingRepository.findAllByAppConfig_EnvAndAppConfig_AppType(env, appType, pageRequest);
|
|
|
- List<AppRunningVO> list = page.getContent().stream().map(appDeploying -> {
|
|
|
+ public Page<AppRunning> getAppRunningByPage(String env, String appType, Pageable pageable) {
|
|
|
+ Page<AppDeploying> page = deployingRepository.findAllByAppConfig_EnvAndAppConfig_AppType(env, appType, pageable);
|
|
|
+ List<AppRunning> list = page.getContent().stream().map(appDeploying -> {
|
|
|
List<AppDeployingNode> deployingNodes = appDeploying.getDeployingNodes();
|
|
|
if (deployingNodes.isEmpty()) {
|
|
|
return null;
|
|
|
@@ -173,13 +161,14 @@ public class AppDeployQueryImpl implements AppDeployQuery {
|
|
|
}
|
|
|
|
|
|
int totalDeployed = deployingNodes.size();
|
|
|
- return new AppRunningVO(appId, appName, bindPorts, packagePath, totalDeployed);
|
|
|
+ return new AppRunning(appId, appName, bindPorts, packagePath, totalDeployed);
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
- return PageList.pageList(pageNumber, pageSize, (int) page.getTotalElements(), list);
|
|
|
+
|
|
|
+ return new PageImpl<>(list, pageable, page.getTotalElements());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<AppRunning> getAppRunning(String appId) {
|
|
|
+ public List<AppRunningNode> getAppRunning(String appId) {
|
|
|
AppDeploying appDeploying = deployingRepository.findByAppConfig_AppId(appId);
|
|
|
if (appDeploying == null) {
|
|
|
return Collections.emptyList();
|
|
|
@@ -187,7 +176,7 @@ public class AppDeployQueryImpl implements AppDeployQuery {
|
|
|
|
|
|
BuildLog buildLog = appDeploying.getBuildLog();
|
|
|
return appDeploying.getDeployingNodes().stream()
|
|
|
- .map(appDeployingNode -> new AppRunning(appDeployingNode, buildLog))
|
|
|
+ .map(appDeployingNode -> new AppRunningNode(appDeployingNode, buildLog))
|
|
|
/*.filter(AppDeploying::isDeployed)
|
|
|
.sorted(Comparator.comparing(AppDeploying::getDeployTime).reversed())*/
|
|
|
.collect(Collectors.toList());
|