Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the function of ServiceReporter in nacos

Shulou Source: shulou.com Published: 2022-06-02 11:07:54 10月03日 Update

In this issue, the editor will bring you about the role of ServiceReporter in nacos. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

ServiceManager.init

Nacos-1.1.3/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java

@ Component@DependsOn ("nacosApplicationContext") public class ServiceManager implements RecordListener {/ * * Map * / private Map serviceMap = new ConcurrentHashMap (); private LinkedBlockingDeque toBeUpdatedServicesQueue = new LinkedBlockingDeque (1024 * 1024); private Synchronizer synchronizer = new ServiceStatusSynchronizer (); private final Lock lock = new ReentrantLock (); @ Resource (name = "consistencyDelegate") private ConsistencyService consistencyService; @ Autowired private SwitchDomain switchDomain; @ Autowired private DistroMapper distroMapper; @ Autowired private ServerListManager serverListManager; @ Autowired private PushService pushService Private final Object putServiceLock = new Object (); @ PostConstruct public void init () {UtilsAndCommons.SERVICE_SYNCHRONIZATION_EXECUTOR.schedule (new ServiceReporter (), 60000, TimeUnit.MILLISECONDS); UtilsAndCommons.SERVICE_UPDATE_EXECUTOR.submit (new UpdatedServiceProcessor ()); 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!");}} /.}

The init method of ServiceManager registers ServiceReporter with UtilsAndCommons.SERVICE_SYNCHRONIZATION_EXECUTOR

ServiceReporter

Nacos-1.1.3/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java

Private class ServiceReporter implements Runnable {@ Override public void run () {try {Map allServiceNames = getAllServiceNames (); if (allServiceNames.size ()

Tags: Methods interfaces functions content messages analysis specialties small and medium rich content summary that is articles more goals knowledge articles industries perspectives information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi OPPO Reno Docker Shulou Information MariaDB