mirror of https://gitee.com/stylefeng/roses
【8.3.0】【resource】完善资源汇报devops的配置
parent
5bee81ad23
commit
521e182672
|
@ -44,6 +44,7 @@ import org.springframework.core.Ordered;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听项目初始化完毕,汇报资源到服务(可为远程服务,可为本服务)
|
* 监听项目初始化完毕,汇报资源到服务(可为远程服务,可为本服务)
|
||||||
|
@ -79,9 +80,7 @@ public class ResourceReportListener extends ApplicationReadyListener implements
|
||||||
// 持久化资源,发送资源到资源服务或本项目
|
// 持久化资源,发送资源到资源服务或本项目
|
||||||
ResourceReportApi resourceService = applicationContext.getBean(ResourceReportApi.class);
|
ResourceReportApi resourceService = applicationContext.getBean(ResourceReportApi.class);
|
||||||
List<SysResourcePersistencePojo> persistencePojos = resourceService.reportResourcesAndGetResult(new ReportResourceParam(scannerProperties.getAppCode(), modularResources));
|
List<SysResourcePersistencePojo> persistencePojos = resourceService.reportResourcesAndGetResult(new ReportResourceParam(scannerProperties.getAppCode(), modularResources));
|
||||||
|
log.info("存储本地接口资源完成,耗时:{}ms", (System.currentTimeMillis() - beginSaveLocal));
|
||||||
long saveLocalFinish = System.currentTimeMillis();
|
|
||||||
log.info("存储本地接口资源完成,耗时:{}ms", (saveLocalFinish - beginSaveLocal));
|
|
||||||
|
|
||||||
// 向DevOps一体化平台汇报资源,只有两种情况会汇报资源:1.本地配置了远程服务器地址;2.本地化集成了devops模块
|
// 向DevOps一体化平台汇报资源,只有两种情况会汇报资源:1.本地配置了远程服务器地址;2.本地化集成了devops模块
|
||||||
DevOpsReportProperties devOpsReportProperties = applicationContext.getBean(DevOpsReportProperties.class);
|
DevOpsReportProperties devOpsReportProperties = applicationContext.getBean(DevOpsReportProperties.class);
|
||||||
|
@ -94,12 +93,16 @@ public class ResourceReportListener extends ApplicationReadyListener implements
|
||||||
// 判断是否配置了host或者本地有集成化的devops平台
|
// 判断是否配置了host或者本地有集成化的devops平台
|
||||||
if (ObjectUtil.isNotEmpty(devOpsReportProperties.getServerHost()) || devOpsDetectApi != null) {
|
if (ObjectUtil.isNotEmpty(devOpsReportProperties.getServerHost()) || devOpsDetectApi != null) {
|
||||||
DevOpsReportApi devOpsReportApi = applicationContext.getBean(DevOpsReportApi.class);
|
DevOpsReportApi devOpsReportApi = applicationContext.getBean(DevOpsReportApi.class);
|
||||||
try {
|
|
||||||
|
// 异步化汇报给devops
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
long beginDevopsReport = System.currentTimeMillis();
|
||||||
devOpsReportApi.reportResources(devOpsReportProperties, persistencePojos);
|
devOpsReportApi.reportResources(devOpsReportProperties, persistencePojos);
|
||||||
log.info("向DevOps平台汇报资源信息完成,耗时:{}ms", (System.currentTimeMillis() - saveLocalFinish));
|
log.info("向DevOps平台汇报资源信息完成,耗时:{}ms", (System.currentTimeMillis() - beginDevopsReport));
|
||||||
} catch (Exception e) {
|
}).exceptionally(ex -> {
|
||||||
log.error("向DevOps平台汇报异常出现网络错误,如无法联通DevOps平台可关闭相关配置。", e);
|
log.error("向DevOps平台汇报异常出现网络错误,如无法联通DevOps平台可关闭相关配置。", ex);
|
||||||
}
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置标识已经扫描过
|
// 设置标识已经扫描过
|
||||||
|
|
Loading…
Reference in New Issue