The code bellow let you set the ACL of a zNode.
To set the ACL of a zNode you have to define:
► The ACL Scheme: "
world
", "
auth
", "
digest
", "
ip
".
► The ACL Scheme Id: for example, the scheme "
world
" has a single Id "
anyone
".
► The ACL permissions: "
ALL
", "
ADMIN
", "
CREATE
", "
DELETE
", "
READ
", "
WRITE
".
Calling the method "
CuratorFramework::setACL
" will initialize the ACL of a zNode and return a "
Stat
" object.
You will get this error if the zNode doesn't exist in ZooKeeper:
org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /path
You will get this error if the ACL is invalid:
org.apache.zookeeper.KeeperException$InvalidACLException: KeeperErrorCode = InvalidACL for /path
You will get this error if you don't have permissions to set the ACL of a zNode:
org.apache.zookeeper.KeeperException$NoAuthException: KeeperErrorCode = NoAuth for /path
In order for the code bellow to work:
► Make sure to update the "
CONNECT_STRING
" variable with your information.