技巧
- 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
网友评论