zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 邢迪侃 <xingdk.a...@gmail.com>
Subject Re: Question about client connection
Date Sat, 14 May 2011 12:40:19 GMT
This way:

class Notifiery
{
public synchronized void Notify()
{
   mNotified = true;
   notify();
}
public synchronized bool Wait(long timeout)
{
   if (mNotified) return true;
   wait(timeout);
   return mNotified;
}
bool mNotified;
}

Notifier n = new Notifier;
zk = new Zookeeper(.....); /// pass "n" to the init watch
bool connected = n.Wait(your_tolerant_timeout);
if (!connected)
{
  zk.close();
  throw something;
}
Inside the init watch, n.Notify() after you see a CONNECTED event.
2011/5/14 Jeremy Sevellec <jeremy.sevellec@sarbacane.com>

> Hi Everyone,
>
> I'm new to Zookeeper and I'm trying to use it to make some distributed
> lock. Globally, It works perfect!
>
> I've got a question about zookeeper client connection to a dead
> zookeeper server .
>
> When I'm doing this connec to to a dead zookeeper server like this (the
> code works fine when the server is up) :
> zooKeeper = new ZooKeeper(....).
>
> The zookeeper client failed to connect but loop infinitely to try to
> connect again and again. Is there any solution to know [catch] that it's
> impossible to connect to a zookeeper server to be abble to make
> something?
>
> Regards,
>
> Jérémy
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message