美文网首页
ElasticSearch 源码分析技巧

ElasticSearch 源码分析技巧

作者: 秦汉邮侠 | 来源:发表于2019-07-13 16:35 被阅读0次

    技巧

    • image.png

    建立索引流程

    • AbstractClient#index:420
    //client的入口,明确知道是要创建索引
        @Override
        public void index(final IndexRequest request, final ActionListener<IndexResponse> listener) {
            execute(IndexAction.INSTANCE, request, listener);
        }
    
    • NodeClient#executeLocally:83
    //NodeClient继承AbstractClient,完成action到transportAction的转换,NodeClient维护了一个map
    //map的映射关系在ActionModule#setupActions中
        public <    Request extends ActionRequest,
                    Response extends ActionResponse
                > Task executeLocally(GenericAction<Request, Response> action, Request request, ActionListener<Response> listener) {
            return transportAction(action).execute(request, listener);
        }
    

    TransportAction#execute:72

    //该实例是TransportIndexAction
     public final Task execute(Request request, ActionListener<Response> listener) {
    
            Task task = taskManager.register("transport", actionName, request);
            if (task == null) {
                execute(null, request, listener);
            } else {
                execute(task, request, new ActionListener<Response>() {
                   ...
                });
            }
            return task;
        }
    

    * TransportAction类结构

    image.png

    相关文章

      网友评论

          本文标题:ElasticSearch 源码分析技巧

          本文链接:https://www.haomeiwen.com/subject/stmukctx.html