curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cameron McKenzie <mckenzie....@gmail.com>
Subject Re: how to avoid keep trying to connect with zk with curator
Date Wed, 02 Mar 2016 20:49:47 GMT
hey Ratan,
You don't need to call blockUntilConnected. You can just call start() and
it will handle connection establishment etc. in the background. Obviously,
none of your operations will succeed until you have a connection.
cheers

On Wed, Mar 2, 2016 at 5:21 PM, RATAN KUMAR YADAV <ratangzp@gmail.com>
wrote:

> Hi Team,
>
>
> I am creating zk connection with curator , which keep retry to connect with
> zookeeper if it not available and blocking my application .
> Is there any way to stop this infinite loop to retry. I am getting below
> exception per second and which keep going after calling of client.start().
>
> java.net.ConnectException: Connection refused
>     at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
>     at
> sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
>     at
>
> org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
>     at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
>
> Below code I am using:
> final RetryPolicy retryPolicy = new ExponentialBackoffRetry(
> BASE_SLEEP_TIME_MS, MAX_RETRIES );
>             client = CuratorFrameworkFactory.newClient( CONNECTION_STRING,
> retryPolicy );
>
>             client.blockUntilConnected( 5, TimeUnit.SECONDS );
>             client.start();
>
>
> Thanks,
> Ratan
>

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