curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alvaro Gareppe <agare...@gmail.com>
Subject Re: PathChildrenCache creates the node if not present
Date Thu, 21 Jul 2016 18:45:41 GMT
This is the case:
There is not evan a listener defined ( not needed to reproduce the problem)
If you see there.. the "Curator-TreeCache-0" is running even the tc.close()
is already called.
This code runs forever,

*package* com.sac.panorama.zookeeper.examples;



*import* java.util.Set;



*import* org.apache.curator.framework.CuratorFramework;

*import* org.apache.curator.framework.CuratorFrameworkFactory;

*import* org.apache.curator.framework.recipes.cache.TreeCache;

*import* org.apache.curator.retry.RetryForever;



*import*
 com.sac.panorama.zookeeper.server.junitserver.ZookeeperTestingServer;



*public* *class* DataWatcherCuratorExample {



    *public* *static* *void* main(String[] args) *throws* Exception {

        ZookeeperTestingServer zk;

        zk = *new* ZookeeperTestingServer();

        zk.doStart();

        CuratorFramework connection = CuratorFrameworkFactory.*newClient*(zk
.getConnectString(),

                        *new* RetryForever(10000));



        connection.start();





        connection.create().forPath("/test");

        TreeCache tc = TreeCache.*newBuilder*(connection, "/test"
).setCacheData(*false*).setMaxDepth(1)

                        .setCreateParentNodes(*false*).build();



        *if* (*isThreadRunning*()) {

            *throw* *new* RuntimeException("");  // this is not thrown [OK]

        }



        tc.start();



        tc.close();



        System.*out*.println();



        *while*(*isThreadRunning*()) {  // this runns forever cause the
thread "Curator-TreeCache" is not stopped after close

            Thread.*sleep*(1000);

            System.*out*.println("");

        }



        connection.close();

    }



    *private* *static* *boolean* isThreadRunning() {

        Set<Thread> runningThreads = Thread.*getAllStackTraces*().keySet();

        *boolean* threadFound = *false*;

        *for* (Thread thread : runningThreads) {

            *if* (thread.getName().startsWith("Curator-TreeCache") &&
thread.isAlive())
{

                threadFound = *true*;

            }

        }

        *return* threadFound;

    }

}

On Thu, Jul 21, 2016 at 2:48 PM, Scott Blum <dragonsinth@gmail.com> wrote:

> What's the thread doing?  Can you grab a stack trace to see where it's
> hung?
> That thread is only used to publish events out to clients, maybe the
> thread is hung in client code?
>
> On Thu, Jul 21, 2016 at 9:26 AM, Alvaro Gareppe <agareppe@gmail.com>
> wrote:
>
>> I just did the upgrate to the version 2.11 and the issue is still there.
>> I still see the Curator-TreeCache-X after the TreeCache is closed.
>> Any ideas ?
>>
>> On Thu, Jul 21, 2016 at 9:22 AM, Alvaro Gareppe <agareppe@gmail.com>
>> wrote:
>>
>>> Do you know if there is a thread issue with the TreeCache? Cause after I
>>> call cache.close() the Curator-TreeCache-X thread is still alive.
>>>
>>> On Tue, Jul 19, 2016 at 1:33 PM, Alvaro Gareppe <agareppe@gmail.com>
>>> wrote:
>>>
>>>> I changed the PathChildrenCache to TreeCache depth=1 and worked OK.
>>>>
>>>> Thanks guys!
>>>>
>>>> On Fri, Jul 15, 2016 at 6:03 PM, Scott Blum <dragonsinth@gmail.com>
>>>> wrote:
>>>>
>>>>> TreeCache is read-only unless you specifically ask it to create the
>>>>> root node.  Use depth=1 to watch only a single node.
>>>>>
>>>>> On Thu, Jul 14, 2016 at 5:46 PM, Cameron McKenzie <
>>>>> cammckenzie@apache.org> wrote:
>>>>>
>>>>>> I don't have the code handy, but have you tried TreeCache?
>>>>>>
>>>>>> On 14 Jul 2016 11:31 PM, "Alvaro Gareppe" <agareppe@gmail.com>
wrote:
>>>>>>
>>>>>>> Is there a way to avoid the node creation on PathChildrenCache
>>>>>>> start() ?
>>>>>>>
>>>>>>> I have this case
>>>>>>>
>>>>>>> 1.- There is no node in ZK
>>>>>>> 2.- I do this:
>>>>>>>          cp = new PathChildrenCache(conn, "/a",
>>>>>>> PathChildrenCache.CACHE_PATH_ONLY);
>>>>>>>          cp.start()
>>>>>>> 3.- now I have a node /a in ZK
>>>>>>>
>>>>>>> Im using the pathCache in a different thread (and possibly different
>>>>>>> server) of the node creation, so I would like to have an option
where the
>>>>>>> node is not created, so it does nothing or throws and exception
in that
>>>>>>> case (both works for me).
>>>>>>>
>>>>>>> Is there some way to configure the PathChildrenCache to do so
?
>>>>>>>
>>>>>>> I'm using curator version: 2.9.1
>>>>>>>
>>>>>>> --
>>>>>>> Ing. Alvaro Gareppe
>>>>>>> agareppe@gmail.com
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Ing. Alvaro Gareppe
>>>> agareppe@gmail.com
>>>>
>>>
>>>
>>>
>>> --
>>> Ing. Alvaro Gareppe
>>> agareppe@gmail.com
>>>
>>
>>
>>
>> --
>> Ing. Alvaro Gareppe
>> agareppe@gmail.com
>>
>
>


-- 
Ing. Alvaro Gareppe
agareppe@gmail.com

Mime
View raw message