|
|
|
@ -74,7 +74,6 @@ public class ThreadPoolAdapterRegister implements ApplicationRunner {
|
|
|
|
|
ScheduledExecutorService scheduler = threadPoolAdapterScheduler.getScheduler();
|
|
|
|
|
int taskIntervalSeconds = threadPoolAdapterScheduler.getTaskIntervalSeconds();
|
|
|
|
|
ThreadPoolAdapterRegisterTask threadPoolAdapterRegisterTask = new ThreadPoolAdapterRegisterTask(scheduler, taskIntervalSeconds);
|
|
|
|
|
|
|
|
|
|
scheduler.schedule(threadPoolAdapterRegisterTask, threadPoolAdapterScheduler.getTaskIntervalSeconds(), TimeUnit.SECONDS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -131,16 +130,35 @@ public class ThreadPoolAdapterRegister implements ApplicationRunner {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
try {
|
|
|
|
|
boolean registerFlag = false;
|
|
|
|
|
|
|
|
|
|
List<ThreadPoolAdapterCacheConfig> newThreadPoolAdapterCacheConfigs = getThreadPoolAdapterCacheConfigs();
|
|
|
|
|
|
|
|
|
|
boolean registerFlag = compareThreadPoolAdapterCacheConfigs(newThreadPoolAdapterCacheConfigs, cacheConfigList);
|
|
|
|
|
|
|
|
|
|
cacheConfigList = newThreadPoolAdapterCacheConfigs;
|
|
|
|
|
|
|
|
|
|
if (registerFlag) {
|
|
|
|
|
doRegister(cacheConfigList);
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error("Register Task Error",e);
|
|
|
|
|
}finally {
|
|
|
|
|
if (!scheduler.isShutdown()) {
|
|
|
|
|
scheduler.schedule(this, taskIntervalSeconds, TimeUnit.MILLISECONDS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean compareThreadPoolAdapterCacheConfigs(List<ThreadPoolAdapterCacheConfig> newThreadPoolAdapterCacheConfigs,
|
|
|
|
|
List<ThreadPoolAdapterCacheConfig> oldThreadPoolAdapterCacheConfigs){
|
|
|
|
|
boolean registerFlag = false;
|
|
|
|
|
|
|
|
|
|
Map<String, List<ThreadPoolAdapterState>> newThreadPoolAdapterCacheConfigMap =
|
|
|
|
|
newThreadPoolAdapterCacheConfigs.stream().collect(Collectors.toMap(
|
|
|
|
|
ThreadPoolAdapterCacheConfig::getMark, ThreadPoolAdapterCacheConfig::getThreadPoolAdapterStates, (k1, k2) -> k2));
|
|
|
|
|
|
|
|
|
|
Map<String, List<ThreadPoolAdapterState>> oldThreadPoolAdapterCacheConfigMap =
|
|
|
|
|
cacheConfigList.stream().collect(Collectors.toMap(
|
|
|
|
|
oldThreadPoolAdapterCacheConfigs.stream().collect(Collectors.toMap(
|
|
|
|
|
ThreadPoolAdapterCacheConfig::getMark, ThreadPoolAdapterCacheConfig::getThreadPoolAdapterStates, (k1, k2) -> k2));
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, List<ThreadPoolAdapterState>> entry : newThreadPoolAdapterCacheConfigMap.entrySet()) {
|
|
|
|
@ -157,19 +175,6 @@ public class ThreadPoolAdapterRegister implements ApplicationRunner {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cacheConfigList = newThreadPoolAdapterCacheConfigs;
|
|
|
|
|
|
|
|
|
|
if (registerFlag) {
|
|
|
|
|
doRegister(cacheConfigList);
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error("Register Task Error",e);
|
|
|
|
|
}finally {
|
|
|
|
|
if (!scheduler.isShutdown()) {
|
|
|
|
|
scheduler.schedule(this, taskIntervalSeconds, TimeUnit.MILLISECONDS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return registerFlag;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|