Apache Curator ZooKeeper - KeeperErrorCode =未实现,错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Apache Curator ZooKeeper - KeeperErrorCode =未实现,错误相关的知识,希望对你有一定的参考价值。

我使用以下Apache Curator Maven依赖:

    <dependency>
        <groupId>org.apache.curator</groupId>
        <artifactId>curator-x-async</artifactId>
        <version>4.0.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

在本地,我已经启动了zookeeper-3.4.13服务器

我尝试使用以下代码创建EPHEMERAL ZNode:

    int sleepMsBetweenRetries = 100;
    int maxRetries = 3;
    RetryPolicy retryPolicy = new RetryNTimes(maxRetries, sleepMsBetweenRetries);

    CuratorFramework client = CuratorFrameworkFactory.newClient("127.0.0.1:2181", retryPolicy);

    client.start();

    String taskPathZombie = "/tasks/b5957aa6-e250-41e0-a39b-521da61ca937";

    client.create().withMode(CreateMode.EPHEMERAL).forPath(taskPathZombie);

但它失败并出现以下异常:

Caused by: org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /tasks/b5957aa6-e250-41e0-a39b-521da61ca937
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:103) ~[zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:51) ~[zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
    at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1525) ~[zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
    at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1181) ~[curator-framework-4.0.1.jar:4.0.1]
    at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1158) ~[curator-framework-4.0.1.jar:4.0.1]
    at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64) ~[curator-client-4.0.1.jar:na]
    at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100) ~[curator-client-4.0.1.jar:na]
    at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1155) ~[curator-framework-4.0.1.jar:4.0.1]
    at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:605) ~[curator-framework-4.0.1.jar:4.0.1]
    at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:595) ~[curator-framework-4.0.1.jar:4.0.1]
    at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:573) ~[curator-framework-4.0.1.jar:4.0.1]
    at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:49) ~[curator-framework-4.0.1.jar:4.0.1]

我做错了什么以及如何解决?

答案

如果Zookeeper Server版本是3.4.x,那么以下工作正常。

<dependencies>
    <dependency>
        <groupId>org.apache.zookeeper</groupId>
        <artifactId>zookeeper</artifactId>
        <version>3.4.14</version>
    </dependency>
    <dependency>
        <groupId>org.apache.curator</groupId>
        <artifactId>curator-recipes</artifactId>
        <version>4.2.0</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
            </exclusion>
        </exclusions>
    </dependency>        
</dependencies>

但是,要将Zookeeper 3.5.x用作客户端(对于较新的功能,如节点容器)以及Curator 4.x,请运行服务器3.5.x版本,否则客户端将抛出UnimplementedException

另一答案

我使用的是Apache Curator和ZooKeeper的错误组合。现在Apache Curator 4.0.1ZooKeeper 3.5.4-beta的组合工作得很好

以上是关于Apache Curator ZooKeeper - KeeperErrorCode =未实现,错误的主要内容,如果未能解决你的问题,请参考以下文章

Apache Curator入门实战

Apache Curator ZooKeeper - KeeperErrorCode =未实现,错误

Apache Curator操作zookeeper的API使用

15. 使用Apache Curator管理ZooKeeper

Apache Curator ZooKeeper单元测试产生错误

zookeeper持有者类