maven配置:
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>2.6.0</version>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>2.6.0</version>
<type>jar</type>
</dependency>
代码:
创建客户端:
CuratorFramework curator= CuratorFrameworkFactory.builder()
.connectString("")
.sessionTimeoutMs(10000)
.retryPolicy(retryPolicy)
.build();
参数解释:
RetryPolicy详解:
继承关系:
ExponentialBackoffRetry:
RetryNTimes & RetryOneTime:
RetryUntilElapsed: