Details

    • Type: Sub-task
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.0
    • Fix Version/s: 3.0.0
    • Component/s: Recipes
    • Labels:
      None

      Description

      Once the new Watcher Removal APIs are available, every Curator Recipe should be reviewed so that they clean up watchers as appropriate.

        Issue Links

          Activity

          Hide
          randgalt Jordan Zimmerman added a comment -

          It was definitely merged. Apache's github tool must've been down or something.

          Show
          randgalt Jordan Zimmerman added a comment - It was definitely merged. Apache's github tool must've been down or something.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user Randgalt closed the pull request at:

          https://github.com/apache/curator/pull/82

          Show
          githubbot ASF GitHub Bot added a comment - Github user Randgalt closed the pull request at: https://github.com/apache/curator/pull/82
          Hide
          randgalt Jordan Zimmerman added a comment -

          I'm trying to figure this out. I think it can. I'll double check and close it today.

          Show
          randgalt Jordan Zimmerman added a comment - I'm trying to figure this out. I think it can. I'll double check and close it today.
          Hide
          mdrob Mike Drob added a comment -

          The PR is closed, was this merged in? Can the issue be resolved?

          Show
          mdrob Mike Drob added a comment - The PR is closed, was this merged in? Can the issue be resolved?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user cammckenzie commented on the pull request:

          https://github.com/apache/curator/pull/82#issuecomment-103745243

          LGTM

          Show
          githubbot ASF GitHub Bot added a comment - Github user cammckenzie commented on the pull request: https://github.com/apache/curator/pull/82#issuecomment-103745243 LGTM
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user Randgalt commented on the pull request:

          https://github.com/apache/curator/pull/82#issuecomment-103744694

          All comments applied, latest CURATOR-161 merged.

          Show
          githubbot ASF GitHub Bot added a comment - Github user Randgalt commented on the pull request: https://github.com/apache/curator/pull/82#issuecomment-103744694 All comments applied, latest CURATOR-161 merged.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user Randgalt commented on a diff in the pull request:

          https://github.com/apache/curator/pull/82#discussion_r30667688

          — Diff: curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java —
          @@ -0,0 +1,251 @@
          +/**
          + * Licensed to the Apache Software Foundation (ASF) under one
          + * or more contributor license agreements. See the NOTICE file
          + * distributed with this work for additional information
          + * regarding copyright ownership. The ASF licenses this file
          + * to you under the Apache License, Version 2.0 (the
          + * "License"); you may not use this file except in compliance
          + * with the License. You may obtain a copy of the License at
          + *
          + * http://www.apache.org/licenses/LICENSE-2.0
          + *
          + * Unless required by applicable law or agreed to in writing,
          + * software distributed under the License is distributed on an
          + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
          + * KIND, either express or implied. See the License for the
          + * specific language governing permissions and limitations
          + * under the License.
          + */
          +package org.apache.curator.framework.imps;
          +
          +import org.apache.curator.framework.CuratorFramework;
          +import org.apache.curator.framework.CuratorFrameworkFactory;
          +import org.apache.curator.framework.WatcherRemoveCuratorFramework;
          +import org.apache.curator.retry.RetryOneTime;
          +import org.apache.curator.test.BaseClassForTests;
          +import org.apache.curator.test.Timing;
          +import org.apache.curator.test.WatchersDebug;
          +import org.apache.curator.utils.CloseableUtils;
          +import org.apache.zookeeper.WatchedEvent;
          +import org.apache.zookeeper.Watcher;
          +import org.testng.Assert;
          +import org.testng.annotations.Test;
          +import java.util.List;
          +import java.util.concurrent.CountDownLatch;
          +
          +public class TestWatcherRemovalManager extends BaseClassForTests
          +{
          + @Test
          + public void testBasic() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          +

          { + client.start(); + internalTryBasic(client); + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testBasicNamespace1() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + { + client.start(); + internalTryBasic(client.usingNamespace("foo")); + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testBasicNamespace2() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.builder()
          + .connectString(server.getConnectString())
          + .retryPolicy(new RetryOneTime(1))
          + .namespace("hey")
          + .build();
          + try
          + { + client.start(); + internalTryBasic(client); + }

          + finally
          +

          { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testBasicNamespace3() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.builder()
          + .connectString(server.getConnectString())
          + .retryPolicy(new RetryOneTime(1))
          + .namespace("hey")
          + .build();
          + try
          + { + client.start(); + internalTryBasic(client.usingNamespace("lakjsf")); + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }

          + }
          +
          + @Test
          + public void testSameWatcher() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + {
          + client.start();
          +
          + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
          +
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          +

          { + // NOP + }

          + };
          +
          + removerClient.getData().usingWatcher(watcher).forPath("/");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + removerClient.getData().usingWatcher(watcher).forPath("/");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + }
          + finally
          +

          { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testTriggered() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + {
          + client.start();
          +
          + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
          +
          + final CountDownLatch latch = new CountDownLatch(1);
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          + {
          + if ( event.getType() == Event.EventType.NodeCreated )
          + { + latch.countDown(); + }
          + }
          + };
          +
          + removerClient.checkExists().usingWatcher(watcher).forPath("/yo");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + removerClient.create().forPath("/yo");
          +
          + Assert.assertTrue(new Timing().awaitLatch(latch));
          +
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0);
          + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }

          + }
          +
          + @Test
          + public void testResetFromWatcher() throws Exception
          + {
          + Timing timing = new Timing();
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + {
          + client.start();
          +
          + final WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
          +
          + final CountDownLatch latch = new CountDownLatch(1);
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          + {
          + if ( event.getType() == Event.EventType.NodeCreated )
          + {
          + try
          +

          { + removerClient.checkExists().usingWatcher(this).forPath("/yo"); + }

          + catch ( Exception e )
          +

          { + e.printStackTrace(); + }

          + }
          + else if ( event.getType() == Event.EventType.NodeDeleted )
          +

          { + latch.countDown(); + }

          + }
          + };
          +
          + removerClient.checkExists().usingWatcher(watcher).forPath("/yo");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + removerClient.create().forPath("/yo");
          +
          + timing.sleepABit();
          — End diff –

          done

          Show
          githubbot ASF GitHub Bot added a comment - Github user Randgalt commented on a diff in the pull request: https://github.com/apache/curator/pull/82#discussion_r30667688 — Diff: curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java — @@ -0,0 +1,251 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.framework.imps; + +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.framework.WatcherRemoveCuratorFramework; +import org.apache.curator.retry.RetryOneTime; +import org.apache.curator.test.BaseClassForTests; +import org.apache.curator.test.Timing; +import org.apache.curator.test.WatchersDebug; +import org.apache.curator.utils.CloseableUtils; +import org.apache.zookeeper.WatchedEvent; +import org.apache.zookeeper.Watcher; +import org.testng.Assert; +import org.testng.annotations.Test; +import java.util.List; +import java.util.concurrent.CountDownLatch; + +public class TestWatcherRemovalManager extends BaseClassForTests +{ + @Test + public void testBasic() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + internalTryBasic(client); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testBasicNamespace1() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + internalTryBasic(client.usingNamespace("foo")); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testBasicNamespace2() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.builder() + .connectString(server.getConnectString()) + .retryPolicy(new RetryOneTime(1)) + .namespace("hey") + .build(); + try + { + client.start(); + internalTryBasic(client); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testBasicNamespace3() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.builder() + .connectString(server.getConnectString()) + .retryPolicy(new RetryOneTime(1)) + .namespace("hey") + .build(); + try + { + client.start(); + internalTryBasic(client.usingNamespace("lakjsf")); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testSameWatcher() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework(); + + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + // NOP + } + }; + + removerClient.getData().usingWatcher(watcher).forPath("/"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + removerClient.getData().usingWatcher(watcher).forPath("/"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testTriggered() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework(); + + final CountDownLatch latch = new CountDownLatch(1); + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + if ( event.getType() == Event.EventType.NodeCreated ) + { + latch.countDown(); + } + } + }; + + removerClient.checkExists().usingWatcher(watcher).forPath("/yo"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + removerClient.create().forPath("/yo"); + + Assert.assertTrue(new Timing().awaitLatch(latch)); + + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testResetFromWatcher() throws Exception + { + Timing timing = new Timing(); + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + + final WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework(); + + final CountDownLatch latch = new CountDownLatch(1); + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + if ( event.getType() == Event.EventType.NodeCreated ) + { + try + { + removerClient.checkExists().usingWatcher(this).forPath("/yo"); + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + else if ( event.getType() == Event.EventType.NodeDeleted ) + { + latch.countDown(); + } + } + }; + + removerClient.checkExists().usingWatcher(watcher).forPath("/yo"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + removerClient.create().forPath("/yo"); + + timing.sleepABit(); — End diff – done
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user Randgalt commented on a diff in the pull request:

          https://github.com/apache/curator/pull/82#discussion_r30667610

          — Diff: curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java —
          @@ -0,0 +1,251 @@
          +/**
          + * Licensed to the Apache Software Foundation (ASF) under one
          + * or more contributor license agreements. See the NOTICE file
          + * distributed with this work for additional information
          + * regarding copyright ownership. The ASF licenses this file
          + * to you under the Apache License, Version 2.0 (the
          + * "License"); you may not use this file except in compliance
          + * with the License. You may obtain a copy of the License at
          + *
          + * http://www.apache.org/licenses/LICENSE-2.0
          + *
          + * Unless required by applicable law or agreed to in writing,
          + * software distributed under the License is distributed on an
          + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
          + * KIND, either express or implied. See the License for the
          + * specific language governing permissions and limitations
          + * under the License.
          + */
          +package org.apache.curator.framework.imps;
          +
          +import org.apache.curator.framework.CuratorFramework;
          +import org.apache.curator.framework.CuratorFrameworkFactory;
          +import org.apache.curator.framework.WatcherRemoveCuratorFramework;
          +import org.apache.curator.retry.RetryOneTime;
          +import org.apache.curator.test.BaseClassForTests;
          +import org.apache.curator.test.Timing;
          +import org.apache.curator.test.WatchersDebug;
          +import org.apache.curator.utils.CloseableUtils;
          +import org.apache.zookeeper.WatchedEvent;
          +import org.apache.zookeeper.Watcher;
          +import org.testng.Assert;
          +import org.testng.annotations.Test;
          +import java.util.List;
          +import java.util.concurrent.CountDownLatch;
          +
          +public class TestWatcherRemovalManager extends BaseClassForTests
          +{
          + @Test
          + public void testBasic() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          +

          { + client.start(); + internalTryBasic(client); + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testBasicNamespace1() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + { + client.start(); + internalTryBasic(client.usingNamespace("foo")); + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testBasicNamespace2() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.builder()
          + .connectString(server.getConnectString())
          + .retryPolicy(new RetryOneTime(1))
          + .namespace("hey")
          + .build();
          + try
          + { + client.start(); + internalTryBasic(client); + }

          + finally
          +

          { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testBasicNamespace3() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.builder()
          + .connectString(server.getConnectString())
          + .retryPolicy(new RetryOneTime(1))
          + .namespace("hey")
          + .build();
          + try
          + { + client.start(); + internalTryBasic(client.usingNamespace("lakjsf")); + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }

          + }
          +
          + @Test
          + public void testSameWatcher() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + {
          + client.start();
          +
          + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
          +
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          +

          { + // NOP + }

          + };
          +
          + removerClient.getData().usingWatcher(watcher).forPath("/");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + removerClient.getData().usingWatcher(watcher).forPath("/");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + }
          + finally
          +

          { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testTriggered() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + {
          + client.start();
          +
          + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
          +
          + final CountDownLatch latch = new CountDownLatch(1);
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          + {
          + if ( event.getType() == Event.EventType.NodeCreated )
          + { + latch.countDown(); + }
          + }
          + };
          +
          + removerClient.checkExists().usingWatcher(watcher).forPath("/yo");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + removerClient.create().forPath("/yo");
          +
          + Assert.assertTrue(new Timing().awaitLatch(latch));
          +
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0);
          + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }

          + }
          +
          + @Test
          + public void testResetFromWatcher() throws Exception
          + {
          + Timing timing = new Timing();
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + {
          + client.start();
          +
          + final WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
          +
          + final CountDownLatch latch = new CountDownLatch(1);
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          + {
          + if ( event.getType() == Event.EventType.NodeCreated )
          + {
          + try
          +

          { + removerClient.checkExists().usingWatcher(this).forPath("/yo"); + }

          + catch ( Exception e )
          +

          { + e.printStackTrace(); + }

          + }
          + else if ( event.getType() == Event.EventType.NodeDeleted )
          +

          { + latch.countDown(); + }

          + }
          + };
          +
          + removerClient.checkExists().usingWatcher(watcher).forPath("/yo");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + removerClient.create().forPath("/yo");
          +
          + timing.sleepABit();
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          +
          + removerClient.delete().forPath("/yo");
          +
          + Assert.assertTrue(timing.awaitLatch(latch));
          +
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0);
          + }
          + finally
          +

          { + CloseableUtils.closeQuietly(client); + }

          + }
          +
          + private void internalTryBasic(CuratorFramework client) throws Exception
          + {
          + WatcherRemoveCuratorFramework removerClient = client.newWatcherRemoveCuratorFramework();
          +
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          +

          { + // NOP + }

          + };
          + removerClient.checkExists().usingWatcher(watcher).forPath("/hey");
          +
          + List<String> existWatches = WatchersDebug.getExistWatches(client.getZookeeperClient().getZooKeeper());
          + Assert.assertEquals(existWatches.size(), 1);
          +
          + removerClient.removeWatchers();
          +
          + new Timing().sleepABit();
          — End diff –

          done

          Show
          githubbot ASF GitHub Bot added a comment - Github user Randgalt commented on a diff in the pull request: https://github.com/apache/curator/pull/82#discussion_r30667610 — Diff: curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java — @@ -0,0 +1,251 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.framework.imps; + +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.framework.WatcherRemoveCuratorFramework; +import org.apache.curator.retry.RetryOneTime; +import org.apache.curator.test.BaseClassForTests; +import org.apache.curator.test.Timing; +import org.apache.curator.test.WatchersDebug; +import org.apache.curator.utils.CloseableUtils; +import org.apache.zookeeper.WatchedEvent; +import org.apache.zookeeper.Watcher; +import org.testng.Assert; +import org.testng.annotations.Test; +import java.util.List; +import java.util.concurrent.CountDownLatch; + +public class TestWatcherRemovalManager extends BaseClassForTests +{ + @Test + public void testBasic() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + internalTryBasic(client); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testBasicNamespace1() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + internalTryBasic(client.usingNamespace("foo")); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testBasicNamespace2() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.builder() + .connectString(server.getConnectString()) + .retryPolicy(new RetryOneTime(1)) + .namespace("hey") + .build(); + try + { + client.start(); + internalTryBasic(client); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testBasicNamespace3() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.builder() + .connectString(server.getConnectString()) + .retryPolicy(new RetryOneTime(1)) + .namespace("hey") + .build(); + try + { + client.start(); + internalTryBasic(client.usingNamespace("lakjsf")); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testSameWatcher() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework(); + + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + // NOP + } + }; + + removerClient.getData().usingWatcher(watcher).forPath("/"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + removerClient.getData().usingWatcher(watcher).forPath("/"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testTriggered() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework(); + + final CountDownLatch latch = new CountDownLatch(1); + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + if ( event.getType() == Event.EventType.NodeCreated ) + { + latch.countDown(); + } + } + }; + + removerClient.checkExists().usingWatcher(watcher).forPath("/yo"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + removerClient.create().forPath("/yo"); + + Assert.assertTrue(new Timing().awaitLatch(latch)); + + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testResetFromWatcher() throws Exception + { + Timing timing = new Timing(); + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + + final WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework(); + + final CountDownLatch latch = new CountDownLatch(1); + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + if ( event.getType() == Event.EventType.NodeCreated ) + { + try + { + removerClient.checkExists().usingWatcher(this).forPath("/yo"); + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + else if ( event.getType() == Event.EventType.NodeDeleted ) + { + latch.countDown(); + } + } + }; + + removerClient.checkExists().usingWatcher(watcher).forPath("/yo"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + removerClient.create().forPath("/yo"); + + timing.sleepABit(); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + + removerClient.delete().forPath("/yo"); + + Assert.assertTrue(timing.awaitLatch(latch)); + + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + private void internalTryBasic(CuratorFramework client) throws Exception + { + WatcherRemoveCuratorFramework removerClient = client.newWatcherRemoveCuratorFramework(); + + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + // NOP + } + }; + removerClient.checkExists().usingWatcher(watcher).forPath("/hey"); + + List<String> existWatches = WatchersDebug.getExistWatches(client.getZookeeperClient().getZooKeeper()); + Assert.assertEquals(existWatches.size(), 1); + + removerClient.removeWatchers(); + + new Timing().sleepABit(); — End diff – done
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user cammckenzie commented on the pull request:

          https://github.com/apache/curator/pull/82#issuecomment-103703152

          Other than my minor comments, this looks good to me. Still needs to have the updates to CURATOR-161 merged into it also as currently one of the CURATOR-161 related unit tests is breaking.

          Are there any other recipes that require watcher removal?

          Show
          githubbot ASF GitHub Bot added a comment - Github user cammckenzie commented on the pull request: https://github.com/apache/curator/pull/82#issuecomment-103703152 Other than my minor comments, this looks good to me. Still needs to have the updates to CURATOR-161 merged into it also as currently one of the CURATOR-161 related unit tests is breaking. Are there any other recipes that require watcher removal?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user cammckenzie commented on a diff in the pull request:

          https://github.com/apache/curator/pull/82#discussion_r30661149

          — Diff: curator-framework/src/main/java/org/apache/curator/framework/imps/WatcherRemovalManager.java —
          @@ -0,0 +1,138 @@
          +/**
          + * Licensed to the Apache Software Foundation (ASF) under one
          + * or more contributor license agreements. See the NOTICE file
          + * distributed with this work for additional information
          + * regarding copyright ownership. The ASF licenses this file
          + * to you under the Apache License, Version 2.0 (the
          + * "License"); you may not use this file except in compliance
          + * with the License. You may obtain a copy of the License at
          + *
          + * http://www.apache.org/licenses/LICENSE-2.0
          + *
          + * Unless required by applicable law or agreed to in writing,
          + * software distributed under the License is distributed on an
          + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
          + * KIND, either express or implied. See the License for the
          + * specific language governing permissions and limitations
          + * under the License.
          + */
          +package org.apache.curator.framework.imps;
          +
          +import com.google.common.annotations.VisibleForTesting;
          +import com.google.common.base.Preconditions;
          +import com.google.common.collect.Sets;
          +import org.apache.zookeeper.WatchedEvent;
          +import org.apache.zookeeper.Watcher;
          +import org.slf4j.Logger;
          +import org.slf4j.LoggerFactory;
          +import java.util.HashSet;
          +import java.util.Set;
          +
          +public class WatcherRemovalManager
          +{
          + private final Logger log = LoggerFactory.getLogger(getClass());
          + private final CuratorFrameworkImpl client;
          + private final Set<WrappedWatcher> entries = Sets.newHashSet(); // guarded by sync
          +
          + WatcherRemovalManager(CuratorFrameworkImpl client)
          +

          { + this.client = client; + }

          +
          + synchronized Watcher add(String path, Watcher watcher)
          +

          { + path = Preconditions.checkNotNull(path, "path cannot be null"); + watcher = Preconditions.checkNotNull(watcher, "watcher cannot be null"); + + WrappedWatcher wrappedWatcher = new WrappedWatcher(watcher, path); + entries.add(wrappedWatcher); + return wrappedWatcher; + }

          +
          + @VisibleForTesting
          + synchronized Set<? extends Watcher> getEntries()
          +

          { + return Sets.newHashSet(entries); + }

          +
          + void removeWatchers()
          + {
          + HashSet<WrappedWatcher> localEntries;
          + synchronized(this)
          +

          { + localEntries = Sets.newHashSet(entries); + }

          + for ( WrappedWatcher entry : localEntries )
          + {
          + try
          + {
          + log.debug("Removing watcher for path: " + entry.path);
          + RemoveWatchesBuilderImpl builder = new RemoveWatchesBuilderImpl(client);
          + builder.prepInternalRemoval(entry);
          + builder.pathInForeground(entry.path);
          — End diff –

          That would probably be a good idea. You could do it as a guaranteed background operation.

          Show
          githubbot ASF GitHub Bot added a comment - Github user cammckenzie commented on a diff in the pull request: https://github.com/apache/curator/pull/82#discussion_r30661149 — Diff: curator-framework/src/main/java/org/apache/curator/framework/imps/WatcherRemovalManager.java — @@ -0,0 +1,138 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.framework.imps; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; +import com.google.common.collect.Sets; +import org.apache.zookeeper.WatchedEvent; +import org.apache.zookeeper.Watcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.HashSet; +import java.util.Set; + +public class WatcherRemovalManager +{ + private final Logger log = LoggerFactory.getLogger(getClass()); + private final CuratorFrameworkImpl client; + private final Set<WrappedWatcher> entries = Sets.newHashSet(); // guarded by sync + + WatcherRemovalManager(CuratorFrameworkImpl client) + { + this.client = client; + } + + synchronized Watcher add(String path, Watcher watcher) + { + path = Preconditions.checkNotNull(path, "path cannot be null"); + watcher = Preconditions.checkNotNull(watcher, "watcher cannot be null"); + + WrappedWatcher wrappedWatcher = new WrappedWatcher(watcher, path); + entries.add(wrappedWatcher); + return wrappedWatcher; + } + + @VisibleForTesting + synchronized Set<? extends Watcher> getEntries() + { + return Sets.newHashSet(entries); + } + + void removeWatchers() + { + HashSet<WrappedWatcher> localEntries; + synchronized(this) + { + localEntries = Sets.newHashSet(entries); + } + for ( WrappedWatcher entry : localEntries ) + { + try + { + log.debug("Removing watcher for path: " + entry.path); + RemoveWatchesBuilderImpl builder = new RemoveWatchesBuilderImpl(client); + builder.prepInternalRemoval(entry); + builder.pathInForeground(entry.path); — End diff – That would probably be a good idea. You could do it as a guaranteed background operation.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user cammckenzie commented on a diff in the pull request:

          https://github.com/apache/curator/pull/82#discussion_r30660689

          — Diff: curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java —
          @@ -0,0 +1,251 @@
          +/**
          + * Licensed to the Apache Software Foundation (ASF) under one
          + * or more contributor license agreements. See the NOTICE file
          + * distributed with this work for additional information
          + * regarding copyright ownership. The ASF licenses this file
          + * to you under the Apache License, Version 2.0 (the
          + * "License"); you may not use this file except in compliance
          + * with the License. You may obtain a copy of the License at
          + *
          + * http://www.apache.org/licenses/LICENSE-2.0
          + *
          + * Unless required by applicable law or agreed to in writing,
          + * software distributed under the License is distributed on an
          + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
          + * KIND, either express or implied. See the License for the
          + * specific language governing permissions and limitations
          + * under the License.
          + */
          +package org.apache.curator.framework.imps;
          +
          +import org.apache.curator.framework.CuratorFramework;
          +import org.apache.curator.framework.CuratorFrameworkFactory;
          +import org.apache.curator.framework.WatcherRemoveCuratorFramework;
          +import org.apache.curator.retry.RetryOneTime;
          +import org.apache.curator.test.BaseClassForTests;
          +import org.apache.curator.test.Timing;
          +import org.apache.curator.test.WatchersDebug;
          +import org.apache.curator.utils.CloseableUtils;
          +import org.apache.zookeeper.WatchedEvent;
          +import org.apache.zookeeper.Watcher;
          +import org.testng.Assert;
          +import org.testng.annotations.Test;
          +import java.util.List;
          +import java.util.concurrent.CountDownLatch;
          +
          +public class TestWatcherRemovalManager extends BaseClassForTests
          +{
          + @Test
          + public void testBasic() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          +

          { + client.start(); + internalTryBasic(client); + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testBasicNamespace1() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + { + client.start(); + internalTryBasic(client.usingNamespace("foo")); + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testBasicNamespace2() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.builder()
          + .connectString(server.getConnectString())
          + .retryPolicy(new RetryOneTime(1))
          + .namespace("hey")
          + .build();
          + try
          + { + client.start(); + internalTryBasic(client); + }

          + finally
          +

          { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testBasicNamespace3() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.builder()
          + .connectString(server.getConnectString())
          + .retryPolicy(new RetryOneTime(1))
          + .namespace("hey")
          + .build();
          + try
          + { + client.start(); + internalTryBasic(client.usingNamespace("lakjsf")); + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }

          + }
          +
          + @Test
          + public void testSameWatcher() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + {
          + client.start();
          +
          + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
          +
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          +

          { + // NOP + }

          + };
          +
          + removerClient.getData().usingWatcher(watcher).forPath("/");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + removerClient.getData().usingWatcher(watcher).forPath("/");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + }
          + finally
          +

          { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testTriggered() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + {
          + client.start();
          +
          + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
          +
          + final CountDownLatch latch = new CountDownLatch(1);
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          + {
          + if ( event.getType() == Event.EventType.NodeCreated )
          + { + latch.countDown(); + }
          + }
          + };
          +
          + removerClient.checkExists().usingWatcher(watcher).forPath("/yo");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + removerClient.create().forPath("/yo");
          +
          + Assert.assertTrue(new Timing().awaitLatch(latch));
          +
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0);
          + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }

          + }
          +
          + @Test
          + public void testResetFromWatcher() throws Exception
          + {
          + Timing timing = new Timing();
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + {
          + client.start();
          +
          + final WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
          +
          + final CountDownLatch latch = new CountDownLatch(1);
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          + {
          + if ( event.getType() == Event.EventType.NodeCreated )
          + {
          + try
          +

          { + removerClient.checkExists().usingWatcher(this).forPath("/yo"); + }

          + catch ( Exception e )
          +

          { + e.printStackTrace(); + }

          + }
          + else if ( event.getType() == Event.EventType.NodeDeleted )
          +

          { + latch.countDown(); + }

          + }
          + };
          +
          + removerClient.checkExists().usingWatcher(watcher).forPath("/yo");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + removerClient.create().forPath("/yo");
          +
          + timing.sleepABit();
          — End diff –

          Latch after reset to ensure this is deterministic?

          Show
          githubbot ASF GitHub Bot added a comment - Github user cammckenzie commented on a diff in the pull request: https://github.com/apache/curator/pull/82#discussion_r30660689 — Diff: curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java — @@ -0,0 +1,251 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.framework.imps; + +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.framework.WatcherRemoveCuratorFramework; +import org.apache.curator.retry.RetryOneTime; +import org.apache.curator.test.BaseClassForTests; +import org.apache.curator.test.Timing; +import org.apache.curator.test.WatchersDebug; +import org.apache.curator.utils.CloseableUtils; +import org.apache.zookeeper.WatchedEvent; +import org.apache.zookeeper.Watcher; +import org.testng.Assert; +import org.testng.annotations.Test; +import java.util.List; +import java.util.concurrent.CountDownLatch; + +public class TestWatcherRemovalManager extends BaseClassForTests +{ + @Test + public void testBasic() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + internalTryBasic(client); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testBasicNamespace1() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + internalTryBasic(client.usingNamespace("foo")); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testBasicNamespace2() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.builder() + .connectString(server.getConnectString()) + .retryPolicy(new RetryOneTime(1)) + .namespace("hey") + .build(); + try + { + client.start(); + internalTryBasic(client); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testBasicNamespace3() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.builder() + .connectString(server.getConnectString()) + .retryPolicy(new RetryOneTime(1)) + .namespace("hey") + .build(); + try + { + client.start(); + internalTryBasic(client.usingNamespace("lakjsf")); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testSameWatcher() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework(); + + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + // NOP + } + }; + + removerClient.getData().usingWatcher(watcher).forPath("/"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + removerClient.getData().usingWatcher(watcher).forPath("/"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testTriggered() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework(); + + final CountDownLatch latch = new CountDownLatch(1); + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + if ( event.getType() == Event.EventType.NodeCreated ) + { + latch.countDown(); + } + } + }; + + removerClient.checkExists().usingWatcher(watcher).forPath("/yo"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + removerClient.create().forPath("/yo"); + + Assert.assertTrue(new Timing().awaitLatch(latch)); + + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testResetFromWatcher() throws Exception + { + Timing timing = new Timing(); + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + + final WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework(); + + final CountDownLatch latch = new CountDownLatch(1); + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + if ( event.getType() == Event.EventType.NodeCreated ) + { + try + { + removerClient.checkExists().usingWatcher(this).forPath("/yo"); + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + else if ( event.getType() == Event.EventType.NodeDeleted ) + { + latch.countDown(); + } + } + }; + + removerClient.checkExists().usingWatcher(watcher).forPath("/yo"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + removerClient.create().forPath("/yo"); + + timing.sleepABit(); — End diff – Latch after reset to ensure this is deterministic?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user cammckenzie commented on a diff in the pull request:

          https://github.com/apache/curator/pull/82#discussion_r30660535

          — Diff: curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java —
          @@ -0,0 +1,251 @@
          +/**
          + * Licensed to the Apache Software Foundation (ASF) under one
          + * or more contributor license agreements. See the NOTICE file
          + * distributed with this work for additional information
          + * regarding copyright ownership. The ASF licenses this file
          + * to you under the Apache License, Version 2.0 (the
          + * "License"); you may not use this file except in compliance
          + * with the License. You may obtain a copy of the License at
          + *
          + * http://www.apache.org/licenses/LICENSE-2.0
          + *
          + * Unless required by applicable law or agreed to in writing,
          + * software distributed under the License is distributed on an
          + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
          + * KIND, either express or implied. See the License for the
          + * specific language governing permissions and limitations
          + * under the License.
          + */
          +package org.apache.curator.framework.imps;
          +
          +import org.apache.curator.framework.CuratorFramework;
          +import org.apache.curator.framework.CuratorFrameworkFactory;
          +import org.apache.curator.framework.WatcherRemoveCuratorFramework;
          +import org.apache.curator.retry.RetryOneTime;
          +import org.apache.curator.test.BaseClassForTests;
          +import org.apache.curator.test.Timing;
          +import org.apache.curator.test.WatchersDebug;
          +import org.apache.curator.utils.CloseableUtils;
          +import org.apache.zookeeper.WatchedEvent;
          +import org.apache.zookeeper.Watcher;
          +import org.testng.Assert;
          +import org.testng.annotations.Test;
          +import java.util.List;
          +import java.util.concurrent.CountDownLatch;
          +
          +public class TestWatcherRemovalManager extends BaseClassForTests
          +{
          + @Test
          + public void testBasic() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          +

          { + client.start(); + internalTryBasic(client); + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testBasicNamespace1() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + { + client.start(); + internalTryBasic(client.usingNamespace("foo")); + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testBasicNamespace2() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.builder()
          + .connectString(server.getConnectString())
          + .retryPolicy(new RetryOneTime(1))
          + .namespace("hey")
          + .build();
          + try
          + { + client.start(); + internalTryBasic(client); + }

          + finally
          +

          { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testBasicNamespace3() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.builder()
          + .connectString(server.getConnectString())
          + .retryPolicy(new RetryOneTime(1))
          + .namespace("hey")
          + .build();
          + try
          + { + client.start(); + internalTryBasic(client.usingNamespace("lakjsf")); + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }

          + }
          +
          + @Test
          + public void testSameWatcher() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + {
          + client.start();
          +
          + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
          +
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          +

          { + // NOP + }

          + };
          +
          + removerClient.getData().usingWatcher(watcher).forPath("/");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + removerClient.getData().usingWatcher(watcher).forPath("/");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + }
          + finally
          +

          { + CloseableUtils.closeQuietly(client); + }
          + }
          +
          + @Test
          + public void testTriggered() throws Exception
          + {
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + {
          + client.start();
          +
          + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
          +
          + final CountDownLatch latch = new CountDownLatch(1);
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          + {
          + if ( event.getType() == Event.EventType.NodeCreated )
          + { + latch.countDown(); + }
          + }
          + };
          +
          + removerClient.checkExists().usingWatcher(watcher).forPath("/yo");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + removerClient.create().forPath("/yo");
          +
          + Assert.assertTrue(new Timing().awaitLatch(latch));
          +
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0);
          + }
          + finally
          + { + CloseableUtils.closeQuietly(client); + }

          + }
          +
          + @Test
          + public void testResetFromWatcher() throws Exception
          + {
          + Timing timing = new Timing();
          + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
          + try
          + {
          + client.start();
          +
          + final WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
          +
          + final CountDownLatch latch = new CountDownLatch(1);
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          + {
          + if ( event.getType() == Event.EventType.NodeCreated )
          + {
          + try
          +

          { + removerClient.checkExists().usingWatcher(this).forPath("/yo"); + }

          + catch ( Exception e )
          +

          { + e.printStackTrace(); + }

          + }
          + else if ( event.getType() == Event.EventType.NodeDeleted )
          +

          { + latch.countDown(); + }

          + }
          + };
          +
          + removerClient.checkExists().usingWatcher(watcher).forPath("/yo");
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          + removerClient.create().forPath("/yo");
          +
          + timing.sleepABit();
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
          +
          + removerClient.delete().forPath("/yo");
          +
          + Assert.assertTrue(timing.awaitLatch(latch));
          +
          + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0);
          + }
          + finally
          +

          { + CloseableUtils.closeQuietly(client); + }

          + }
          +
          + private void internalTryBasic(CuratorFramework client) throws Exception
          + {
          + WatcherRemoveCuratorFramework removerClient = client.newWatcherRemoveCuratorFramework();
          +
          + Watcher watcher = new Watcher()
          + {
          + @Override
          + public void process(WatchedEvent event)
          +

          { + // NOP + }

          + };
          + removerClient.checkExists().usingWatcher(watcher).forPath("/hey");
          +
          + List<String> existWatches = WatchersDebug.getExistWatches(client.getZookeeperClient().getZooKeeper());
          + Assert.assertEquals(existWatches.size(), 1);
          +
          + removerClient.removeWatchers();
          +
          + new Timing().sleepABit();
          — End diff –

          Could this test be more reliable with a latch in the process() method of the watcher? If for whatever reason the remove takes longer than Timing().sleepABit() then the tests using this method will currently fail.

          Show
          githubbot ASF GitHub Bot added a comment - Github user cammckenzie commented on a diff in the pull request: https://github.com/apache/curator/pull/82#discussion_r30660535 — Diff: curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java — @@ -0,0 +1,251 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.framework.imps; + +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.framework.WatcherRemoveCuratorFramework; +import org.apache.curator.retry.RetryOneTime; +import org.apache.curator.test.BaseClassForTests; +import org.apache.curator.test.Timing; +import org.apache.curator.test.WatchersDebug; +import org.apache.curator.utils.CloseableUtils; +import org.apache.zookeeper.WatchedEvent; +import org.apache.zookeeper.Watcher; +import org.testng.Assert; +import org.testng.annotations.Test; +import java.util.List; +import java.util.concurrent.CountDownLatch; + +public class TestWatcherRemovalManager extends BaseClassForTests +{ + @Test + public void testBasic() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + internalTryBasic(client); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testBasicNamespace1() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + internalTryBasic(client.usingNamespace("foo")); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testBasicNamespace2() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.builder() + .connectString(server.getConnectString()) + .retryPolicy(new RetryOneTime(1)) + .namespace("hey") + .build(); + try + { + client.start(); + internalTryBasic(client); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testBasicNamespace3() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.builder() + .connectString(server.getConnectString()) + .retryPolicy(new RetryOneTime(1)) + .namespace("hey") + .build(); + try + { + client.start(); + internalTryBasic(client.usingNamespace("lakjsf")); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testSameWatcher() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework(); + + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + // NOP + } + }; + + removerClient.getData().usingWatcher(watcher).forPath("/"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + removerClient.getData().usingWatcher(watcher).forPath("/"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testTriggered() throws Exception + { + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + + WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework(); + + final CountDownLatch latch = new CountDownLatch(1); + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + if ( event.getType() == Event.EventType.NodeCreated ) + { + latch.countDown(); + } + } + }; + + removerClient.checkExists().usingWatcher(watcher).forPath("/yo"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + removerClient.create().forPath("/yo"); + + Assert.assertTrue(new Timing().awaitLatch(latch)); + + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + @Test + public void testResetFromWatcher() throws Exception + { + Timing timing = new Timing(); + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); + try + { + client.start(); + + final WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework(); + + final CountDownLatch latch = new CountDownLatch(1); + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + if ( event.getType() == Event.EventType.NodeCreated ) + { + try + { + removerClient.checkExists().usingWatcher(this).forPath("/yo"); + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + else if ( event.getType() == Event.EventType.NodeDeleted ) + { + latch.countDown(); + } + } + }; + + removerClient.checkExists().usingWatcher(watcher).forPath("/yo"); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + removerClient.create().forPath("/yo"); + + timing.sleepABit(); + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1); + + removerClient.delete().forPath("/yo"); + + Assert.assertTrue(timing.awaitLatch(latch)); + + Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0); + } + finally + { + CloseableUtils.closeQuietly(client); + } + } + + private void internalTryBasic(CuratorFramework client) throws Exception + { + WatcherRemoveCuratorFramework removerClient = client.newWatcherRemoveCuratorFramework(); + + Watcher watcher = new Watcher() + { + @Override + public void process(WatchedEvent event) + { + // NOP + } + }; + removerClient.checkExists().usingWatcher(watcher).forPath("/hey"); + + List<String> existWatches = WatchersDebug.getExistWatches(client.getZookeeperClient().getZooKeeper()); + Assert.assertEquals(existWatches.size(), 1); + + removerClient.removeWatchers(); + + new Timing().sleepABit(); — End diff – Could this test be more reliable with a latch in the process() method of the watcher? If for whatever reason the remove takes longer than Timing().sleepABit() then the tests using this method will currently fail.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user Randgalt commented on a diff in the pull request:

          https://github.com/apache/curator/pull/82#discussion_r30660440

          — Diff: curator-framework/src/main/java/org/apache/curator/framework/imps/WatcherRemovalManager.java —
          @@ -0,0 +1,138 @@
          +/**
          + * Licensed to the Apache Software Foundation (ASF) under one
          + * or more contributor license agreements. See the NOTICE file
          + * distributed with this work for additional information
          + * regarding copyright ownership. The ASF licenses this file
          + * to you under the Apache License, Version 2.0 (the
          + * "License"); you may not use this file except in compliance
          + * with the License. You may obtain a copy of the License at
          + *
          + * http://www.apache.org/licenses/LICENSE-2.0
          + *
          + * Unless required by applicable law or agreed to in writing,
          + * software distributed under the License is distributed on an
          + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
          + * KIND, either express or implied. See the License for the
          + * specific language governing permissions and limitations
          + * under the License.
          + */
          +package org.apache.curator.framework.imps;
          +
          +import com.google.common.annotations.VisibleForTesting;
          +import com.google.common.base.Preconditions;
          +import com.google.common.collect.Sets;
          +import org.apache.zookeeper.WatchedEvent;
          +import org.apache.zookeeper.Watcher;
          +import org.slf4j.Logger;
          +import org.slf4j.LoggerFactory;
          +import java.util.HashSet;
          +import java.util.Set;
          +
          +public class WatcherRemovalManager
          +{
          + private final Logger log = LoggerFactory.getLogger(getClass());
          + private final CuratorFrameworkImpl client;
          + private final Set<WrappedWatcher> entries = Sets.newHashSet(); // guarded by sync
          +
          + WatcherRemovalManager(CuratorFrameworkImpl client)
          +

          { + this.client = client; + }

          +
          + synchronized Watcher add(String path, Watcher watcher)
          +

          { + path = Preconditions.checkNotNull(path, "path cannot be null"); + watcher = Preconditions.checkNotNull(watcher, "watcher cannot be null"); + + WrappedWatcher wrappedWatcher = new WrappedWatcher(watcher, path); + entries.add(wrappedWatcher); + return wrappedWatcher; + }

          +
          + @VisibleForTesting
          + synchronized Set<? extends Watcher> getEntries()
          +

          { + return Sets.newHashSet(entries); + }

          +
          + void removeWatchers()
          + {
          + HashSet<WrappedWatcher> localEntries;
          + synchronized(this)
          +

          { + localEntries = Sets.newHashSet(entries); + }

          + for ( WrappedWatcher entry : localEntries )
          + {
          + try
          + {
          + log.debug("Removing watcher for path: " + entry.path);
          + RemoveWatchesBuilderImpl builder = new RemoveWatchesBuilderImpl(client);
          + builder.prepInternalRemoval(entry);
          + builder.pathInForeground(entry.path);
          — End diff –

          I wonder if this should be a background/async call instead

          Show
          githubbot ASF GitHub Bot added a comment - Github user Randgalt commented on a diff in the pull request: https://github.com/apache/curator/pull/82#discussion_r30660440 — Diff: curator-framework/src/main/java/org/apache/curator/framework/imps/WatcherRemovalManager.java — @@ -0,0 +1,138 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.framework.imps; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; +import com.google.common.collect.Sets; +import org.apache.zookeeper.WatchedEvent; +import org.apache.zookeeper.Watcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.HashSet; +import java.util.Set; + +public class WatcherRemovalManager +{ + private final Logger log = LoggerFactory.getLogger(getClass()); + private final CuratorFrameworkImpl client; + private final Set<WrappedWatcher> entries = Sets.newHashSet(); // guarded by sync + + WatcherRemovalManager(CuratorFrameworkImpl client) + { + this.client = client; + } + + synchronized Watcher add(String path, Watcher watcher) + { + path = Preconditions.checkNotNull(path, "path cannot be null"); + watcher = Preconditions.checkNotNull(watcher, "watcher cannot be null"); + + WrappedWatcher wrappedWatcher = new WrappedWatcher(watcher, path); + entries.add(wrappedWatcher); + return wrappedWatcher; + } + + @VisibleForTesting + synchronized Set<? extends Watcher> getEntries() + { + return Sets.newHashSet(entries); + } + + void removeWatchers() + { + HashSet<WrappedWatcher> localEntries; + synchronized(this) + { + localEntries = Sets.newHashSet(entries); + } + for ( WrappedWatcher entry : localEntries ) + { + try + { + log.debug("Removing watcher for path: " + entry.path); + RemoveWatchesBuilderImpl builder = new RemoveWatchesBuilderImpl(client); + builder.prepInternalRemoval(entry); + builder.pathInForeground(entry.path); — End diff – I wonder if this should be a background/async call instead
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user Randgalt commented on a diff in the pull request:

          https://github.com/apache/curator/pull/82#discussion_r30659178

          — Diff: curator-framework/src/main/java/org/apache/curator/framework/WatcherRemoveCuratorFramework.java —
          @@ -0,0 +1,24 @@
          +/**
          + * Licensed to the Apache Software Foundation (ASF) under one
          + * or more contributor license agreements. See the NOTICE file
          + * distributed with this work for additional information
          + * regarding copyright ownership. The ASF licenses this file
          + * to you under the Apache License, Version 2.0 (the
          + * "License"); you may not use this file except in compliance
          + * with the License. You may obtain a copy of the License at
          + *
          + * http://www.apache.org/licenses/LICENSE-2.0
          + *
          + * Unless required by applicable law or agreed to in writing,
          + * software distributed under the License is distributed on an
          + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
          + * KIND, either express or implied. See the License for the
          + * specific language governing permissions and limitations
          + * under the License.
          + */
          +package org.apache.curator.framework;
          +
          +public interface WatcherRemoveCuratorFramework extends CuratorFramework
          +{
          + void removeWatchers();
          — End diff –

          Yeah - missed that

          Show
          githubbot ASF GitHub Bot added a comment - Github user Randgalt commented on a diff in the pull request: https://github.com/apache/curator/pull/82#discussion_r30659178 — Diff: curator-framework/src/main/java/org/apache/curator/framework/WatcherRemoveCuratorFramework.java — @@ -0,0 +1,24 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.framework; + +public interface WatcherRemoveCuratorFramework extends CuratorFramework +{ + void removeWatchers(); — End diff – Yeah - missed that
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user cammckenzie commented on a diff in the pull request:

          https://github.com/apache/curator/pull/82#discussion_r30659120

          — Diff: curator-framework/src/main/java/org/apache/curator/framework/WatcherRemoveCuratorFramework.java —
          @@ -0,0 +1,24 @@
          +/**
          + * Licensed to the Apache Software Foundation (ASF) under one
          + * or more contributor license agreements. See the NOTICE file
          + * distributed with this work for additional information
          + * regarding copyright ownership. The ASF licenses this file
          + * to you under the Apache License, Version 2.0 (the
          + * "License"); you may not use this file except in compliance
          + * with the License. You may obtain a copy of the License at
          + *
          + * http://www.apache.org/licenses/LICENSE-2.0
          + *
          + * Unless required by applicable law or agreed to in writing,
          + * software distributed under the License is distributed on an
          + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
          + * KIND, either express or implied. See the License for the
          + * specific language governing permissions and limitations
          + * under the License.
          + */
          +package org.apache.curator.framework;
          +
          +public interface WatcherRemoveCuratorFramework extends CuratorFramework
          +{
          + void removeWatchers();
          — End diff –

          Javadoc?

          Show
          githubbot ASF GitHub Bot added a comment - Github user cammckenzie commented on a diff in the pull request: https://github.com/apache/curator/pull/82#discussion_r30659120 — Diff: curator-framework/src/main/java/org/apache/curator/framework/WatcherRemoveCuratorFramework.java — @@ -0,0 +1,24 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.framework; + +public interface WatcherRemoveCuratorFramework extends CuratorFramework +{ + void removeWatchers(); — End diff – Javadoc?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user cammckenzie commented on a diff in the pull request:

          https://github.com/apache/curator/pull/82#discussion_r30659075

          — Diff: curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java —
          @@ -235,4 +235,6 @@

          • @throws InterruptedException If interrupted while waiting
            */
            public void blockUntilConnected() throws InterruptedException;
            +
            + WatcherRemoveCuratorFramework newWatcherRemoveCuratorFramework();
              • End diff –

          Javadoc?

          Show
          githubbot ASF GitHub Bot added a comment - Github user cammckenzie commented on a diff in the pull request: https://github.com/apache/curator/pull/82#discussion_r30659075 — Diff: curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java — @@ -235,4 +235,6 @@ @throws InterruptedException If interrupted while waiting */ public void blockUntilConnected() throws InterruptedException; + + WatcherRemoveCuratorFramework newWatcherRemoveCuratorFramework(); End diff – Javadoc?
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user Randgalt opened a pull request:

          https://github.com/apache/curator/pull/82

          CURATOR-217 Use new Watcher Removal APIs in Curator Recipes

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/apache/curator CURATOR-217

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/curator/pull/82.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #82


          commit 58fcc548f87e3c787f82d48931e2e9992f6c3366
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-11T20:29:09Z

          first pass at implementation and a simple test

          commit d3672a5acbd2bdf0f8caa9b7c8ea07e9d4e4dd2a
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-11T21:19:45Z

          wip

          commit 49b2fd3a8313cd05292e2ca8edb4b14b08f0de55
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-11T23:04:01Z

          more tests, refinements

          commit ff8eb4b2ec7c99258e62416453bef649fdc6220e
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-12T01:48:16Z

          more tests

          commit 5030c198456150a82bf2a2a2e5aea75b65b2efc8
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-12T13:53:24Z

          wip


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user Randgalt opened a pull request: https://github.com/apache/curator/pull/82 CURATOR-217 Use new Watcher Removal APIs in Curator Recipes You can merge this pull request into a Git repository by running: $ git pull https://github.com/apache/curator CURATOR-217 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/curator/pull/82.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #82 commit 58fcc548f87e3c787f82d48931e2e9992f6c3366 Author: randgalt <randgalt@apache.org> Date: 2015-05-11T20:29:09Z first pass at implementation and a simple test commit d3672a5acbd2bdf0f8caa9b7c8ea07e9d4e4dd2a Author: randgalt <randgalt@apache.org> Date: 2015-05-11T21:19:45Z wip commit 49b2fd3a8313cd05292e2ca8edb4b14b08f0de55 Author: randgalt <randgalt@apache.org> Date: 2015-05-11T23:04:01Z more tests, refinements commit ff8eb4b2ec7c99258e62416453bef649fdc6220e Author: randgalt <randgalt@apache.org> Date: 2015-05-12T01:48:16Z more tests commit 5030c198456150a82bf2a2a2e5aea75b65b2efc8 Author: randgalt <randgalt@apache.org> Date: 2015-05-12T13:53:24Z wip
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/curator/pull/81

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/curator/pull/81
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/curator/pull/80

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/curator/pull/80
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user Randgalt opened a pull request:

          https://github.com/apache/curator/pull/81

          CURATOR-217 Use new Watcher Removal APIs in Curator Recipes

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/apache/curator CURATOR-217

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/curator/pull/81.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #81


          commit 9ff9ccd23c8d033b2e7d72b83a0183d05f5dd685
          Author: Cameron McKenzie <cameron@unico.com.au>
          Date: 2014-12-01T22:16:40Z

          CURATOR-161 - Initial cut of remove watches functionality. This provides
          the ability to remove watches, but does not yet provide a framework for
          observers being notified when a watch has been removed.

          commit b2b9af31c181d7e4f790dbfd9f8850a7b948822d
          Author: Cameron McKenzie <cameron@unico.com.au>
          Date: 2014-12-01T22:56:02Z

          CURATOR-161 - Updates to unit tests.

          commit a83090bea7cdd69aa094ddaa9d4a70f401c28861
          Author: Cameron McKenzie <cameron@unico.com.au>
          Date: 2015-05-08T04:05:18Z

          CURATOR-161 - Updates to naming based on review. Added unit test for
          local() case, which has still not been resolved. Need to make changes to
          the framework to allow some ZK calls (local watch removal in this case) to
          occur even if no ZK connection is available.

          commit 4c2ba3744d90f2af12d815e8aa0747fd0d1a1c67
          Author: Cameron McKenzie <cameron@unico.com.au>
          Date: 2015-05-10T23:19:45Z

          CURATOR-161 - Added support for quietly() call that will suppress
          NoWatcherException exceptions.

          commit 58fcc548f87e3c787f82d48931e2e9992f6c3366
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-11T20:29:09Z

          first pass at implementation and a simple test

          commit d3672a5acbd2bdf0f8caa9b7c8ea07e9d4e4dd2a
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-11T21:19:45Z

          wip

          commit 49b2fd3a8313cd05292e2ca8edb4b14b08f0de55
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-11T23:04:01Z

          more tests, refinements

          commit ff8eb4b2ec7c99258e62416453bef649fdc6220e
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-12T01:48:16Z

          more tests

          commit 5030c198456150a82bf2a2a2e5aea75b65b2efc8
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-12T13:53:24Z

          wip


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user Randgalt opened a pull request: https://github.com/apache/curator/pull/81 CURATOR-217 Use new Watcher Removal APIs in Curator Recipes You can merge this pull request into a Git repository by running: $ git pull https://github.com/apache/curator CURATOR-217 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/curator/pull/81.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #81 commit 9ff9ccd23c8d033b2e7d72b83a0183d05f5dd685 Author: Cameron McKenzie <cameron@unico.com.au> Date: 2014-12-01T22:16:40Z CURATOR-161 - Initial cut of remove watches functionality. This provides the ability to remove watches, but does not yet provide a framework for observers being notified when a watch has been removed. commit b2b9af31c181d7e4f790dbfd9f8850a7b948822d Author: Cameron McKenzie <cameron@unico.com.au> Date: 2014-12-01T22:56:02Z CURATOR-161 - Updates to unit tests. commit a83090bea7cdd69aa094ddaa9d4a70f401c28861 Author: Cameron McKenzie <cameron@unico.com.au> Date: 2015-05-08T04:05:18Z CURATOR-161 - Updates to naming based on review. Added unit test for local() case, which has still not been resolved. Need to make changes to the framework to allow some ZK calls (local watch removal in this case) to occur even if no ZK connection is available. commit 4c2ba3744d90f2af12d815e8aa0747fd0d1a1c67 Author: Cameron McKenzie <cameron@unico.com.au> Date: 2015-05-10T23:19:45Z CURATOR-161 - Added support for quietly() call that will suppress NoWatcherException exceptions. commit 58fcc548f87e3c787f82d48931e2e9992f6c3366 Author: randgalt <randgalt@apache.org> Date: 2015-05-11T20:29:09Z first pass at implementation and a simple test commit d3672a5acbd2bdf0f8caa9b7c8ea07e9d4e4dd2a Author: randgalt <randgalt@apache.org> Date: 2015-05-11T21:19:45Z wip commit 49b2fd3a8313cd05292e2ca8edb4b14b08f0de55 Author: randgalt <randgalt@apache.org> Date: 2015-05-11T23:04:01Z more tests, refinements commit ff8eb4b2ec7c99258e62416453bef649fdc6220e Author: randgalt <randgalt@apache.org> Date: 2015-05-12T01:48:16Z more tests commit 5030c198456150a82bf2a2a2e5aea75b65b2efc8 Author: randgalt <randgalt@apache.org> Date: 2015-05-12T13:53:24Z wip
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user Randgalt opened a pull request:

          https://github.com/apache/curator/pull/80

          CURATOR-217 Use new Watcher Removal APIs in Curator Recipes

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/apache/curator CURATOR-217

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/curator/pull/80.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #80


          commit 034e910a907fa89e1c0cd3373fa3bf8ee7759ae6
          Author: Ioannis Canellos <iocanel@gmail.com>
          Date: 2014-11-06T14:53:09Z

          Upgrade to ZooKeeper 3.5.0-alpha.

          commit d4883a845a3778bcad4a776bb18b146f733d8885
          Author: Ioannis Canellos <iocanel@gmail.com>
          Date: 2014-11-06T15:30:29Z

          Update project version to 3.0.0-SNAPSHOT.

          commit 9ff9ccd23c8d033b2e7d72b83a0183d05f5dd685
          Author: Cameron McKenzie <cameron@unico.com.au>
          Date: 2014-12-01T22:16:40Z

          CURATOR-161 - Initial cut of remove watches functionality. This provides
          the ability to remove watches, but does not yet provide a framework for
          observers being notified when a watch has been removed.

          commit b2b9af31c181d7e4f790dbfd9f8850a7b948822d
          Author: Cameron McKenzie <cameron@unico.com.au>
          Date: 2014-12-01T22:56:02Z

          CURATOR-161 - Updates to unit tests.

          commit a83090bea7cdd69aa094ddaa9d4a70f401c28861
          Author: Cameron McKenzie <cameron@unico.com.au>
          Date: 2015-05-08T04:05:18Z

          CURATOR-161 - Updates to naming based on review. Added unit test for
          local() case, which has still not been resolved. Need to make changes to
          the framework to allow some ZK calls (local watch removal in this case) to
          occur even if no ZK connection is available.

          commit 4c2ba3744d90f2af12d815e8aa0747fd0d1a1c67
          Author: Cameron McKenzie <cameron@unico.com.au>
          Date: 2015-05-10T23:19:45Z

          CURATOR-161 - Added support for quietly() call that will suppress
          NoWatcherException exceptions.

          commit 58fcc548f87e3c787f82d48931e2e9992f6c3366
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-11T20:29:09Z

          first pass at implementation and a simple test

          commit d3672a5acbd2bdf0f8caa9b7c8ea07e9d4e4dd2a
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-11T21:19:45Z

          wip

          commit 49b2fd3a8313cd05292e2ca8edb4b14b08f0de55
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-11T23:04:01Z

          more tests, refinements

          commit ff8eb4b2ec7c99258e62416453bef649fdc6220e
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-12T01:48:16Z

          more tests

          commit 5030c198456150a82bf2a2a2e5aea75b65b2efc8
          Author: randgalt <randgalt@apache.org>
          Date: 2015-05-12T13:53:24Z

          wip


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user Randgalt opened a pull request: https://github.com/apache/curator/pull/80 CURATOR-217 Use new Watcher Removal APIs in Curator Recipes You can merge this pull request into a Git repository by running: $ git pull https://github.com/apache/curator CURATOR-217 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/curator/pull/80.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #80 commit 034e910a907fa89e1c0cd3373fa3bf8ee7759ae6 Author: Ioannis Canellos <iocanel@gmail.com> Date: 2014-11-06T14:53:09Z Upgrade to ZooKeeper 3.5.0-alpha. commit d4883a845a3778bcad4a776bb18b146f733d8885 Author: Ioannis Canellos <iocanel@gmail.com> Date: 2014-11-06T15:30:29Z Update project version to 3.0.0-SNAPSHOT. commit 9ff9ccd23c8d033b2e7d72b83a0183d05f5dd685 Author: Cameron McKenzie <cameron@unico.com.au> Date: 2014-12-01T22:16:40Z CURATOR-161 - Initial cut of remove watches functionality. This provides the ability to remove watches, but does not yet provide a framework for observers being notified when a watch has been removed. commit b2b9af31c181d7e4f790dbfd9f8850a7b948822d Author: Cameron McKenzie <cameron@unico.com.au> Date: 2014-12-01T22:56:02Z CURATOR-161 - Updates to unit tests. commit a83090bea7cdd69aa094ddaa9d4a70f401c28861 Author: Cameron McKenzie <cameron@unico.com.au> Date: 2015-05-08T04:05:18Z CURATOR-161 - Updates to naming based on review. Added unit test for local() case, which has still not been resolved. Need to make changes to the framework to allow some ZK calls (local watch removal in this case) to occur even if no ZK connection is available. commit 4c2ba3744d90f2af12d815e8aa0747fd0d1a1c67 Author: Cameron McKenzie <cameron@unico.com.au> Date: 2015-05-10T23:19:45Z CURATOR-161 - Added support for quietly() call that will suppress NoWatcherException exceptions. commit 58fcc548f87e3c787f82d48931e2e9992f6c3366 Author: randgalt <randgalt@apache.org> Date: 2015-05-11T20:29:09Z first pass at implementation and a simple test commit d3672a5acbd2bdf0f8caa9b7c8ea07e9d4e4dd2a Author: randgalt <randgalt@apache.org> Date: 2015-05-11T21:19:45Z wip commit 49b2fd3a8313cd05292e2ca8edb4b14b08f0de55 Author: randgalt <randgalt@apache.org> Date: 2015-05-11T23:04:01Z more tests, refinements commit ff8eb4b2ec7c99258e62416453bef649fdc6220e Author: randgalt <randgalt@apache.org> Date: 2015-05-12T01:48:16Z more tests commit 5030c198456150a82bf2a2a2e5aea75b65b2efc8 Author: randgalt <randgalt@apache.org> Date: 2015-05-12T13:53:24Z wip

            People

            • Assignee:
              randgalt Jordan Zimmerman
              Reporter:
              randgalt Jordan Zimmerman
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development