From 0a6d3c673ec69fa60305331a10d2844739034a78 Mon Sep 17 00:00:00 2001 From: xuezechao1 <15510726991@163.com> Date: Mon, 10 Apr 2023 16:25:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E8=BF=87=E6=9C=9F=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=8D=95=E4=BD=8D=E7=94=B1=E7=A7=92=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=A4=A9=EF=BC=8C=E9=BB=98=E8=AE=A4=E4=BF=9D=E5=AD=98?= =?UTF-8?q?7=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sermant/backend/dao/memory/MemoryClientImpl.java | 12 ++++++------ .../sermant/backend/dao/redis/RedisClientImpl.java | 2 +- .../src/main/resources/application.properties | 8 +++++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/sermant-backend/src/main/java/com/huaweicloud/sermant/backend/dao/memory/MemoryClientImpl.java b/sermant-backend/src/main/java/com/huaweicloud/sermant/backend/dao/memory/MemoryClientImpl.java index a8c6fd5cac..d078e52318 100644 --- a/sermant-backend/src/main/java/com/huaweicloud/sermant/backend/dao/memory/MemoryClientImpl.java +++ b/sermant-backend/src/main/java/com/huaweicloud/sermant/backend/dao/memory/MemoryClientImpl.java @@ -61,25 +61,25 @@ public class MemoryClientImpl implements EventDao { */ public MemoryClientImpl(BackendConfig backendConfig) { this.eventMap = ExpiringMap.builder().expiration( - backendConfig.getEventExpire(), TimeUnit.SECONDS) + backendConfig.getEventExpire(), TimeUnit.DAYS) .expirationPolicy(ExpirationPolicy.CREATED).build(); this.agentInstanceMap = ExpiringMap.builder() - .expiration(backendConfig.getEventExpire(), TimeUnit.SECONDS) + .expiration(backendConfig.getEventExpire(), TimeUnit.DAYS) .expirationPolicy(ExpirationPolicy.CREATED).build(); this.eventTimeKeyMap = ExpiringMap.builder() - .expiration(backendConfig.getEventExpire(), TimeUnit.SECONDS) + .expiration(backendConfig.getEventExpire(), TimeUnit.DAYS) .expirationPolicy(ExpirationPolicy.CREATED).build(); this.sessionMap = ExpiringMap.builder() .expiration(backendConfig.getSessionTimeout(), TimeUnit.SECONDS) .expirationPolicy(ExpirationPolicy.CREATED).build(); this.emergency = ExpiringMap.builder() - .expiration(backendConfig.getEventExpire(), TimeUnit.SECONDS) + .expiration(backendConfig.getEventExpire(), TimeUnit.DAYS) .expirationPolicy(ExpirationPolicy.CREATED).build(); this.important = ExpiringMap.builder() - .expiration(backendConfig.getEventExpire(), TimeUnit.SECONDS) + .expiration(backendConfig.getEventExpire(), TimeUnit.DAYS) .expirationPolicy(ExpirationPolicy.CREATED).build(); this.normal = ExpiringMap.builder() - .expiration(backendConfig.getEventExpire(), TimeUnit.SECONDS) + .expiration(backendConfig.getEventExpire(), TimeUnit.DAYS) .expirationPolicy(ExpirationPolicy.CREATED).build(); } diff --git a/sermant-backend/src/main/java/com/huaweicloud/sermant/backend/dao/redis/RedisClientImpl.java b/sermant-backend/src/main/java/com/huaweicloud/sermant/backend/dao/redis/RedisClientImpl.java index 5f5bc1c4ae..9771c1e0bf 100644 --- a/sermant-backend/src/main/java/com/huaweicloud/sermant/backend/dao/redis/RedisClientImpl.java +++ b/sermant-backend/src/main/java/com/huaweicloud/sermant/backend/dao/redis/RedisClientImpl.java @@ -237,7 +237,7 @@ public QueryCacheSizeEntity getQueryCacheSize(EventsRequestEntity eventsRequestE public void cleanOverDueEventTimerTask() { if (backendConfig.getDatabase().equals(DatabaseType.REDIS)) { Calendar calendar = Calendar.getInstance(); - calendar.add(Calendar.SECOND, -backendConfig.getEventExpire()); + calendar.add(Calendar.DATE, -backendConfig.getEventExpire()); List needCleanEvent = queryByTimeRange( CommonConst.REDIS_EVENT_FIELD_SET_KEY, 0, calendar.getTimeInMillis()); List eventKeys = needCleanEvent.stream().map(Tuple::getElement).collect(Collectors.toList()); diff --git a/sermant-backend/src/main/resources/application.properties b/sermant-backend/src/main/resources/application.properties index 8bb3afb74e..11fac7e624 100644 --- a/sermant-backend/src/main/resources/application.properties +++ b/sermant-backend/src/main/resources/application.properties @@ -25,10 +25,12 @@ database.password= database.filter.thread.num=10000 # webhook level[EMERGENCY,IMPORTANT,NORMAL] -webhook.eventpush.level=NORMAL +webhook.eventpush.level=EMERGENCY -# Event Expiration Time (s) -database.event.expire=1800 +# Event Expiration Time (day) +database.event.expire=7 + +# event field Expiration Time (s) database.field.expire=5 database.fixedDelay=10000