zoukankan      html  css  js  c++  java
  • elasticSearch6源码分析(7)node

    1.node概述

    Any time that you start an instance of Elasticsearch, you are starting a node. A collection of connected nodes is called a cluster. If you are running a single node of Elasticsearch, then you have a cluster of one node.
    
    Every node in the cluster can handle HTTP and Transport traffic by default. The transport layer is used exclusively for communication between nodes and the Java TransportClient; the HTTP layer is used only by external REST clients.
    
    All nodes know about all the other nodes in the cluster and can forward client requests to the appropriate node. Besides that, each node serves one or more purpose:
    
    Master-eligible node
    A node that has node.master set to true (default), which makes it eligible to be elected as the master node, which controls the cluster.
    Data node
    A node that has node.data set to true (default). Data nodes hold data and perform data related operations such as CRUD, search, and aggregations.
    Ingest node
    A node that has node.ingest set to true (default). Ingest nodes are able to apply an ingest pipeline to a document in order to transform and enrich the document before indexing. With a heavy ingest load, it makes sense to use dedicated ingest nodes and to mark the master and data nodes as node.ingest: false.
    Tribe node
    A tribe node, configured via the tribe.* settings, is a special type of coordinating only node that can connect to multiple clusters and perform search and other operations across all connected clusters.
    By default a node is a master-eligible node and a data node, plus it can pre-process documents through ingest pipelines. This is very convenient for small clusters but, as the cluster grows, it becomes important to consider separating dedicated master-eligible nodes from dedicated data nodes.

    2.配置Node类

    /**
     * A node represent a node within a cluster ({@code cluster.name}). The {@link #client()} can be used
     * in order to use a {@link Client} to perform actions/operations against the cluster.
     */
    
        public static final Setting<Boolean> WRITE_PORTS_FILE_SETTING =
            Setting.boolSetting("node.portsfile", false, Property.NodeScope);
        public static final Setting<Boolean> NODE_DATA_SETTING = Setting.boolSetting("node.data", true, Property.NodeScope);
        public static final Setting<Boolean> NODE_MASTER_SETTING =
            Setting.boolSetting("node.master", true, Property.NodeScope);
        public static final Setting<Boolean> NODE_INGEST_SETTING =
            Setting.boolSetting("node.ingest", true, Property.NodeScope);

    3.node通信 :NodeClient.java

        private <    Request extends ActionRequest,
                    Response extends ActionResponse
                > TransportAction<Request, Response> transportAction(Action<Response> action) {
            if (actions == null) {
                throw new IllegalStateException("NodeClient has not been initialized");
            }
            TransportAction<Request, Response> transportAction = actions.get(action);
            if (transportAction == null) {
                throw new IllegalStateException("failed to find action [" + action + "] to execute");
            }
            return transportAction;
        }

    4.TransportAction.java(node之间通信,走tcp)

        /**
         * Execute the transport action on the local node, returning the {@link Task} used to track its execution and accepting a
         * {@link TaskListener} which listens for the completion of the action.
         */
        public final Task execute(Request request, TaskListener<Response> listener) {
            Task task = taskManager.register("transport", actionName, request);
            execute(task, request, new ActionListener<Response>() {
                @Override
                public void onResponse(Response response) {
                    if (task != null) {
                        taskManager.unregister(task);
                    }
                    listener.onResponse(task, response);
                }
    
                @Override
                public void onFailure(Exception e) {
                    if (task != null) {
                        taskManager.unregister(task);
                    }
                    listener.onFailure(task, e);
                }
            });
            return task;
        }
  • 相关阅读:
    NGUI 3.5课程(五岁以下儿童)button-图片切换
    跑openstack命令错误【You must provide a username via either -...】
    angular cors跨域资源共享设置 和formdata设定
    PHP 如何获取客户端ip地址
    JavaScript如何生成思维导图(mindmap)
    百度ueditor上传图片时如何设置默认宽高度
    英语发音规则---E字母常见的发音组合有哪些
    google搜索引擎爬虫爬网站原理
    legend2---开发日志10(ajax请求的方法是否同样会执行base控制器里面的方法)
    JS中如何判断对象是对象还是数组
  • 原文地址:https://www.cnblogs.com/davidwang456/p/10114434.html
Copyright © 2011-2022 走看看