• courator


    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();

  • 相关阅读:
    php学习之Model类
    PHP学习之图像处理-水印类
    PHP学习之文件上传类
    windows 安装gitea
    下载安装office2019
    第6章 互联网的那些事儿
    第五章 了解你的用户
    第四章 关于测试的一些思考
    第三章 web设计原则:
    第二章 编程之道
  • 原文地址:https://www.cnblogs.com/xiaobin-hlj80/p/9655078.html
Copyright © 2020-2023  润新知