Search in sources :

Example 1 with EmptyServiceAutoCleaner

use of com.alibaba.nacos.naming.core.v2.cleaner.EmptyServiceAutoCleaner in project nacos by alibaba.

the class ServiceManager method init.

/**
 * Init service maneger.
 */
@PostConstruct
public void init() {
    GlobalExecutor.scheduleServiceReporter(new ServiceReporter(), 60000, TimeUnit.MILLISECONDS);
    GlobalExecutor.submitServiceUpdateManager(new UpdatedServiceProcessor());
    if (emptyServiceAutoClean) {
        Loggers.SRV_LOG.info("open empty service auto clean job, initialDelay : {} ms, period : {} ms", cleanEmptyServiceDelay, cleanEmptyServicePeriod);
        // delay 60s, period 20s;
        // This task is not recommended to be performed frequently in order to avoid
        // the possibility that the service cache information may just be deleted
        // and then created due to the heartbeat mechanism
        GlobalExecutor.scheduleServiceAutoClean(new EmptyServiceAutoCleaner(this, distroMapper), cleanEmptyServiceDelay, cleanEmptyServicePeriod);
    }
    try {
        Loggers.SRV_LOG.info("listen for service meta change");
        consistencyService.listen(KeyBuilder.SERVICE_META_KEY_PREFIX, this);
    } catch (NacosException e) {
        Loggers.SRV_LOG.error("listen for service meta change failed!");
    }
}
Also used : EmptyServiceAutoCleaner(com.alibaba.nacos.naming.core.v2.cleaner.EmptyServiceAutoCleaner) NacosException(com.alibaba.nacos.api.exception.NacosException) PostConstruct(javax.annotation.PostConstruct)

Aggregations

NacosException (com.alibaba.nacos.api.exception.NacosException)1 EmptyServiceAutoCleaner (com.alibaba.nacos.naming.core.v2.cleaner.EmptyServiceAutoCleaner)1 PostConstruct (javax.annotation.PostConstruct)1