You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Dan Hopkins <da...@victorops.com> on 2014/03/24 17:01:05 UTC

Basic client question

As a beginner using zookeeper I was wondering if anyone could help me 
understand how the java ZooKeeper client handles a permanent disconnect 
from the cluster. I'm curious because as I read the FAQ we can get a 
Session expiration if we ever connect to the server but I'm not sure 
what to do if I can never connect again.

Is there a different exception thrown after a the client has detected 
permanent failure?

I'm currently using Zk 3.3.4 in case the behavior has changed.

Thanks for any pointers,
Dan

-- 
Dan Hopkins | Programmer
e: danhopkins@victorops.com

Be Victorious


Re: Basic client question

Posted by Camille Fournier <ca...@apache.org>.
There is a connect timeout set automatically in the client based on the
session timeout divided by the number of servers in the cluster. You will
see a SessionTimeout exception if you exceed this connect timeout without
successfully connecting to one of the servers.
I would recommend using a higher-level client than the one that ships with
ZooKeeper, or else you have to build all of this in.
Even if you want to build your own, it would probably be useful reading the
documentation for something like Curator, which explains the choices that
client made to do this:
http://curator.apache.org/curator-client/index.html



On Mon, Mar 24, 2014 at 12:48 PM, Dan Hopkins <da...@victorops.com>wrote:

> Camille,
> I'm trying to figure out what timeout you're referring to? I'm using
> zkClient that ships with ZooKeeper and the only timeout I can see to
> configure is the "session timeout." Does this timeout work even if you
> never hear back from any server?
>
> Thanks,
> Dan
>
>
> On 03/24/2014 10:31 AM, Camille Fournier wrote:
>
>> So, client will never be able to reach the server again? The client that
>> you use (and we generally recommend you use an existing client library
>> like
>> Curator or even zkClient instead of writing your own) should have some
>> sort
>> of timeout configured so that if it gets disconnected and can't reach the
>> server within some period of time it gives up.
>>
>> C
>>
>>
>> On Mon, Mar 24, 2014 at 12:01 PM, Dan Hopkins <da...@victorops.com>
>> wrote:
>>
>>  As a beginner using zookeeper I was wondering if anyone could help me
>>> understand how the java ZooKeeper client handles a permanent disconnect
>>> from the cluster. I'm curious because as I read the FAQ we can get a
>>> Session expiration if we ever connect to the server but I'm not sure what
>>> to do if I can never connect again.
>>>
>>> Is there a different exception thrown after a the client has detected
>>> permanent failure?
>>>
>>> I'm currently using Zk 3.3.4 in case the behavior has changed.
>>>
>>> Thanks for any pointers,
>>> Dan
>>>
>>> --
>>> Dan Hopkins | Programmer
>>> e: danhopkins@victorops.com
>>>
>>> Be Victorious
>>>
>>>
>>>
> --
> Dan Hopkins | Programmer
> e: danhopkins@victorops.com
>
> Be Victorious
>
>

Re: Basic client question

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
 I'm definitely not trying to predict the 
future, only trying to react in the case of an inconsistent cluster and 
cover the pathological cases where ZooKeeper itself is down. The code 
will also rejoin the cluster if it reappears. 
This is what Curator attempts to do. It provides a framework for managing the underlying ZooKeeper connection. You can then write recipes (and Curator comes with many) that take advantage of connection management. There are a bunch of folks using it from Scala (and Clojure for that matter). So, there should be plenty of examples.



-JZ



From: Dan Hopkins danhopkins@victorops.com
Reply: user@zookeeper.apache.org user@zookeeper.apache.org
Date: March 24, 2014 at 12:27:32 PM
To: user@zookeeper.apache.org user@zookeeper.apache.org
Cc: Henry Robinson henry@cloudera.com
Subject:  Re: Basic client question  

Yes, this is a great point. I'm definitely not trying to predict the  
future, only trying to react in the case of an inconsistent cluster and  
cover the pathological cases where ZooKeeper itself is down. The code  
will also rejoin the cluster if it reappears.  

Curator's Framework and Client utils seem like the right tool. My only  
hesitency initially was poor Scala integration, but a thin shim ought  
to be good enough.  

Thanks again Camille & Henry,  
Dan  

On Mon 24 Mar 2014 11:06:55 AM MDT, Henry Robinson wrote:  
> It's also important to realise that 'never' is a property that's impossible  
> to detect. The client has no idea if a failure is permanent, because that  
> would require the ability to see into the future.  
>  
> So the best you can do is guess, somehow, and as Camille says timeouts are  
> the best blunt instrument we have.  
>  
>  
> On 24 March 2014 09:48, Dan Hopkins <da...@victorops.com> wrote:  
>  
>> Camille,  
>> I'm trying to figure out what timeout you're referring to? I'm using  
>> zkClient that ships with ZooKeeper and the only timeout I can see to  
>> configure is the "session timeout." Does this timeout work even if you  
>> never hear back from any server?  
>>  
>> Thanks,  
>> Dan  
>>  
>>  
>> On 03/24/2014 10:31 AM, Camille Fournier wrote:  
>>  
>>> So, client will never be able to reach the server again? The client that  
>>> you use (and we generally recommend you use an existing client library  
>>> like  
>>> Curator or even zkClient instead of writing your own) should have some  
>>> sort  
>>> of timeout configured so that if it gets disconnected and can't reach the  
>>> server within some period of time it gives up.  
>>>  
>>> C  
>>>  
>>>  
>>> On Mon, Mar 24, 2014 at 12:01 PM, Dan Hopkins <da...@victorops.com>  
>>> wrote:  
>>>  
>>> As a beginner using zookeeper I was wondering if anyone could help me  
>>>> understand how the java ZooKeeper client handles a permanent disconnect  
>>>> from the cluster. I'm curious because as I read the FAQ we can get a  
>>>> Session expiration if we ever connect to the server but I'm not sure what  
>>>> to do if I can never connect again.  
>>>>  
>>>> Is there a different exception thrown after a the client has detected  
>>>> permanent failure?  
>>>>  
>>>> I'm currently using Zk 3.3.4 in case the behavior has changed.  
>>>>  
>>>> Thanks for any pointers,  
>>>> Dan  
>>>>  
>>>> --  
>>>> Dan Hopkins | Programmer  
>>>> e: danhopkins@victorops.com  
>>>>  
>>>> Be Victorious  
>>>>  
>>>>  
>>>>  
>> --  
>> Dan Hopkins | Programmer  
>> e: danhopkins@victorops.com  
>>  
>> Be Victorious  
>>  
>>  
>  
>  

--  
Dan Hopkins | Programmer  
e: danhopkins@victorops.com  

Be Victorious  

Re: Basic client question

Posted by Dan Hopkins <da...@victorops.com>.
Yes, this is a great point. I'm definitely not trying to predict the 
future, only trying to react in the case of an inconsistent cluster and 
cover the pathological cases where ZooKeeper itself is down. The code 
will also rejoin the cluster if it reappears.

Curator's Framework and Client utils seem like the right tool. My only 
hesitency initially was poor Scala integration, but a thin shim ought 
to be good enough.

Thanks again Camille & Henry,
Dan

On Mon 24 Mar 2014 11:06:55 AM MDT, Henry Robinson wrote:
> It's also important to realise that 'never' is a property that's impossible
> to detect. The client has no idea if a failure is permanent, because that
> would require the ability to see into the future.
>
> So the best you can do is guess, somehow, and as Camille says timeouts are
> the best blunt instrument we have.
>
>
> On 24 March 2014 09:48, Dan Hopkins <da...@victorops.com> wrote:
>
>> Camille,
>> I'm trying to figure out what timeout you're referring to? I'm using
>> zkClient that ships with ZooKeeper and the only timeout I can see to
>> configure is the "session timeout." Does this timeout work even if you
>> never hear back from any server?
>>
>> Thanks,
>> Dan
>>
>>
>> On 03/24/2014 10:31 AM, Camille Fournier wrote:
>>
>>> So, client will never be able to reach the server again? The client that
>>> you use (and we generally recommend you use an existing client library
>>> like
>>> Curator or even zkClient instead of writing your own) should have some
>>> sort
>>> of timeout configured so that if it gets disconnected and can't reach the
>>> server within some period of time it gives up.
>>>
>>> C
>>>
>>>
>>> On Mon, Mar 24, 2014 at 12:01 PM, Dan Hopkins <da...@victorops.com>
>>> wrote:
>>>
>>>   As a beginner using zookeeper I was wondering if anyone could help me
>>>> understand how the java ZooKeeper client handles a permanent disconnect
>>>> from the cluster. I'm curious because as I read the FAQ we can get a
>>>> Session expiration if we ever connect to the server but I'm not sure what
>>>> to do if I can never connect again.
>>>>
>>>> Is there a different exception thrown after a the client has detected
>>>> permanent failure?
>>>>
>>>> I'm currently using Zk 3.3.4 in case the behavior has changed.
>>>>
>>>> Thanks for any pointers,
>>>> Dan
>>>>
>>>> --
>>>> Dan Hopkins | Programmer
>>>> e: danhopkins@victorops.com
>>>>
>>>> Be Victorious
>>>>
>>>>
>>>>
>> --
>> Dan Hopkins | Programmer
>> e: danhopkins@victorops.com
>>
>> Be Victorious
>>
>>
>
>

--
Dan Hopkins | Programmer
e: danhopkins@victorops.com

Be Victorious

Re: Basic client question

Posted by Henry Robinson <he...@cloudera.com>.
It's also important to realise that 'never' is a property that's impossible
to detect. The client has no idea if a failure is permanent, because that
would require the ability to see into the future.

So the best you can do is guess, somehow, and as Camille says timeouts are
the best blunt instrument we have.


On 24 March 2014 09:48, Dan Hopkins <da...@victorops.com> wrote:

> Camille,
> I'm trying to figure out what timeout you're referring to? I'm using
> zkClient that ships with ZooKeeper and the only timeout I can see to
> configure is the "session timeout." Does this timeout work even if you
> never hear back from any server?
>
> Thanks,
> Dan
>
>
> On 03/24/2014 10:31 AM, Camille Fournier wrote:
>
>> So, client will never be able to reach the server again? The client that
>> you use (and we generally recommend you use an existing client library
>> like
>> Curator or even zkClient instead of writing your own) should have some
>> sort
>> of timeout configured so that if it gets disconnected and can't reach the
>> server within some period of time it gives up.
>>
>> C
>>
>>
>> On Mon, Mar 24, 2014 at 12:01 PM, Dan Hopkins <da...@victorops.com>
>> wrote:
>>
>>  As a beginner using zookeeper I was wondering if anyone could help me
>>> understand how the java ZooKeeper client handles a permanent disconnect
>>> from the cluster. I'm curious because as I read the FAQ we can get a
>>> Session expiration if we ever connect to the server but I'm not sure what
>>> to do if I can never connect again.
>>>
>>> Is there a different exception thrown after a the client has detected
>>> permanent failure?
>>>
>>> I'm currently using Zk 3.3.4 in case the behavior has changed.
>>>
>>> Thanks for any pointers,
>>> Dan
>>>
>>> --
>>> Dan Hopkins | Programmer
>>> e: danhopkins@victorops.com
>>>
>>> Be Victorious
>>>
>>>
>>>
> --
> Dan Hopkins | Programmer
> e: danhopkins@victorops.com
>
> Be Victorious
>
>


-- 
Henry Robinson
Software Engineer
Cloudera
415-994-6679

Re: Basic client question

Posted by Dan Hopkins <da...@victorops.com>.
Camille,
I'm trying to figure out what timeout you're referring to? I'm using 
zkClient that ships with ZooKeeper and the only timeout I can see to 
configure is the "session timeout." Does this timeout work even if you 
never hear back from any server?

Thanks,
Dan

On 03/24/2014 10:31 AM, Camille Fournier wrote:
> So, client will never be able to reach the server again? The client that
> you use (and we generally recommend you use an existing client library like
> Curator or even zkClient instead of writing your own) should have some sort
> of timeout configured so that if it gets disconnected and can't reach the
> server within some period of time it gives up.
>
> C
>
>
> On Mon, Mar 24, 2014 at 12:01 PM, Dan Hopkins <da...@victorops.com>wrote:
>
>> As a beginner using zookeeper I was wondering if anyone could help me
>> understand how the java ZooKeeper client handles a permanent disconnect
>> from the cluster. I'm curious because as I read the FAQ we can get a
>> Session expiration if we ever connect to the server but I'm not sure what
>> to do if I can never connect again.
>>
>> Is there a different exception thrown after a the client has detected
>> permanent failure?
>>
>> I'm currently using Zk 3.3.4 in case the behavior has changed.
>>
>> Thanks for any pointers,
>> Dan
>>
>> --
>> Dan Hopkins | Programmer
>> e: danhopkins@victorops.com
>>
>> Be Victorious
>>
>>

-- 
Dan Hopkins | Programmer
e: danhopkins@victorops.com

Be Victorious


Re: Basic client question

Posted by Camille Fournier <ca...@apache.org>.
So, client will never be able to reach the server again? The client that
you use (and we generally recommend you use an existing client library like
Curator or even zkClient instead of writing your own) should have some sort
of timeout configured so that if it gets disconnected and can't reach the
server within some period of time it gives up.

C


On Mon, Mar 24, 2014 at 12:01 PM, Dan Hopkins <da...@victorops.com>wrote:

> As a beginner using zookeeper I was wondering if anyone could help me
> understand how the java ZooKeeper client handles a permanent disconnect
> from the cluster. I'm curious because as I read the FAQ we can get a
> Session expiration if we ever connect to the server but I'm not sure what
> to do if I can never connect again.
>
> Is there a different exception thrown after a the client has detected
> permanent failure?
>
> I'm currently using Zk 3.3.4 in case the behavior has changed.
>
> Thanks for any pointers,
> Dan
>
> --
> Dan Hopkins | Programmer
> e: danhopkins@victorops.com
>
> Be Victorious
>
>