七Dubbo各模块的层次核心接口及组件类--4Cluster层--Cluster-Directory-Router
七Dubbo各模块的层次核心接口及组件类--4Cluster层--Cluster-Directory-Router
7.4 Cluster(Cluster模块)
路由层:封装多个提供者的路由及负载均衡,并桥接注册中心,以invoker为中心。
| 模块 | Dubbo层 | 各层核心接口 |
|---|---|---|
| Service | ServiceBean ReferanceBean | |
| dubbo-config | Config | ServiceConfig ReferanceConfig |
| dubbo-RPC | Proxy | ServiceProxy ProxyFactory |
| dubbo-registry | Registry | RegistryFactory Registry RegistryService |
| dubbo-cluster | Cluster | Cluster Directory Router LoadBalance |
| dubbo-monitor | Monitor | |
| dubbo-RPC | Protocol | Filter Invoker Prococol Exporter |
| dubbo-remoting | Exchange | Exchanger ExchangeChannel ExchangeClient ExchangeServer |
| : | Transport | Transport Channel Client Server Codec |
| dubbo-common | Serialize |
集群层,是对于多个provider时,consumer端调用场景的抽象,是dubbo集群容错的抽象层。
7.4.1 Cluster


7.4.2 Directory

Directory 代表多个 Invoker,可以把它看成 List<Invoker> ,但与 List 不同的是,它的值可能是动态变化的,比如注册中心推送变更。
notifyListener是监听机制。
public interface Directory<T> extends Node {
/**
* get service type.
*/
Class<T> getInterface();
/**
* list invokers.
*/
List<Invoker<T>> list(Invocation invocation) throws RpcException;
}
7.4.3 Router

public interface Router extends Comparable<Router> {
//get the router url.
URL getUrl();
/**
* route.
*
* @param invokers
* @param url refer url
* @param invocation
* @return routed invokers
* @throws RpcException
*/
<T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException;
}

浙公网安备 33010602011771号