You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by Ted Yu <yu...@gmail.com> on 2013/03/13 23:54:50 UTC

recursive delete in multi

Hi,
Currently multi() only supports single delete Op:

    public void testNestedCreate() throws Exception {

        multi(zk, Arrays.asList(

                /* Create */

                Op.create("/multi", new byte[0], Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT),

                Op.create("/multi/a", new byte[0], Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT),

                Op.create("/multi/a/1", new byte[0], Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT),

                /* Delete */

                Op.delete("/multi/a/1", 0),

                Op.delete("/multi/a", 0),

                Op.delete("/multi", 0)

                ));

To obtain all the paths to be deleted, I need to traverse all the children
of the specified node. Is there plan to support recursive deletion in multi
so that I don't need to perform the traversal first ?


Thanks

Re: recursive delete in multi

Posted by Ted Yu <yu...@gmail.com>.
I logged ZOOKEEPER-1665

Cheers

On Wed, Mar 13, 2013 at 9:01 PM, Marshall McMullen <
marshall.mcmullen@gmail.com> wrote:

> I agree, sounds like a good enhancement. And far safer and less
> race-condition prone too. Feel free to open a Jira on this as we don't have
> one on it yet.
>
>
> On Wed, Mar 13, 2013 at 9:25 PM, Ted Yu <yu...@gmail.com> wrote:
>
> > Here is the background for my request.
> > In HBase, we use the following code to do clean up:
> >
> >     ZKUtil.deleteChildrenRecursively(watcher, acquiredZnode);
> >
> >     ZKUtil.deleteChildrenRecursively(watcher, reachedZnode);
> >
> >     ZKUtil.deleteChildrenRecursively(watcher, abortZnode);
> > It would be nice if recursive deletion is supported so that we don't need
> > to traverse all the children first.
> >
> > Thanks
> >
> > On Wed, Mar 13, 2013 at 8:22 PM, Marshall McMullen <
> > marshall.mcmullen@gmail.com> wrote:
> >
> > > No plans to add that at this point that I know of. Certainly haven't
> seen
> > > any jira for this.
> > >
> > >
> > > On Wed, Mar 13, 2013 at 4:54 PM, Ted Yu <yu...@gmail.com> wrote:
> > >
> > > > Hi,
> > > > Currently multi() only supports single delete Op:
> > > >
> > > >     public void testNestedCreate() throws Exception {
> > > >
> > > >         multi(zk, Arrays.asList(
> > > >
> > > >                 /* Create */
> > > >
> > > >                 Op.create("/multi", new byte[0], Ids.OPEN_ACL_UNSAFE,
> > > > CreateMode.PERSISTENT),
> > > >
> > > >                 Op.create("/multi/a", new byte[0],
> Ids.OPEN_ACL_UNSAFE,
> > > > CreateMode.PERSISTENT),
> > > >
> > > >                 Op.create("/multi/a/1", new byte[0],
> > Ids.OPEN_ACL_UNSAFE,
> > > > CreateMode.PERSISTENT),
> > > >
> > > >                 /* Delete */
> > > >
> > > >                 Op.delete("/multi/a/1", 0),
> > > >
> > > >                 Op.delete("/multi/a", 0),
> > > >
> > > >                 Op.delete("/multi", 0)
> > > >
> > > >                 ));
> > > >
> > > > To obtain all the paths to be deleted, I need to traverse all the
> > > children
> > > > of the specified node. Is there plan to support recursive deletion in
> > > multi
> > > > so that I don't need to perform the traversal first ?
> > > >
> > > >
> > > > Thanks
> > > >
> > >
> >
>

Re: recursive delete in multi

Posted by Marshall McMullen <ma...@gmail.com>.
I agree, sounds like a good enhancement. And far safer and less
race-condition prone too. Feel free to open a Jira on this as we don't have
one on it yet.


On Wed, Mar 13, 2013 at 9:25 PM, Ted Yu <yu...@gmail.com> wrote:

> Here is the background for my request.
> In HBase, we use the following code to do clean up:
>
>     ZKUtil.deleteChildrenRecursively(watcher, acquiredZnode);
>
>     ZKUtil.deleteChildrenRecursively(watcher, reachedZnode);
>
>     ZKUtil.deleteChildrenRecursively(watcher, abortZnode);
> It would be nice if recursive deletion is supported so that we don't need
> to traverse all the children first.
>
> Thanks
>
> On Wed, Mar 13, 2013 at 8:22 PM, Marshall McMullen <
> marshall.mcmullen@gmail.com> wrote:
>
> > No plans to add that at this point that I know of. Certainly haven't seen
> > any jira for this.
> >
> >
> > On Wed, Mar 13, 2013 at 4:54 PM, Ted Yu <yu...@gmail.com> wrote:
> >
> > > Hi,
> > > Currently multi() only supports single delete Op:
> > >
> > >     public void testNestedCreate() throws Exception {
> > >
> > >         multi(zk, Arrays.asList(
> > >
> > >                 /* Create */
> > >
> > >                 Op.create("/multi", new byte[0], Ids.OPEN_ACL_UNSAFE,
> > > CreateMode.PERSISTENT),
> > >
> > >                 Op.create("/multi/a", new byte[0], Ids.OPEN_ACL_UNSAFE,
> > > CreateMode.PERSISTENT),
> > >
> > >                 Op.create("/multi/a/1", new byte[0],
> Ids.OPEN_ACL_UNSAFE,
> > > CreateMode.PERSISTENT),
> > >
> > >                 /* Delete */
> > >
> > >                 Op.delete("/multi/a/1", 0),
> > >
> > >                 Op.delete("/multi/a", 0),
> > >
> > >                 Op.delete("/multi", 0)
> > >
> > >                 ));
> > >
> > > To obtain all the paths to be deleted, I need to traverse all the
> > children
> > > of the specified node. Is there plan to support recursive deletion in
> > multi
> > > so that I don't need to perform the traversal first ?
> > >
> > >
> > > Thanks
> > >
> >
>

Re: recursive delete in multi

Posted by Ted Yu <yu...@gmail.com>.
Here is the background for my request.
In HBase, we use the following code to do clean up:

    ZKUtil.deleteChildrenRecursively(watcher, acquiredZnode);

    ZKUtil.deleteChildrenRecursively(watcher, reachedZnode);

    ZKUtil.deleteChildrenRecursively(watcher, abortZnode);
It would be nice if recursive deletion is supported so that we don't need
to traverse all the children first.

Thanks

On Wed, Mar 13, 2013 at 8:22 PM, Marshall McMullen <
marshall.mcmullen@gmail.com> wrote:

> No plans to add that at this point that I know of. Certainly haven't seen
> any jira for this.
>
>
> On Wed, Mar 13, 2013 at 4:54 PM, Ted Yu <yu...@gmail.com> wrote:
>
> > Hi,
> > Currently multi() only supports single delete Op:
> >
> >     public void testNestedCreate() throws Exception {
> >
> >         multi(zk, Arrays.asList(
> >
> >                 /* Create */
> >
> >                 Op.create("/multi", new byte[0], Ids.OPEN_ACL_UNSAFE,
> > CreateMode.PERSISTENT),
> >
> >                 Op.create("/multi/a", new byte[0], Ids.OPEN_ACL_UNSAFE,
> > CreateMode.PERSISTENT),
> >
> >                 Op.create("/multi/a/1", new byte[0], Ids.OPEN_ACL_UNSAFE,
> > CreateMode.PERSISTENT),
> >
> >                 /* Delete */
> >
> >                 Op.delete("/multi/a/1", 0),
> >
> >                 Op.delete("/multi/a", 0),
> >
> >                 Op.delete("/multi", 0)
> >
> >                 ));
> >
> > To obtain all the paths to be deleted, I need to traverse all the
> children
> > of the specified node. Is there plan to support recursive deletion in
> multi
> > so that I don't need to perform the traversal first ?
> >
> >
> > Thanks
> >
>

Re: recursive delete in multi

Posted by Marshall McMullen <ma...@gmail.com>.
No plans to add that at this point that I know of. Certainly haven't seen
any jira for this.


On Wed, Mar 13, 2013 at 4:54 PM, Ted Yu <yu...@gmail.com> wrote:

> Hi,
> Currently multi() only supports single delete Op:
>
>     public void testNestedCreate() throws Exception {
>
>         multi(zk, Arrays.asList(
>
>                 /* Create */
>
>                 Op.create("/multi", new byte[0], Ids.OPEN_ACL_UNSAFE,
> CreateMode.PERSISTENT),
>
>                 Op.create("/multi/a", new byte[0], Ids.OPEN_ACL_UNSAFE,
> CreateMode.PERSISTENT),
>
>                 Op.create("/multi/a/1", new byte[0], Ids.OPEN_ACL_UNSAFE,
> CreateMode.PERSISTENT),
>
>                 /* Delete */
>
>                 Op.delete("/multi/a/1", 0),
>
>                 Op.delete("/multi/a", 0),
>
>                 Op.delete("/multi", 0)
>
>                 ));
>
> To obtain all the paths to be deleted, I need to traverse all the children
> of the specified node. Is there plan to support recursive deletion in multi
> so that I don't need to perform the traversal first ?
>
>
> Thanks
>