zookeeper -org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplem

 

在項目中使用到Apache Curator Framework連接Zookeeper 3.4.9服務器,使用的Curator Framework版本是最新版3.2.1

<dependency>
	<groupId>org.apache.curator</groupId>
	<artifactId>curator-framework</artifactId>
	<version>3.2.1</version>
</dependency>

項目同時導入了zookeeper-3.5.1的庫

結果在使用CuratorFramework.create()方法創建新的節點時,拋出了

org.apache.zookeeper.KeeperException$UnimplementedException: 
KeeperErrorCode = Unimplemented for [zk節點路徑名]

的異常。

Curator Framework的2.x.x版本和3.x.x版本對Zookeeper支持的版本是有差異的,查看Curator Framework的官網(http://curator.apache.org),在Versions部分有這麼一段話

Versions
The are currently two released versions of Curator, 2.x.x and 3.x.x:

Curator 2.x.x - compatible with both ZooKeeper 3.4.x and ZooKeeper 3.5.x
Curator 3.x.x - compatible only with ZooKeeper 3.5.x and includes support for new features such as dynamic reconfiguration, etc.

對於zookeeper 3.4.x服務器版本,只有Curator 2.x.x才支持,我使用的是Curator 3.2.1版本,不支持Zookeeper 3.4.9服務器,所以會拋出這個異常, 將Curator Framework的版本改爲2.x.x的最後一個版本2.11.1,再運行程序就沒有異常了。

<dependency>
	<groupId>org.apache.curator</groupId>
	<artifactId>curator-framework</artifactId>
	<version>2.11.1</version>
</dependency>

大家在直接使用Curator Framework進行Zk監控,或者使用Spring Cloud Zookeeper Config時(內含Curator Framework的引用),請注意連接的zookeeper服務器版本,根據zk服務器版本的不同,選擇不同的Curator Framework版本

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章