zoukankan      html  css  js  c++  java
  • ElasticSearch(一) Transport Client

    Transport  Client 通过远程连接到Es 集群,他不加入集群,只是通过集群nodes 的 transportAddress 和集群通信。

    一  如何通过集群域名获得集群nodes的transportAddress

    http://xxx.com/_cat/nodes?h=ip,port

    http://xxx.com/_nodes/transport

    二 TransportClient 初始化方式

    // on startup
    
    TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
            .addTransportAddress(new TransportAddress(InetAddress.getByName("host1"), 9300)) //9300 为nodes 默认的端口,请使用实际 端口号
            .addTransportAddress(new TransportAddress(InetAddress.getByName("host2"), 9300));
    
    // on shutdown
    
    client.close();

    三 TransportClient 动态加入node

    Settings settings = Settings.builder()
            .put("client.transport.sniff", true)   //嗅探 默认每5s去更新下集群新的节点,加入新节点,去掉坏节点
    .put("cluster.name", "myClusterName") //集群名称
    .build();

    TransportClient client = new PreBuiltTransportClient(settings);

    四 Settings 其他参数

    可通过设置 client.transport.nodes_sampler_interval 来改变轮询集群节点连接的频率。
    ParameterDescription

    client.transport.ignore_cluster_name

    Set to true to ignore cluster name validation of connected nodes. (since 0.19.4)

    client.transport.ping_timeout

    The time to wait for a ping response from a node. Defaults to 5s.

    client.transport.nodes_sampler_interval

    How often to sample / ping the nodes listed and connected. Defaults to 5s.


    官方文档:https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html

  • 相关阅读:
    nasm astrstr函数 x86
    nasm astrspn函数 x86
    nasm astrset_s函数 x86
    nasm astrrev函数 x86
    模板:最长公共子序列(LCS)
    模板:最小生成树(MST)
    模板:并查集
    模板:单源最短路径
    模板:最近公共祖先(LCA)
    模板:线段树(1)——加法,求和
  • 原文地址:https://www.cnblogs.com/xiaocandou/p/8016340.html
Copyright © 2011-2022 走看看