In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
ES plug-ins are needed in development, and ES plug-ins need to understand the internal structure of ES, so start learning the source code of ES again. On the one hand, understand the routines of plug-in development, on the other hand, understand the implementation details of the get interface.
Understand the principle of ES, the source code is the best supplement to the document. The source code is even more helpful in understanding the inner core of ES than the documentation.
First, clone the source code from git:
Git clone https://github.com/elastic/elasticsearch.gitcd elasticsearchgit tag-lgit checkout v2.4.5sh run.sh
If you do not succeed in using run.sh, try again, it is possible that maven's jar package was not downloaded.
V2.4.5 is used here because the relevant jar package is used in the process of compiling es, and https://oss.sonatype.org/content/repositories/snapshots/org/elasticsearch/rest-api-spec/ is not available in all versions of jar package, so v2.4.5 is selected, which is the same as choosing a phone number, which is purely subjective.
Here, the JDK will be changed to 1.8,1.7 jdk maven will report a protocol_verson error.
After the compilation is successful, the zip package for elasticsearch is generated and needs to be unzipped because the conf file is used in the source code.
Cd / home/shgy/es_workspace/elasticsearch/distribution/zip/target/releases/unzip elasticsearch-2.4.5-SNAPSHOT.zip mv elasticsearch-2.4.5-SNAPSHOT / opt/
After the compilation is completed, import the source code into intellij, and the startup parameters of intellij
Vm options:-Des.path.home=/opt/elasticsearch-2.4.5-SNAPSHOTProgram arguments: start
Use after successful startup
Curl http://localhost:9200
You can see the classic
{"name": "Ruckus", "cluster_name": "elasticsearch", "cluster_uuid": "ZIl7g86YRiGv8Dqz4DCoAQ", "version": {"number": "2.4.5", "build_hash": "c849dd13904f53e63e88efc33b2ceeda0b6a1276", "build_timestamp": "2018-08-12T01:30:55Z", "build_snapshot": true, "lucene_version": "5.5.4"} "tagline": "You Know, for Search"}
After booting successfully from the source code, there are many things you can do. For example, take a look at You Know, where for Search comes from, and how ES works inside index/get/search and other interfaces.
More importantly, you can apply the logic of the relevant interfaces to develop plugin to implement your own business logic.
After starting es as debug, the first breakpoint can be hit at org.elasticsearch.http.netty.HttpRequestHandler.messageReceived (), which is the programming mode of netty.
For example, You Know and for Search. Through debug, you can learn that the call chain is:
HttpRequestHandler.messageReceived ()-RestMainAction.handleRequest ()
Rest_xxx_Action is a common routine for all http interfaces of es. For example:
RestSearchAction _ searchRestGetAction / {index} / {type} / {id} RestIndexAction / {index} / {type} / {id}.
It can be said that Rest_xxx_Action is the shell of es, and the structure of the entire ES is roughly shown in the following figure:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.