feat(sj_1.1.0-beta3): 优化启动CacheRegisterTable#CACHE报错问题
This commit is contained in:
parent
dec32efc2a
commit
30862f9d96
@ -39,7 +39,16 @@ import java.util.concurrent.TimeUnit;
|
||||
@Slf4j
|
||||
public class CacheRegisterTable implements Lifecycle {
|
||||
|
||||
private static Cache<Pair<String/*groupName*/, String/*namespaceId*/>, ConcurrentMap<String, RegisterNodeInfo>> CACHE;
|
||||
private static final Cache<Pair<String/*groupName*/, String/*namespaceId*/>, ConcurrentMap<String, RegisterNodeInfo>> 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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<ContextClosedEvent> {
|
||||
|
||||
@Autowired
|
||||
@ -25,7 +24,8 @@ public class EndListener implements ApplicationListener<ContextClosedEvent> {
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user