From 30862f9d966e7ba38180c5b31d21f9a6c56442bd Mon Sep 17 00:00:00 2001
From: opensnail <598092184@qq.com>
Date: Sun, 14 Jul 2024 10:38:39 +0800
Subject: [PATCH] =?UTF-8?q?feat(sj=5F1.1.0-beta3):=20=E4=BC=98=E5=8C=96?=
=?UTF-8?q?=E5=90=AF=E5=8A=A8CacheRegisterTable#CACHE=E6=8A=A5=E9=94=99?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../server/common/cache/CacheRegisterTable.java | 17 ++++++++++-------
.../server/starter/listener/EndListener.java | 6 +++---
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/snail-job-server/snail-job-server-common/src/main/java/com/aizuda/snailjob/server/common/cache/CacheRegisterTable.java b/snail-job-server/snail-job-server-common/src/main/java/com/aizuda/snailjob/server/common/cache/CacheRegisterTable.java
index ec518a8b..740d23ac 100644
--- a/snail-job-server/snail-job-server-common/src/main/java/com/aizuda/snailjob/server/common/cache/CacheRegisterTable.java
+++ b/snail-job-server/snail-job-server-common/src/main/java/com/aizuda/snailjob/server/common/cache/CacheRegisterTable.java
@@ -39,7 +39,16 @@ import java.util.concurrent.TimeUnit;
@Slf4j
public class CacheRegisterTable implements Lifecycle {
- private static Cache, ConcurrentMap> CACHE;
+ private static final Cache, ConcurrentMap> CACHE;
+
+ static {
+ CACHE = CacheBuilder.newBuilder()
+ // 设置并发级别为cpu核心数
+ .concurrencyLevel(Runtime.getRuntime().availableProcessors())
+ // 设置写缓存后60秒过期
+ .expireAfterWrite(60, TimeUnit.SECONDS)
+ .build();
+ }
/**
* 获取所有缓存
@@ -225,12 +234,6 @@ public class CacheRegisterTable implements Lifecycle {
@Override
public void start() {
SnailJobLog.LOCAL.info("CacheRegisterTable start");
- CACHE = CacheBuilder.newBuilder()
- // 设置并发级别为cpu核心数
- .concurrencyLevel(Runtime.getRuntime().availableProcessors())
- // 设置写缓存后60秒过期
- .expireAfterWrite(60, TimeUnit.SECONDS)
- .build();
}
diff --git a/snail-job-server/snail-job-server-starter/src/main/java/com/aizuda/snailjob/server/starter/listener/EndListener.java b/snail-job-server/snail-job-server-starter/src/main/java/com/aizuda/snailjob/server/starter/listener/EndListener.java
index 62deb5b4..a6348237 100644
--- a/snail-job-server/snail-job-server-starter/src/main/java/com/aizuda/snailjob/server/starter/listener/EndListener.java
+++ b/snail-job-server/snail-job-server-starter/src/main/java/com/aizuda/snailjob/server/starter/listener/EndListener.java
@@ -1,8 +1,8 @@
package com.aizuda.snailjob.server.starter.listener;
+import com.aizuda.snailjob.common.core.util.SnailJobVersion;
import com.aizuda.snailjob.common.log.SnailJobLog;
import com.aizuda.snailjob.server.common.Lifecycle;
-import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
@@ -17,7 +17,6 @@ import java.util.List;
* @date : 2021-11-19 19:00
*/
@Component
-@Slf4j
public class EndListener implements ApplicationListener {
@Autowired
@@ -25,7 +24,8 @@ public class EndListener implements ApplicationListener {
@Override
public void onApplicationEvent(ContextClosedEvent event) {
- SnailJobLog.LOCAL.info("snail-job-SERVER 停止");
+ SnailJobLog.LOCAL.info("snail-job client about to shutdown v{}", SnailJobVersion.getVersion());
lifecycleList.forEach(Lifecycle::close);
+ SnailJobLog.LOCAL.info("snail-job client closed successfully v{}", SnailJobVersion.getVersion());
}
}