常见的KeeperException里,Connectionloss异常通常是可以忽略的,authfailed和session expired异常要求重新创建zookeeper客户端。其他种类的异常,根据实际业务逻辑来处理。

ZooKeeper.create 

NodeExistsException NODEEXISTS - if a node with the same actual path already exists
NoNodeException NONODE - if the parent node does not exist
NoChildrenForEphemeralsException NOCHILDRENFOREPHEMERALS - if the parent node of the given path is ephemeral
InvalidACLException INVALIDACL - if the ACL is invalid, null, or empty
AuthFailedException AUTHFAILED
SessionExpiredException SESSIONEXPIRED
ConnectionLossException CONNECTIONLOSS


ZooKeeper.delete

NoNodeException NONODE - if the nodes does not exist
BadVersionException BADVERSION - if the given version does not match the node's version
NotEmptyException NOTEMPTY - if the node has children
AuthFailedException AUTHFAILED
SessionExpiredException SESSIONEXPIRED
ConnectionLossException CONNECTIONLOSS


ZooKeeper.multi

AuthFailedException AUTHFAILED
SessionExpiredException SESSIONEXPIRED
ConnectionLossException CONNECTIONLOSS


ZooKeeper.exists

AuthFailedException AUTHFAILED
SessionExpiredException SESSIONEXPIRED
ConnectionLossException CONNECTIONLOSS


ZooKeeper.getData

NodeExistsException NODEEXISTS - if no node with the given path exists
AuthFailedException AUTHFAILED
SessionExpiredException SESSIONEXPIRED
ConnectionLossException CONNECTIONLOSS


ZooKeeper.setData

NodeExistsException NODEEXISTS - if no node with the given path exists
BadVersionException BADVERSION - if the given version does not match the node's version
AuthFailedException AUTHFAILED
SessionExpiredException SESSIONEXPIRED
ConnectionLossException CONNECTIONLOSS


ZooKeeper.getACL

NodeExistsException NODEEXISTS - if no node with the given path exists
AuthFailedException AUTHFAILED
SessionExpiredException SESSIONEXPIRED
ConnectionLossException CONNECTIONLOSS


ZooKeeper.setACL

NodeExistsException NODEEXISTS - if no node with the given path exists
BadVersionException BADVERSION - if the given version does not match the node's version
InvalidACLException INVALIDACL - if the ACL is invalid
AuthFailedException AUTHFAILED
SessionExpiredException SESSIONEXPIRED
ConnectionLossException CONNECTIONLOSS


ZooKeeper.getChildren
NodeExistsException NODEEXISTS - if no node with the given path exists
AuthFailedException AUTHFAILED
SessionExpiredException SESSIONEXPIRED
ConnectionLossException CONNECTIONLOSS
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐