服务健康检查
This commit is contained in:
@@ -500,22 +500,22 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
LambdaQueryWrapper<FileStorage> fileMetaDataQuery = new LambdaQueryWrapper<>();
|
||||
fileMetaDataQuery.select(FileStorage::getFileId).eq(FileStorage::getDirId, deleteDirId);
|
||||
List<Long> deleteFileIdList = fileStorageService.listObjs(fileMetaDataQuery, id -> (Long) id);
|
||||
deleteFileIdList.add(deleteDirId);
|
||||
|
||||
if(ObjectUtils.isNotEmpty(deleteFileIdList)){
|
||||
fileMetadataInfoService.removeByIds(deleteFileIdList);
|
||||
fileMetadataExtensionService.lambdaUpdate().in(FileMetadataExtension::getTFilemetaId, deleteFileIdList).remove();
|
||||
fileUserPermissionService.lambdaUpdate().in(FileUserPermission::getTFilemetaId, deleteFileIdList).remove();
|
||||
}
|
||||
|
||||
fileMetadataInfoService.removeByIds(deleteFileIdList);
|
||||
fileMetadataExtensionService.lambdaUpdate().in(FileMetadataExtension::getTFilemetaId, deleteFileIdList).remove();
|
||||
fileStorageService.lambdaUpdate().eq(FileStorage::getDirId, deleteDirId).remove();
|
||||
|
||||
// 数据库批量删除权限信息
|
||||
fileUserPermissionService.lambdaUpdate().in(FileUserPermission::getTFilemetaId, deleteFileIdList).remove();
|
||||
|
||||
// minio文件系统批量删除文件
|
||||
minioService.deleteDirectoryRecursively(dirMinioObjectKey);
|
||||
|
||||
if (ObjectUtils.isNotEmpty(req.getDelUuid()) && ObjectUtils.isNotEmpty(req.getDelUuIdOwnType())) {
|
||||
if (ObjectUtils.isNotEmpty(deleteDirMetadataInfo.getRelatedResourceUuid()) && ObjectUtils.isNotEmpty(deleteDirMetadataInfo.getRelatedResourceUuidOwnType())) {
|
||||
DelNodeReq delNodeReq = new DelNodeReq();
|
||||
delNodeReq.setUuid(req.getDelUuid());
|
||||
delNodeReq.setUuidOwnType(req.getDelUuIdOwnType());
|
||||
delNodeReq.setUuid(deleteDirMetadataInfo.getRelatedResourceUuid());
|
||||
delNodeReq.setUuidOwnType(deleteDirMetadataInfo.getRelatedResourceUuidOwnType());
|
||||
simulationNodeFeignClient.delteNode(delNodeReq);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -1009,6 +1009,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
fileStorage.setFileSuffix(getSuffixWithoutDot(fileInfo.getOriginalName()));
|
||||
fileStorage.setFileSize(req.getFile().getSize());
|
||||
while (parentDirId != null) {
|
||||
fileStorage.setId(null);
|
||||
fileStorage.setDirId(parentDirId);
|
||||
fileStorageService.save(fileStorage);
|
||||
parentDirId = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getId, parentDirId).oneOpt()
|
||||
|
||||
@@ -33,34 +33,6 @@ spring:
|
||||
group: DEV_GROUP
|
||||
# server-addr: 127.0.0.1:8848
|
||||
enabled: true
|
||||
# username: nacos
|
||||
# password: ENC(+QKYnI6gAYu1SbLaZQTkZA==)
|
||||
data:
|
||||
redis:
|
||||
# Redis默认情况下有16个分片(库),这里配置具体使用的分片,默认是0
|
||||
database: 0
|
||||
# redis服务器地址(填写自己的服务器地址)
|
||||
host: 192.168.2.166
|
||||
# redis端口(默认6379)
|
||||
port: 6379
|
||||
#redis连接超时等待,10秒
|
||||
timeout: PT10S
|
||||
# redis访问密码(默认为空)
|
||||
password:
|
||||
lettuce:
|
||||
pool:
|
||||
# 连接池最大连接数(使用负值表示没有限制) 默认 8
|
||||
max-active: 50
|
||||
# 连接池中的最大空闲连接 默认 8
|
||||
max-idle: 20
|
||||
# 连接池中的最小空闲连接 默认 0
|
||||
min-idle: 1
|
||||
# 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1,这里配置10s
|
||||
max-wait: PT10S
|
||||
# password:
|
||||
# sentinel:
|
||||
# master: mymaster
|
||||
# nodes: 10.18.109.50:26379,10.18.109.51:26379,10.18.109.52:26379
|
||||
servlet:
|
||||
multipart:
|
||||
# 单个文件的最大值
|
||||
@@ -76,6 +48,14 @@ management:
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
group:
|
||||
readiness:
|
||||
include: discoveryComposite,ping,refreshScope
|
||||
health:
|
||||
redis:
|
||||
enabled: false
|
||||
db:
|
||||
enabled: false
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
|
||||
@@ -29,38 +29,9 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.65.161:8848/nacos
|
||||
server-addr: 192.168.65.161:8848
|
||||
group: LOCAL_GROUP
|
||||
# server-addr: 127.0.0.1:8848
|
||||
enabled: true
|
||||
# username: nacos
|
||||
# password: ENC(+QKYnI6gAYu1SbLaZQTkZA==)
|
||||
data:
|
||||
redis:
|
||||
# Redis默认情况下有16个分片(库),这里配置具体使用的分片,默认是0
|
||||
database: 0
|
||||
# redis服务器地址(填写自己的服务器地址)
|
||||
host: 192.168.2.166
|
||||
# redis端口(默认6379)
|
||||
port: 6379
|
||||
#redis连接超时等待,10秒
|
||||
timeout: PT10S
|
||||
# redis访问密码(默认为空)
|
||||
password:
|
||||
lettuce:
|
||||
pool:
|
||||
# 连接池最大连接数(使用负值表示没有限制) 默认 8
|
||||
max-active: 50
|
||||
# 连接池中的最大空闲连接 默认 8
|
||||
max-idle: 20
|
||||
# 连接池中的最小空闲连接 默认 0
|
||||
min-idle: 1
|
||||
# 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1,这里配置10s
|
||||
max-wait: PT10S
|
||||
# password:
|
||||
# sentinel:
|
||||
# master: mymaster
|
||||
# nodes: 10.18.109.50:26379,10.18.109.51:26379,10.18.109.52:26379
|
||||
servlet:
|
||||
multipart:
|
||||
# 单个文件的最大值
|
||||
@@ -124,4 +95,22 @@ minio:
|
||||
access-key: minioadmin
|
||||
secret-key: minioadmin
|
||||
secure: false
|
||||
bucket-name: spdm
|
||||
bucket-name: spdm
|
||||
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
group:
|
||||
readiness:
|
||||
include: discoveryComposite,ping,refreshScope
|
||||
health:
|
||||
redis:
|
||||
enabled: false
|
||||
db:
|
||||
enabled: false
|
||||
@@ -1,8 +1,9 @@
|
||||
/*
|
||||
package com.sdm.gateway2.health;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.cloud.client.loadbalancer.reactive.ReactorLoadBalancerExchangeFilterFunction;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import org.springframework.web.reactive.function.client.WebClientRequestException;
|
||||
@@ -13,26 +14,28 @@ import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
*/
|
||||
/**
|
||||
* /actuator/health 查看整体健康状态
|
||||
* 下游服务健康检查指示器
|
||||
* 检查关键下游服务的可达性
|
||||
*//*
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class DownstreamServicesHealthIndicator implements HealthIndicator {
|
||||
|
||||
// 服务名称列表
|
||||
private static final String[] SERVICE_NAMES = {
|
||||
"approve", "capability", "data", "pbs",
|
||||
"performance", "project", "system", "task"
|
||||
"data", "project","system","task"
|
||||
};
|
||||
|
||||
@Autowired
|
||||
private ReactorLoadBalancerExchangeFilterFunction loadBalancerExchangeFilterFunction;
|
||||
|
||||
@Override
|
||||
public Health health() {
|
||||
Map<String, Object> servicesStatus = new HashMap<>();
|
||||
boolean allServicesUp = true;
|
||||
|
||||
|
||||
// 检查各个关键服务的状态
|
||||
for (String serviceName : SERVICE_NAMES) {
|
||||
boolean serviceUp = checkServiceStatus(serviceName);
|
||||
@@ -41,7 +44,7 @@ public class DownstreamServicesHealthIndicator implements HealthIndicator {
|
||||
allServicesUp = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (allServicesUp) {
|
||||
return Health.up()
|
||||
.withDetail("downstreamServices", servicesStatus)
|
||||
@@ -54,27 +57,28 @@ public class DownstreamServicesHealthIndicator implements HealthIndicator {
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
|
||||
|
||||
/**
|
||||
* 检查特定服务的状态
|
||||
* 通过调用服务的 /actuator/health 端点来检查服务的健康状况
|
||||
*//*
|
||||
*/
|
||||
|
||||
private boolean checkServiceStatus(String serviceName) {
|
||||
try {
|
||||
WebClient webClient = WebClient.builder()
|
||||
.filter(loadBalancerExchangeFilterFunction)
|
||||
.baseUrl("http://" + serviceName)
|
||||
.build();
|
||||
|
||||
|
||||
// 设置较短的超时时间,避免健康检查阻塞太久
|
||||
String response = webClient.get()
|
||||
.uri("/actuator/health")
|
||||
.retrieve()
|
||||
.bodyToMono(String.class)
|
||||
.timeout(Duration.ofSeconds(5)) // 5秒超时
|
||||
.timeout(Duration.ofSeconds(25)) // 25秒超时
|
||||
.block();
|
||||
|
||||
|
||||
// 如果能成功获取响应,则认为服务是可达的
|
||||
return response != null && !response.isEmpty();
|
||||
} catch (WebClientResponseException e) {
|
||||
@@ -88,4 +92,4 @@ public class DownstreamServicesHealthIndicator implements HealthIndicator {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -85,18 +85,18 @@ management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info,metrics,logfile
|
||||
include: health,info
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
enabled: true
|
||||
probes:
|
||||
enabled: true
|
||||
info:
|
||||
enabled: true
|
||||
info:
|
||||
env:
|
||||
enabled: true
|
||||
group:
|
||||
readiness:
|
||||
include: discoveryComposite,ping,refreshScope
|
||||
health:
|
||||
redis:
|
||||
enabled: false
|
||||
db:
|
||||
enabled: false
|
||||
|
||||
logging:
|
||||
level:
|
||||
|
||||
@@ -85,18 +85,18 @@ management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info,metrics,logfile
|
||||
include: health,info
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
enabled: true
|
||||
probes:
|
||||
enabled: true
|
||||
info:
|
||||
enabled: true
|
||||
info:
|
||||
env:
|
||||
enabled: true
|
||||
group:
|
||||
readiness:
|
||||
include: discoveryComposite,ping,refreshScope
|
||||
health:
|
||||
redis:
|
||||
enabled: false
|
||||
db:
|
||||
enabled: false
|
||||
|
||||
logging:
|
||||
level:
|
||||
|
||||
@@ -75,6 +75,14 @@ management:
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
group:
|
||||
readiness:
|
||||
include: discoveryComposite,ping,refreshScope
|
||||
health:
|
||||
redis:
|
||||
enabled: false
|
||||
db:
|
||||
enabled: false
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
|
||||
@@ -95,4 +95,21 @@ file:
|
||||
rootPath: /data/home/sdm
|
||||
|
||||
#logging:
|
||||
# config: ./config/logback.xml
|
||||
# config: ./config/logback.xml
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
group:
|
||||
readiness:
|
||||
include: discoveryComposite,ping,refreshScope
|
||||
health:
|
||||
redis:
|
||||
enabled: false
|
||||
db:
|
||||
enabled: false
|
||||
@@ -74,6 +74,14 @@ management:
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
group:
|
||||
readiness:
|
||||
include: discoveryComposite,ping,refreshScope
|
||||
health:
|
||||
redis:
|
||||
enabled: false
|
||||
db:
|
||||
enabled: false
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
|
||||
@@ -66,6 +66,23 @@ spring:
|
||||
# 上传文件总的最大值
|
||||
max-request-size: 10240MB
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
group:
|
||||
readiness:
|
||||
include: discoveryComposite,ping,refreshScope
|
||||
health:
|
||||
redis:
|
||||
enabled: false
|
||||
db:
|
||||
enabled: false
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
@@ -134,4 +151,10 @@ cid:
|
||||
listRoles: /spdm-role/listRoles
|
||||
tenant:
|
||||
getTenantDetailById: /spdm-tenant/getTenantDetailById
|
||||
listTenant: /spdm-tenant/listTenant
|
||||
listTenant: /spdm-tenant/listTenant
|
||||
flow:
|
||||
launchApprove: /spdm-flow/startFlow
|
||||
queryFlowTemplate: /spdm-flow/listProcessByGroup
|
||||
queryApproveDetail: /spdm-flow/queryFlowNodeDetail
|
||||
stopApproveFlow: /spdm-flow/stopFlow
|
||||
group: SPDM
|
||||
@@ -77,6 +77,14 @@ management:
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
group:
|
||||
readiness:
|
||||
include: discoveryComposite,ping,refreshScope
|
||||
health:
|
||||
redis:
|
||||
enabled: false
|
||||
db:
|
||||
enabled: false
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 8080
|
||||
port: 7102
|
||||
|
||||
spring:
|
||||
application:
|
||||
@@ -31,10 +31,8 @@ spring:
|
||||
discovery:
|
||||
server-addr: 192.168.65.161:8848
|
||||
group: LOCAL_GROUP
|
||||
# server-addr: 127.0.0.1:8848
|
||||
enabled: false
|
||||
# username: nacos
|
||||
# password: ENC(+QKYnI6gAYu1SbLaZQTkZA==)
|
||||
enabled: true
|
||||
|
||||
data:
|
||||
redis:
|
||||
# Redis默认情况下有16个分片(库),这里配置具体使用的分片,默认是0
|
||||
@@ -68,6 +66,23 @@ spring:
|
||||
# 上传文件总的最大值
|
||||
max-request-size: 10240MB
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
group:
|
||||
readiness:
|
||||
include: discoveryComposite,ping,refreshScope
|
||||
health:
|
||||
redis:
|
||||
enabled: false
|
||||
db:
|
||||
enabled: false
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
Reference in New Issue
Block a user