码迷,mamicode.com
首页 > 其他好文 > 详细

courator - create

时间:2018-09-16 12:33:04      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:nbsp   lead   code   actor   default   art   ssi   string   col   

0. retry policy

    

RetryPolicy retryPolicy  = new ExponentialBackoffRetry(3000,3);

 

1. client

    1) recipes

  • org.apache.curator.framework.recipes.leader.LeaderSelector
  • org.apache.curator.framework.recipes.cache.TreeCache
  • org.apache.curator.framework.recipes.cache.PathChildrenCache
  • org.apache.curator.x.discovery.ServiceDiscovery

 

    2) CuratorFramework

  • org.apache.curator.framework.CuratorFramework

       (curator-framework\src\main\java\org\apache\curator\framework\CuratorFramework.java)

 

2.create

curator-framework\src\main\java\org\apache\curator\framework
CuratorFrameworkFactory.java

1) simple

default:

CuratorFramework newClient(String connectString, RetryPolicy retryPolicy);

 

client.newClient("tdtc101:2181, tdtc102:2181, tdtc103:2181", retryPolicy);

 


advanced:

CuratorFramework newClient(String connectString, int sessionTimeoutMs, int connectionTimeoutMs, RetryPolicy retryPolicy);

 

client.newClient("tdtc101:2181, tdtc102:2181, tdtc103:2181", 60 * 1000, 15 * 1000, retryPolicy);

 

2) Fluent style

default:

client = CuratorFrameworkFactory.builder()
.connectString("tdtc101:2181, tdtc102:2181, tdtc103:2181")
.retryPolicy(retryPolicy)
.build();



advanced:

client = CuratorFrameworkFactory.builder()
.connectString("tdtc101:2181, tdtc102:2181, tdtc103:2181")
.sessionTimeoutMs(60 * 1000) // CuratorFrameworkFactory.java Ln61
.connectionTimeoutMs(15 * 1000) // CuratorFrameworkFactory.java Ln62
.retryPolicy(retryPolicy)
.build();

 

3. start

    client.start();

 

courator - create

标签:nbsp   lead   code   actor   default   art   ssi   string   col   

原文地址:https://www.cnblogs.com/xiaobin-hlj80/p/9655078.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!