apache/dubbo

使用多注册中心集群会进入ZoneAwareClusterInvoker.doInvoke方法中对所有注册中心进行负载均衡,会将所有Invoke强转为MockClusterInvoker<T>类型

Open

#7.313 aberto em 3 de mar. de 2021

Ver no GitHub
 (1 comment) (0 reactions) (0 assignees)Java (26.453 forks)batch import
help wanted

Métricas do repositório

Stars
 (41.524 stars)
Métricas de merge de PR
 (Mesclagem média 7d 14h) (20 fundiu PRs em 30d)

Description

Environment

  • Dubbo version: 2.7.6
  • Operating System version: window10
  • Java version: 1.8

Steps to reproduce this issue

使用多注册中心集群会进入ZoneAwareClusterInvoker.doInvoke方法中对所有注册中心进行负载均衡,会将所有Invoke强转为MockClusterInvoker类型,dubbo的具体解释(FIXME, the invoker is a cluster invoker representing one Registry, so it will automatically wrapped by MockClusterInvoker.) 由于自己对Cluster进行了扩展,我提供的ClusterInvoker和dubbo自身的MockClusterInvoker同为Invoker的子类,所以会有类型转换异常。 image 不使用扩展的cluster时的invoker都是MockClusterInvoker类型: image 使用扩展的cluster时的invoker都是ClusterInvoker类型: image 强转时发生解析异常: java.lang.ClassCastException: com.common.util.rpc.dubbo.invoker.ClusterInvoker cannot be cast to org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker

首先,为什么在ZoneAwareClusterInvoker类中会耦合MockClusterInvoker,其次这边把所有Invoke强转为MockClusterInvoker类型,是不是会对Cluster的扩展产生影响? image image

Guia do colaborador