Class ZooReaderWriter


  • public class ZooReaderWriter
    extends ZooReader
    • Method Detail

      • getZooKeeper

        public org.apache.zookeeper.ZooKeeper getZooKeeper()
        Overrides:
        getZooKeeper in class ZooReader
      • getACL

        public List<org.apache.zookeeper.data.ACL> getACL​(String zPath)
                                                   throws org.apache.zookeeper.KeeperException,
                                                          InterruptedException
        Retrieve the ACL list that was on the node
        Throws:
        org.apache.zookeeper.KeeperException
        InterruptedException
      • putPersistentData

        public boolean putPersistentData​(String zPath,
                                         byte[] data,
                                         ZooUtil.NodeExistsPolicy policy)
                                  throws org.apache.zookeeper.KeeperException,
                                         InterruptedException
        Create a persistent node with the default ACL
        Returns:
        true if the data was set on a new node or overwritten, and false if an existing node was skipped
        Throws:
        org.apache.zookeeper.KeeperException
        InterruptedException
      • putPrivatePersistentData

        public boolean putPrivatePersistentData​(String zPath,
                                                byte[] data,
                                                ZooUtil.NodeExistsPolicy policy)
                                         throws org.apache.zookeeper.KeeperException,
                                                InterruptedException
        Create a persistent node with the private ACL
        Returns:
        true if the data was set on a new node or overwritten, and false if an existing node was skipped
        Throws:
        org.apache.zookeeper.KeeperException
        InterruptedException
      • putPersistentData

        public boolean putPersistentData​(String zPath,
                                         byte[] data,
                                         ZooUtil.NodeExistsPolicy policy,
                                         List<org.apache.zookeeper.data.ACL> acls)
                                  throws org.apache.zookeeper.KeeperException,
                                         InterruptedException
        Create a persistent node with the provided ACLs
        Returns:
        true if the data was set on a new node or overwritten, and false if an existing node was skipped
        Throws:
        org.apache.zookeeper.KeeperException
        InterruptedException
      • overwritePersistentData

        public boolean overwritePersistentData​(String zPath,
                                               byte[] data,
                                               int expectedVersion)
                                        throws org.apache.zookeeper.KeeperException,
                                               InterruptedException
        Overwrite a persistent node if the data version matches.
        Parameters:
        zPath - the zookeeper path
        data - the byte array data
        expectedVersion - the expected data version of the zookeeper node.
        Returns:
        true if the data was set, false if the version does not match expected.
        Throws:
        org.apache.zookeeper.KeeperException - if a KeeperException occurs (no node most likely)
        InterruptedException - if the zookeeper write is interrupted.
      • putPersistentSequential

        public String putPersistentSequential​(String zPath,
                                              byte[] data)
                                       throws org.apache.zookeeper.KeeperException,
                                              InterruptedException
        Create a persistent sequential node with the default ACL
        Returns:
        the actual path of the created node
        Throws:
        org.apache.zookeeper.KeeperException
        InterruptedException
      • putEphemeralData

        public void putEphemeralData​(String zPath,
                                     byte[] data)
                              throws org.apache.zookeeper.KeeperException,
                                     InterruptedException
        Create an ephemeral node with the default ACL
        Throws:
        org.apache.zookeeper.KeeperException
        InterruptedException
      • putEphemeralSequential

        public String putEphemeralSequential​(String zPath,
                                             byte[] data)
                                      throws org.apache.zookeeper.KeeperException,
                                             InterruptedException
        Create an ephemeral sequential node with the default ACL
        Returns:
        the actual path of the created node
        Throws:
        org.apache.zookeeper.KeeperException
        InterruptedException
      • recursiveCopyPersistentOverwrite

        public void recursiveCopyPersistentOverwrite​(String source,
                                                     String destination)
                                              throws org.apache.zookeeper.KeeperException,
                                                     InterruptedException
        Recursively copy any persistent data from the source to the destination, using the default ACL to create any missing nodes and skipping over any ephemeral data.
        Throws:
        org.apache.zookeeper.KeeperException
        InterruptedException
      • mkdirs

        public void mkdirs​(String path)
                    throws org.apache.zookeeper.KeeperException,
                           InterruptedException
        Ensure the provided path exists, using persistent nodes, empty data, and the default ACL for any missing path elements.
        Throws:
        org.apache.zookeeper.KeeperException
        InterruptedException
      • delete

        public void delete​(String path)
                    throws org.apache.zookeeper.KeeperException,
                           InterruptedException
        Delete the specified node, and ignore NONODE exceptions.
        Throws:
        org.apache.zookeeper.KeeperException
        InterruptedException
      • deleteStrict

        public void deleteStrict​(String path,
                                 int version)
                          throws org.apache.zookeeper.KeeperException,
                                 InterruptedException
        Delete the specified node if the version matches the provided version. All underlying exceptions are thrown back to the caller.
        Parameters:
        path - the path of the ZooKeeper node.
        version - the expected version of the ZooKeeper node.
        Throws:
        org.apache.zookeeper.KeeperException
        InterruptedException