|
|
@@ -12,8 +12,6 @@ import cn.reghao.autodop.dmaster.app.service.BuildDeployConfigService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -37,36 +35,6 @@ public class BuildDeployConfigServiceImpl implements BuildDeployConfigService {
|
|
|
this.runningRepository = runningRepository;
|
|
|
}
|
|
|
|
|
|
- // TODO 启用 env 和 appType 字段,根据环境和应用类型来刷新,避免一次刷新过多应用
|
|
|
- @Override
|
|
|
- public void refresh() {
|
|
|
- List<AppConfig> apps = appConfigQuery.findAll();
|
|
|
- Set<String> appIds = apps.stream().map(AppConfig::getAppId).collect(Collectors.toSet());
|
|
|
-
|
|
|
- refreshAppBuilding(apps, appIds);
|
|
|
- refreshAppDeployingAndRunning(apps, appIds);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void refreshApp(AppConfig app) {
|
|
|
- refreshAppBuilding(app);
|
|
|
- refreshAppDeploying(app);
|
|
|
- refreshAppRunning(app);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void refreshAppBuilding(List<AppConfig> apps, Set<String> appIds) {
|
|
|
- Set<String> appsToDelete = buildingRepository.findAll().stream()
|
|
|
- .map(appBuilding -> {
|
|
|
- String appId = appBuilding.getAppId();
|
|
|
- return appIds.contains(appId) ? null : appId;
|
|
|
- })
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .collect(Collectors.toSet());
|
|
|
-
|
|
|
- apps.forEach(this::refreshAppBuilding);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 刷新应用构建信息
|
|
|
*
|
|
|
@@ -74,6 +42,7 @@ public class BuildDeployConfigServiceImpl implements BuildDeployConfigService {
|
|
|
* @return
|
|
|
* @date 2021-06-18 下午5:24
|
|
|
*/
|
|
|
+ @Override
|
|
|
public void refreshAppBuilding(AppConfig app) {
|
|
|
AppBuilding appBuilding = buildingRepository.findByAppId(app.getAppId());
|
|
|
if (appBuilding == null) {
|
|
|
@@ -84,35 +53,6 @@ public class BuildDeployConfigServiceImpl implements BuildDeployConfigService {
|
|
|
buildingRepository.save(appBuilding);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void refreshAppDeployingAndRunning(List<AppConfig> apps, Set<String> appIds) {
|
|
|
- Set<String> appsToDelete = deployingRepository.findAll().stream()
|
|
|
- .map(appDeploying -> {
|
|
|
- String appId = appDeploying.getAppId();
|
|
|
- return appIds.contains(appId) ? null : appId;
|
|
|
- })
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .collect(Collectors.toSet());
|
|
|
-
|
|
|
- runningRepository.findAll().stream()
|
|
|
- .map(appRunning -> {
|
|
|
- String appId = appRunning.getAppId();
|
|
|
- return appIds.contains(appId) ? null : appId;
|
|
|
- })
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .collect(Collectors.toSet());
|
|
|
-
|
|
|
- // 配置了 DeployConfig 的应用
|
|
|
- List<AppConfig> appsWithDeployConfig = apps.stream()
|
|
|
- .filter(app -> !app.getDeployConfigs().isEmpty())
|
|
|
- // TODO 使用 peek
|
|
|
- //.peek()
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- appsWithDeployConfig.forEach(this::refreshAppDeploying);
|
|
|
- appsWithDeployConfig.forEach(this::refreshAppRunning);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 刷新应用部署信息
|
|
|
*
|
|
|
@@ -120,6 +60,7 @@ public class BuildDeployConfigServiceImpl implements BuildDeployConfigService {
|
|
|
* @return
|
|
|
* @date 2021-06-18 下午5:25
|
|
|
*/
|
|
|
+ @Override
|
|
|
public void refreshAppDeploying(AppConfig app) {
|
|
|
String appId = app.getAppId();
|
|
|
List<AppDeploying> list = app.getDeployConfigs().stream()
|
|
|
@@ -144,6 +85,7 @@ public class BuildDeployConfigServiceImpl implements BuildDeployConfigService {
|
|
|
* @return
|
|
|
* @date 2021-06-18 下午5:29
|
|
|
*/
|
|
|
+ @Override
|
|
|
public void refreshAppRunning(AppConfig app) {
|
|
|
String appId = app.getAppId();
|
|
|
List<AppRunning> list = app.getDeployConfigs().stream()
|