使用ZK 3.4.5和zkCli.sh,我得到了以下结果:
./zkCli.sh -server localhost:2181
Connecting to localhost:2181
Welcome to ZooKeeper!
JLine support is enabled
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] create /test 100
Created /test
[zk: localhost:2181(CONNECTED) 1] create /test/spacesString "this string has spaces in it"
Created /test/spacesString
[zk: localhost:2181(CONNECTED) 2] get /test/spacesString
"this
cZxid = 0x9c220
ctime = Wed Mar 11 06:46:10 EDT 2015
mZxid = 0x9c220
mtime = Wed Mar 11 06:46:10 EDT 2015
[deleted rest of output here]
[zk: localhost:2181(CONNECTED) 3] set /test/spacesString "new value"
Command failed: java.lang.NumberFormatException: For input string: "value""
我尝试这种方法是因为这里。 从那里,我得出了我所尝试的应该可以工作的结论。两个问题:
为什么第一个带空格的字符串无法正确创建?
为什么后续的“设置”会抛出NumberFormatException异常?