• Home
  • LLMs
  • Python
  • Docker
  • Kubernetes
  • Java
  • Maven
  • All
  • About
ZooKeeper | Curator Framework: Print the ACL of a zNode [getACL]
  1. Notes
  2. Example

  1. Notes:
    The code bellow let you read the ACL of a zNode.

    Calling the method "CuratorFramework::getACL" will return a "List<ACL>" list.

    You will get this error if the zNode doesn't exist in ZooKeeper:
    org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /path

    In order for the code bellow to work:
    ► Make sure to update the "CONNECT_STRING" variable with your information.
  2. Example
    Here's an example of how to read the ACL of a zNode:
    final String CONNECT_STRING = "localhost:2181";
    
    final int SESSION_TIMEOUT_MS = Integer.valueOf(60 * 1000);
    final int CONNECTION_TIMEOUT_MS = Integer.valueOf(15 * 1000);
    final RetryPolicy RETRY_POLICY = new RetryOneTime(1000);
    
    // -- CuratorFrameworkFactory::newClient
    final CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient(CONNECT_STRING, SESSION_TIMEOUT_MS, CONNECTION_TIMEOUT_MS, RETRY_POLICY);
    
    // -- CuratorFramework::start
    curatorFramework.start();
    
    // -- CuratorFramework::getACL
    final String path = "/abc";
    
    final List<ACL> acls = curatorFramework.getACL().forPath(path);
    
    if (acls != null) {
        for (ACL acl : acls) {
            System.out.println("acl: " + acl);
        }
    }
    
    // -- CuratorFramework::close
    curatorFramework.close();
© 2025  mtitek