Zookeeper与Curator二三事【坑爹】

起因:我的Dubbo服务起不来:我本地Zookeeper3.4.11,Curator4.1

Caused by: org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /dubbo/com.demo.common.service.DemoService
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:106) ~[zookeeper-3.5.4-beta.jar:3.5.4-beta-7f51e5b68cf2f80176ff944a9ebd2abbc65e7327]
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:54) ~[zookeeper-3.5.4-beta.jar:3.5.4-beta-7f51e5b68cf2f80176ff944a9ebd2abbc65e7327]
    at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1549) ~[zookeeper-3.5.4-beta.jar:3.5.4-beta-7f51e5b68cf2f80176ff944a9ebd2abbc65e7327]
    at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1183) ~[curator-framework-4.1.0.jar:4.1.0]
    at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1160) ~[curator-framework-4.1.0.jar:4.1.0]
    at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64) ~[curator-client-4.1.0.jar:na]
    at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100) ~[curator-client-4.1.0.jar:na]
    at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1157) ~[curator-framework-4.1.0.jar:4.1.0]
    at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:607) ~[curator-framework-4.1.0.jar:4.1.0]
    at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:597) ~[curator-framework-4.1.0.jar:4.1.0]
    at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:575) ~[curator-framework-4.1.0.jar:4.1.0]
    at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:49) ~[curator-framework-4.1.0.jar:4.1.0]
    at com.alibaba.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.createPersistent(CuratorZookeeperClient.java:76) ~[dubbo-2.6.5.jar:2.6.5]
    ... 33 common frames omitted

于是去了解这个版本对应关系如下:

Curator作为zookeeper的客户端,并不是最新版的就没问题,因为它的版本和zookeeper的版本有对应关系。

ZooKeeper 3.5.x

Curator4.0十分依赖Zookeeper3.5.X

ZooKeeper 3.4.x

Curator4.0在软兼容模式下支持Zookeeper3.4.X,但是需要依赖排除zookeeper

<dependency>
    <groupId>org.apache.curatorgroupId>
    <artifactId>curator-recipesartifactId>
    <version>${curator-version}version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.zookeepergroupId>
            <artifactId>zookeeperartifactId>
        exclusion>
    exclusions>
dependency>

同时必须加入Zookeeper3.4.X的依赖,并且呢,因为是软兼容模式,一些3.4.X不具备的新特性是不能使用的。

低版本

对于Curator2.X是支持Zookeeper3.4.X的,所以如果目前你是Zookeeper3.4.X的版本,还是使用Curator2.X的吧,比如:


<dependency>
    <groupId>org.apache.zookeepergroupId>
    <artifactId>zookeeperartifactId>
    <version>3.4.13version>
    <type>pomtype>
dependency>

 

版本列表

Zookeeper与Curator二三事【坑爹】_第1张图片

同一个项目有三个版本也是醉了,貌似现在2.X和4.X是主打了,3.X被边缘了?

 

转载于:https://www.cnblogs.com/LUA123/p/10288797.html

你可能感兴趣的:(Zookeeper与Curator二三事【坑爹】)