当前位置:网站首页>Instanceinforeplicator class of Eureka (service registration auxiliary class)
Instanceinforeplicator class of Eureka (service registration auxiliary class)
2022-06-22 13:45:00 【51CTO】
Welcome to visit mine GitHub
Here we classify and summarize all the original works of Xinchen ( Including supporting source code ): https://github.com/zq2599/blog_demos
About service registration
- The following pictures are from Netflix official , The picture shows Eureka Client Will initiate... To the registry Get Registry Request to get the list of services :

- With Spring Cloud Of Edgware.RELEASE Version as an example ,Eureka client The registration action of is on the com.netflix.discovery.DiscoveryClient Class initScheduledTasks Method , The relevant code snippet is shown below , Please pay attention to the Chinese Notes :
- The above code indicates that , Report your information to Eureka server Your job is to call instanceInfoReplicator Of api Accomplished ;
InstanceInfoReplicator The role of
- First look at InstanceInfoReplicator Comments on source code :
- I understand it :
- InstanceInfoReplicator It is a task class , Be responsible for periodically reporting their own information to Eureka server;
- There are two scenarios that trigger escalation : Periodic tasks 、 Service status changes (onDemandUpdate Called ), therefore , There may be two tasks reported at the same time ;
- A single thread executes the reported operation , If there are multiple reporting tasks , It can also ensure that it is serial ;
- There's a frequency limit , adopt burstSize Parameters to control ;
- Tasks created first are always executed first , however onDemandUpdate The task created in the method discards the periodic task ;
Source code analysis
- The previous understanding of annotation is the main line , Go to the source code :
- First look at the construction method , as follows , Note the position of Chinese notes :
- As can be seen from the above code , The line path pool and frequency limiting tool are prepared in the construction method , Calculate the number of tasks allowed per minute ;
- stay com.netflix.discovery.DiscoveryClient Class initScheduledTasks In the method , By calling instanceInfoReplicator.start Method starts the periodic task , Now let's look at this method :
- When the delay time arrives , Will execute run Method :
- Sum up the above codes , The logic of periodic tasks is completed , Next, let's look at the externally invoked onDemandUpdate Method :
As shown in the above code , It can be seen that the functions mentioned in the previous notes have been implemented ;
thus ,InstanceInfoReplicator Analysis completed , It can be seen that this is a powerful auxiliary class , Check in on the application information Eureka server Has played an important role , The business logic can safely submit the submission request , Concurrent 、 Frequency overruns and other conditions are InstanceInfoReplicator It's handled ;
Welcome to your attention 51CTO Blog : Xinchen, programmer
On the way to study , You are not alone , Xinchen's original works are accompanied all the way …
边栏推荐
- 简简单单的科研秘籍
- Leetcode daily question 202110
- Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
- leetcode 829. Sum of continuous integers
- Leetcode union search set
- Acwing game 55
- leetcode 99. Restore binary search tree
- Growth knowledge network
- leetcode 85. Max rectangle
- LDA study notes
猜你喜欢

Leetcode interval DP

openGauss内核分析之查询重写

Acwing week 53
Redis+Caffeine两级缓存的实现

"N'osez pas douter du Code, vous devez douter du Code" notez une analyse de délai de demande réseau

leetcode每日一题202110

Redis active / standby configuration dockercompose version

PHP deserialization & Magic method

史蒂芬·柯维写给年轻人的高效工作秘笈

Leetcode union search set
随机推荐
谈谈人生风控
Processing statement on price selection of several manufacturers
Common writing methods and excellent examples of acknowledgments in graduation thesis writing
JSP based library management system, including source code, database script, video tutorial for project operation, and video tutorial for thesis writing
Istio服务网格中的流量复制
Temporary recommendation on graphs via long- and short term preference fusion
高薪程序员&面试题精讲系列114之Redis缓存你熟悉吗?Redis的key如何设计?内存淘汰机制你熟悉吗?
SSM based library management system, high-quality graduation thesis example (can be used directly), project import video, attached source code and database script, Thesis Writing Tutorial
基于SSM的小区垃圾分类和运输管理系统,高质量毕业论文范例(可直接使用),源码,数据库脚本,项目导入运行视频教程,论文撰写教程
坚持了 10 年的 9 个编程好习惯
性能相关指标
leetcode 32. Longest valid bracket
448. Find All Numbers Disappeared in an Array
693. Binary Number with Alternating Bits
浅析Redis 切片集群的数据倾斜问题
leetcode-背包问题
SQL and Oracle statements for eliminating duplicate records
Leetcode math problems
Leetcode knapsack problem
简简单单的科研秘籍