Tharindu Kumara
Tharindu Kumara

Reputation: 4458

Apache Curator create with retry logic

I like to know whether the create() method in Apache Curator wraps the original Zookeeper create method with retry logic or not?

I have written a bit of code that create a ZNode and I would like to that it is retrying by default. If not what would be the best way to write the create function with retrying capability?

CuratorFramework client = CuratorFrameworkFactory.newClient("0.0.0.0:32770", new RetryUntilElapsed(3000, 1000));
client.start();

try {
     //make sure you're connected to zookeeper.
    client.blockUntilConnected();

     //Make sure the parants are created.
    client.create().creatingParentsIfNeeded().forPath("/larry-smells/foop", "tuna?".getBytes());
} catch (Exception e) {
    System.out.println(e.toString());
}

Upvotes: 1

Views: 579

Answers (1)

Randgalt
Randgalt

Reputation: 2956

All operations in Apache Curator use the retry policy. So, yes, create() uses the retry policy. Note: I'm the main author of Curator.

Upvotes: 2

Related Questions