We’ve seen Dubbo’s earlierserviceIntroduction andService exportSource code, let me take a look at the DubboCluster fault toleranceSource code of
1、 Relationship between related components
Description of cluster fault tolerance in Dubbo

You can see that dojoin is a template method
It’s actually very simple here, just creating a clusterinvoker
2、Invoker
Here we can see that invoke mainly obtains the invokerlist and load balancer from the directory, and delegates the call to the subclass
Now let’s take another look org.apache.dubbo . rpc.cluster.support The concrete implementation of. Failoverclusterinvoker ා doinvoke
From the picture above, we can see that there are several main things to do here
1. Gets the number of retries by method name
2. Traverse the number of retries and do load balancing
3. Initiate the call
Here is another template method. Let’s take a look at its default implementation class org.apache.dubbo . rpc.cluster.loadbalance Doselect of. Randomloadbalance
The implementation idea is whether the weights of all invockers are the same. If they are the same, one invocker will be selected randomly
Otherwise, add up the total weight of all the invockers, and then generate a random number in [0, total] to find the first one that matches the random number
4. Execution logic of invoker
org.apache.dubbo.rpc.protocol.AbstractInvoker#invoke
It is mainly used here org.apache.dubbo . remoting.exchange.ExchangeClient Send request
It will eventually be handed over to you org.apache.dubbo . remoting.exchange.support . header.HeaderExchangeChannel#request implement

Abstract directory is a basic implementation class in directory. It mainly encapsulates some common methods and mainly relies on the real implementation of subclasses.
So when did directory come into being? Can we recall that we also saw the registry directory when the service was referenced? Now let’s look at the code method
Are you familiar with it
Well, by now, the source code of our cluster fault tolerance mechanism is basically finished