curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From RATAN KUMAR YADAV <ratan...@gmail.com>
Subject how to avoid keep trying to connect with zk with curator
Date Wed, 02 Mar 2016 06:21:09 GMT
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