From 0709cb3894504020ae16ee7a2c4fefbd01782563 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Fri, 17 Dec 2021 23:52:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=9C=9F=E5=88=A0=E9=99=A4=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E6=B1=A0=E5=8E=86=E5=8F=B2=E8=BF=90=E8=A1=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=BB=BB=E5=8A=A1=E6=B7=BB=E5=8A=A0=E5=BC=80=E5=85=B3?= =?UTF-8?q?.=20(#33)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/monitor/TimeCleanHistoryDataTask.java | 12 +++++++++--- hippo4j-server/conf/application.properties | 1 + .../src/main/resources/application.properties | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/TimeCleanHistoryDataTask.java b/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/TimeCleanHistoryDataTask.java index 5a8f9092..988c0b5c 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/TimeCleanHistoryDataTask.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/TimeCleanHistoryDataTask.java @@ -32,11 +32,13 @@ public class TimeCleanHistoryDataTask implements Runnable, InitializingBean { @Value("${clean.history.data.period:30}") private Long cleanHistoryDataPeriod; + @Value("${clean.history.data.period.enable:true}") + private Boolean cleanHistoryDataPeriodEnable; + @NonNull private final HisRunDataService hisRunDataService; - private final ScheduledExecutorService cleanHistoryDataExecutor = ExecutorFactory.Managed - .newSingleScheduledExecutorService(DEFAULT_GROUP, r -> new Thread(r, "clean-history-data")); + private ScheduledExecutorService cleanHistoryDataExecutor; @Override public void run() { @@ -51,7 +53,11 @@ public class TimeCleanHistoryDataTask implements Runnable, InitializingBean { @Override public void afterPropertiesSet() throws Exception { - cleanHistoryDataExecutor.scheduleWithFixedDelay(this, 0, 1, TimeUnit.MINUTES); + if (cleanHistoryDataPeriodEnable) { + cleanHistoryDataExecutor = ExecutorFactory.Managed + .newSingleScheduledExecutorService(DEFAULT_GROUP, r -> new Thread(r, "clean-history-data")); + cleanHistoryDataExecutor.scheduleWithFixedDelay(this, 0, 1, TimeUnit.MINUTES); + } } } diff --git a/hippo4j-server/conf/application.properties b/hippo4j-server/conf/application.properties index 11ec45cb..6f5c9ccf 100644 --- a/hippo4j-server/conf/application.properties +++ b/hippo4j-server/conf/application.properties @@ -18,6 +18,7 @@ tenant=hippo4j ### Regularly clean up the historical running data of thread pool. unit: minute. clean.history.data.period=30 +clean.history.data.period.enable=true #*************** Config Module Related Configurations ***************# diff --git a/hippo4j-server/src/main/resources/application.properties b/hippo4j-server/src/main/resources/application.properties index 11ec45cb..6f5c9ccf 100644 --- a/hippo4j-server/src/main/resources/application.properties +++ b/hippo4j-server/src/main/resources/application.properties @@ -18,6 +18,7 @@ tenant=hippo4j ### Regularly clean up the historical running data of thread pool. unit: minute. clean.history.data.period=30 +clean.history.data.period.enable=true #*************** Config Module Related Configurations ***************#