courator - create

Posted xiaobin-hlj80

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了courator - create相关的知识,希望对你有一定的参考价值。

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-frameworksrcmainjavaorgapachecuratorframeworkCuratorFramework.java)

 

2.create

curator-frameworksrcmainjavaorgapachecuratorframework
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的主要内容,如果未能解决你的问题,请参考以下文章

Laravel:如何在控制器的几种方法中重用代码片段

持久片段和查看器

在片段中单击按钮播放声音(Kotlin)[重复]

text 此片段用于以下知识库文章 - http://kb.wpbeaverbuilder.com/article/591-create-a-filter-to-customize-the-di

如何删除导航抽屉?

片段后面的不可见布局被点击: