Spring-eureka source code interpretation----as a cluster of Eureka how to achieve not to do two times spread

Source: Internet
Author: User

In peacetime work, Eureka as a cluster, we will configure multiple peers, assuming that there is currently a server eureka-a,eureka-b,eureka-c.

if the peer of Eureka a points to B and the peer of B points to C, then when the service registers with a, there is a registration information for the service in B, but not in C . That is, if you wish to register all other instances with a single Eureka, you must configure all other nodes into the properties of the current Eureka peer . This logic is implemented in the PeerAwareInstanceRegistryImpl#replicateToPeers() method:

PrivatevoidReplicatetopeers (Action action, string appName, string ID, instanceinfo info/* Optional */, Instancestatus newstatus/* optional */,boolean isreplication) {Stopwatch tracer = Action.gettimer (). Start (); try {if (isreplication) { Numberofreplicationslastmin.increment (); } //if this registration information is other Eureka synchronized, it will not continue to propagate to its peer node if ( Peereurekanodes = = Collections.empty_list | | isreplication) {return;} for (final peereurekanode node: Peereurekanodes.getpeereurekanodes ()) {//do not send yourself a sync request if ( Peereurekanodes.isthismyurl (Node.getserviceurl ())) {continue;} Replicateinstanceactionstopeers (action, appName, ID, info, newstatus, node); }} finally {tracer.stop ();}}         

Spring-eureka Source code interpretation----as a cluster of Eureka how to achieve not to do two propagation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.