feat(naming): Support empty service cleanup task time configurable
This commit is contained in:
parent
4f264fed2d
commit
0886653a08
@ -37,5 +37,7 @@ nacos.core.auth.enabled=false
|
|||||||
nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
|
nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
|
||||||
|
|
||||||
nacos.naming.empty.service.auto-clean=true
|
nacos.naming.empty.service.auto-clean=true
|
||||||
|
nacos.naming.empty-service.clean.initial-delay-ms=50000
|
||||||
|
nacos.naming.empty-service.clean.period-time-ms=30000
|
||||||
|
|
||||||
tldSkipPatterns=derbyLocale_*.jar,jaxb-api.jar,jsr173_1.0_api.jar,jaxb1-impl.jar,activation.jar
|
tldSkipPatterns=derbyLocale_*.jar,jaxb-api.jar,jsr173_1.0_api.jar,jaxb1-impl.jar,activation.jar
|
||||||
|
@ -44,6 +44,10 @@ server.port=8848
|
|||||||
|
|
||||||
### If enable the empty service auto clean, services with an empty instance are automatically cleared
|
### If enable the empty service auto clean, services with an empty instance are automatically cleared
|
||||||
nacos.naming.empty.service.auto-clean=false
|
nacos.naming.empty.service.auto-clean=false
|
||||||
|
### The empty service cleanup task delays startup time in milliseconds
|
||||||
|
nacos.naming.empty-service.clean.initial-delay-ms=60000
|
||||||
|
### The empty service cleanup task cycle execution time in milliseconds
|
||||||
|
nacos.naming.empty-service.clean.period-time-ms=20000
|
||||||
|
|
||||||
|
|
||||||
#*************** CMDB Module Related Configurations ***************#
|
#*************** CMDB Module Related Configurations ***************#
|
||||||
|
@ -110,6 +110,12 @@ public class ServiceManager implements RecordListener<Service> {
|
|||||||
|
|
||||||
private final Object putServiceLock = new Object();
|
private final Object putServiceLock = new Object();
|
||||||
|
|
||||||
|
@Value("${nacos.naming.empty-service.clean.initial-delay-ms:60000}")
|
||||||
|
private int cleanEmptyServiceDelay;
|
||||||
|
|
||||||
|
@Value("${nacos.naming.empty-service.clean.period-time-ms:20000}")
|
||||||
|
private int cleanEmptyServicePeriod;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|
||||||
@ -119,15 +125,15 @@ public class ServiceManager implements RecordListener<Service> {
|
|||||||
|
|
||||||
if (emptyServiceAutoClean) {
|
if (emptyServiceAutoClean) {
|
||||||
|
|
||||||
|
Loggers.SRV_LOG.info("open empty service auto clean job, initialDelay : {} ms, period : {} ms", cleanEmptyServiceDelay, cleanEmptyServicePeriod);
|
||||||
|
|
||||||
// delay 60s, period 20s;
|
// delay 60s, period 20s;
|
||||||
|
|
||||||
// This task is not recommended to be performed frequently in order to avoid
|
// This task is not recommended to be performed frequently in order to avoid
|
||||||
// the possibility that the service cache information may just be deleted
|
// the possibility that the service cache information may just be deleted
|
||||||
// and then created due to the heartbeat mechanism
|
// and then created due to the heartbeat mechanism
|
||||||
|
|
||||||
GlobalExecutor.scheduleServiceAutoClean(new EmptyServiceAutoClean(), 60_000L, 20_000L);
|
GlobalExecutor.scheduleServiceAutoClean(new EmptyServiceAutoClean(), cleanEmptyServiceDelay, cleanEmptyServicePeriod);
|
||||||
|
|
||||||
Loggers.SRV_LOG.info("open empty service auto clean job");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user