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