当前位置:   article > 正文

Curator 异常处理一: KeeperErrorCode = Unimplemented ``for` `/curator_keepererrorcode =unimplemeted

keepererrorcode =unimplemeted

1 异常结果

`org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented ``for` `/curator` `  ``at org.apache.zookeeper.KeeperException.create(KeeperException.java:``103``)``  ``at org.apache.zookeeper.KeeperException.create(KeeperException.java:``51``)``  ``at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:``1525``)``  ``at org.apache.curator.framework.imps.CreateBuilderImpl$``17``.call(CreateBuilderImpl.java:``1189``)``  ``at org.apache.curator.framework.imps.CreateBuilderImpl$``17``.call(CreateBuilderImpl.java:``1166``)``  ``at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:``64``)``  ``at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:``100``)``  ``at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:``1163``)``  ``at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:``603``)``  ``at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:``593``)``  ``at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:``47``)``  ``at cn.practice.zk.ZookeeperClientPractice.test(ZookeeperClientPractice.java:``41``)``  ``at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)``  ``at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:``62``)``  ``at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:``43``)``  ``at java.lang.reflect.Method.invoke(Method.java:``497``)``  ``at org.junit.runners.model.FrameworkMethod$``1``.runReflectiveCall(FrameworkMethod.java:``50``)``  ``at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:``12``)``  ``at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:``47``)``  ``at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:``17``)``  ``at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:``325``)``  ``at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:``78``)``  ``at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:``57``)``  ``at org.junit.runners.ParentRunner$``3``.run(ParentRunner.java:``290``)``  ``at org.junit.runners.ParentRunner$``1``.schedule(ParentRunner.java:``71``)``  ``at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:``288``)``  ``at org.junit.runners.ParentRunner.access$``000``(ParentRunner.java:``58``)``  ``at org.junit.runners.ParentRunner$``2``.evaluate(ParentRunner.java:``268``)``  ``at org.junit.runners.ParentRunner.run(ParentRunner.java:``363``)``  ``at org.junit.runner.JUnitCore.run(JUnitCore.java:``137``)``  ``at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:``68``)``  ``at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:``47``)``  ``at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:``242``)``  ``at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:``70``)`
  • 1

2 原因是Zookeeper的版本与curator的版本不匹配造成的

自己查阅了一下资料发现匹配规则如下

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.curator</groupId>
    <artifactId>curator-recipes</artifactId>
    <version>${curator-version}</version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
        </exclusion>
    </exclusions>
</dependency>
复制代码
同时必须加入Zookeeper3.4.X的依赖,并且呢,因为是软兼容模式,一些3.4.X不具备的新特性是不能使用的。
 
低版本
对于Curator2.X是支持Zookeeper3.4.X的,所以如果目前你是Zookeeper3.4.X的版本,还是使用Curator2.X的吧,
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

3 解决方案,因为我的部署Zookeeper版本为3.4.5所以应该选择2.x的curator版本

<dependency>
           <groupId>org.apache.curator</groupId>
           <artifactId>curator-client</artifactId>
           <version>2.12.0</version>
 
       </dependency>
       <dependency>
           <groupId>org.apache.curator</groupId>
           <artifactId>curator-framework</artifactId>
           <version>2.12.0</version>
       </dependency>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

重新maven导入一下jar包解决问题,之前已经创建成功过了,所以抛出节点已经存在的错误

img

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/772494
推荐阅读
  

闽ICP备14008679号