fix: 修复nacos配置变更无法识别问题
This commit is contained in:
parent
705d403186
commit
3bc1e4ca43
@ -6,6 +6,8 @@ import lombok.Getter;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
|
import org.springframework.cloud.context.scope.refresh.RefreshScopeRefreshedEvent;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
@ -67,25 +69,19 @@ public class DynamicConfig {
|
|||||||
@Value("${thread.pool.monitor.interval.seconds:60}")
|
@Value("${thread.pool.monitor.interval.seconds:60}")
|
||||||
private long threadPoolMonitorIntervalSeconds;
|
private long threadPoolMonitorIntervalSeconds;
|
||||||
|
|
||||||
|
@Value("${thread.pool.monitor.enabled:true}")
|
||||||
private boolean enableThreadPoolMonitor;
|
private boolean enableThreadPoolMonitor;
|
||||||
|
|
||||||
/**
|
// 监听配置刷新事件,主动刷新线程池监控
|
||||||
* 来自 nacos 的开关控制是否启用线程池监控
|
@EventListener
|
||||||
*/
|
public void onRefresh(RefreshScopeRefreshedEvent event) {
|
||||||
@Value("${thread.pool.monitor.enabled:true}")
|
log.info("[config-refresh-event] 捕获配置刷新事件,重新判断是否需要刷新线程池监控,当前开关值为:{}", enableThreadPoolMonitor);
|
||||||
public void setEnableThreadPoolMonitor(boolean enabled) {
|
if (enableThreadPoolMonitor) {
|
||||||
boolean changed = this.enableThreadPoolMonitor != enabled;
|
|
||||||
this.enableThreadPoolMonitor = enabled;
|
|
||||||
if (changed) {
|
|
||||||
if (enabled) {
|
|
||||||
log.info("[config-refresh] enableThreadPoolMonitor=true,刷新线程池监控");
|
|
||||||
ThreadPoolMonitorStarter.getInstance().refreshAll();
|
ThreadPoolMonitorStarter.getInstance().refreshAll();
|
||||||
} else {
|
} else {
|
||||||
log.info("[config-refresh] enableThreadPoolMonitor=false,清除线程池监控");
|
|
||||||
ThreadPoolMonitorStarter.getInstance().clearAll();
|
ThreadPoolMonitorStarter.getInstance().clearAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getLlmActiveSlugs() {
|
public Set<String> getLlmActiveSlugs() {
|
||||||
return Arrays.stream(llmSharedActiveSlugIds.split("[,;\\n]"))
|
return Arrays.stream(llmSharedActiveSlugIds.split("[,;\\n]"))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user