ElasticSearch源碼分析(一):源碼調(diào)試環(huán)境搭建(將ElasticSearch源碼導(dǎo)入IDEA)
? 本源碼閱讀環(huán)境是基于ElasticSearch 7.8.0版本虐急,此版本需要IDEA版本至少為2020.1版
一箱残、 準(zhǔn)備工作:
- 下載ElasticSearch 7.8.0 源碼
- 下載ElasticSearch 7.8.0發(fā)行版
- 安裝Gradle(最低版本要求詳見源代碼: ~/buildSrc/src/main/resources: minimumCompilerVersion、minimumGradleVersion止吁、minimumRuntimeVersion)
- 查看本機(jī)JDK版本(7.8.0編譯JDK版本最低為14)
二被辑、 導(dǎo)入IDEA (CONTRIBUTING.md)
### Importing the project into IntelliJ IDEA Elasticsearch builds using Java 14. When importing into IntelliJ you will need to define an appropriate SDK. The convention is that **this SDK should be named "14"** so that the project import will detect it automatically. For more details on defining an SDK in IntelliJ please refer to [their documentation](https://www.jetbrains.com/help/idea/sdk.html#define-sdk). SDK definitions are global, so you can add the JDK from any project, or after project import. Importing with a missing JDK will still work, IntelliJ will simply report a problem and will refuse to build until resolved. You can import the Elasticsearch project into IntelliJ IDEA via: - Select **File > Open** - In the subsequent dialog navigate to the root `build.gradle` file - In the subsequent dialog select **Open as Project**
三、 本地運(yùn)行/調(diào)試配置
配置以下JVM參數(shù):
-Des.path.conf=/Users/xuxl/Library/elasticsearch/elasticsearch-7.8.0/config
-Des.path.home=/Users/xuxl/Library/elasticsearch/elasticsearch-7.8.0
-Djava.security.policy=/Users/xuxl/Library/elasticsearch/elasticsearch-7.8.0/config/elasticsearch.policy
-Xms2g
-Xmx2g
-Dlog4j2.disable.jmx=true
-Des.path.plugins=/Users/xuxl/Library/elasticsearch/elasticsearch-7.8.0/plugins
配置 elasticsearch.policy文件(在elasticsearch-home/conf/創(chuàng)建文件)敬惦,內(nèi)容如下:
grant{
permission javax.management.MBeanTruxtPermission "register";
permission javax.management.MBeanServerPermission "createMBeanServer";
permission java.lang.RuntimePermission "createClassLoader";
};
源碼文件server模塊中build.gradle中修改
compileOnly project(':libs:elasticsearch-plugin-classloader') ---》 compile project(':libs:elasticsearch-plugin-classloader')
ps:
需要配置node.name盼理!