apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.34k stars 26.4k forks source link

com.alibaba cluster、Directory兼容失败 #6026

Open iwhalecloud-platform opened 4 years ago

iwhalecloud-platform commented 4 years ago

Environment

Steps to reproduce this issue

1、Cluster

@Deprecated
public interface Cluster extends org.apache.dubbo.rpc.cluster.Cluster {

    <T> com.alibaba.dubbo.rpc.Invoker<T> join(com.alibaba.dubbo.rpc.cluster.Directory<T> directory) throws
            com.alibaba.dubbo.rpc.RpcException;

    @Override
    default <T> Invoker<T> join(Directory<T> directory) throws RpcException {
        return null;
    }
}

join为什么返回NULL

2、Directory

public interface Directory<T> extends org.apache.dubbo.rpc.cluster.Directory<T> {

    @Override
    URL getUrl();

    List<com.alibaba.dubbo.rpc.Invoker<T>> list(com.alibaba.dubbo.rpc.Invocation invocation) throws com.alibaba.dubbo.rpc.RpcException;

    @Override
    default List<Invoker<T>> list(Invocation invocation) throws RpcException {
        List<com.alibaba.dubbo.rpc.Invoker<T>> res = this.list(new com.alibaba.dubbo.rpc.Invocation.CompatibleInvocation(invocation));
        return res.stream().map(i -> i.getOriginal()).collect(Collectors.toList());
    }
}

缺少兼容Directory,例如CompatibleDirectory

我们有老项目实现了Cluster,如果改新的包,很多项目都要动,量很大,所以需要兼容老的。

CodeIngL commented 4 years ago

你得自己改,当前的兼容性是不足的,在生产上,我们是这样的改的 image

iwhalecloud-platform commented 4 years ago

我暂时修复了

chickenlj commented 4 years ago

@CodeIngL Would you please submit a pull request for this issue, possibly with the solution you suggested?

CodeIngL commented 4 years ago

这些是历包袱,dubbo是否考虑一下去掉这些包袱了。https://github.com/open-wrapper/dubbo-wrapper 提供了如何在公司内部定制dubbo的模板,社区不可能满足每一个公司的需求,剥离出来提供一个模板例如dubbo-wrapper会更好