From 9b408e82d5c7feeb49091f74316f71ce41eff64b Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Thu, 21 Nov 2019 09:26:23 +0800 Subject: [PATCH] [Feature] Support ElasticSearch 7 as backend storage (#3870) * [Feature] Officially support ElasticSearch 7 as backend storage * Extract bootstrap module to be shared by multiple starters * Add missing configuration file and distinguish different version in test * Update known-oap-backend-dependencies-es7.txt Update the dependency lib * Fix missing adaptation to ElasticSearch 7 * Rename ElasticSearch 7 specific class with Es7 infix * Fix miss-adapted ElasticSearch DAO API * Add ES7 specific configuration and polish documentations * Polish documentations * Polish documentations --- Jenkinsfile | 1 - Jenkinsfile-E2E | 12 + apm-dist/pom.xml | 37 ++- apm-dist/release-docs/LICENSE | 1 + .../main/assembly/alarm-settings-sample.yml | 0 .../src/main/assembly/alarm-settings.yml | 0 .../src/main/assembly/application.yml | 22 ++ apm-dist/src/main/assembly/binary-es7.xml | 105 +++++++ apm-dist/src/main/assembly/binary.xml | 19 ++ .../src/main/assembly/log4j2.xml | 0 docs/en/setup/backend/backend-storage.md | 48 ++- oap-server/pom.xml | 2 + oap-server/server-bootstrap/pom.xml | 234 +++++++++++++++ .../server/starter/OAPServerBootstrap.java | 63 ++++ .../config/ApplicationConfigLoader.java | 0 .../config/ConfigFileNotFoundException.java | 0 .../server/starter/config/ConfigLoader.java | 0 .../src/main/resources/alarm-settings.yml | 0 .../src/main/resources/application.yml | 27 +- .../main/resources/component-libraries.yml | 0 .../endpoint_naming_rules.properties | 0 .../src/main/resources}/gateways.yml | 0 .../src/main/resources/log4j2.xml | 0 .../src/main/resources/official_analysis.oal | 0 .../ApplicationConfigLoaderTestCase.java | 0 .../src/test/resources/application.yml | 0 .../elasticsearch/ElasticSearchClient.java | 107 +++---- .../elasticsearch/ITElasticSearchClient.java | 41 ++- oap-server/server-starter-es7/pom.xml | 72 +++++ .../src/main/assembly/assembly.xml | 33 +++ .../oap/server/starter/OAPServerStartUp.java | 30 ++ oap-server/server-starter/pom.xml | 196 +------------ .../src/main/assembly/assembly.xml | 21 -- .../oap/server/starter/OAPServerStartUp.java | 33 +-- oap-server/server-storage-plugin/pom.xml | 1 + .../elasticsearch/base/MetricsEsDAO.java | 10 +- .../elasticsearch/base/RecordEsDAO.java | 2 +- .../elasticsearch/base/RegisterEsDAO.java | 2 +- .../base/StorageEsInstaller.java | 79 ++--- .../elasticsearch/base/TimeSeriesUtils.java | 2 +- .../cache/EndpointInventoryCacheEsDAO.java | 2 +- .../NetworkAddressInventoryCacheEsDAO.java | 4 +- .../ServiceInstanceInventoryCacheDAO.java | 2 +- .../cache/ServiceInventoryCacheEsDAO.java | 4 +- .../lock/RegisterLockInstaller.java | 40 +-- .../query/AggregationQueryEsDAO.java | 23 +- .../query/MetadataQueryEsDAO.java | 2 +- .../query/MetricsQueryEsDAO.java | 2 +- .../storage-elasticsearch7-plugin/pom.xml | 55 ++++ .../storage/plugin/elasticsearch7/Es7DAO.java | 31 ++ .../StorageModuleElasticsearch7Config.java | 36 +++ .../StorageModuleElasticsearch7Provider.java | 164 +++++++++++ .../base/StorageEs7Installer.java | 66 +++++ .../cache/EndpointInventoryCacheEs7DAO.java | 62 ++++ .../NetworkAddressInventoryCacheEs7DAO.java | 61 ++++ .../ServiceInstanceInventoryCacheEs7DAO.java | 62 ++++ .../cache/ServiceInventoryCacheEs7DAO.java | 61 ++++ .../client/ElasticSearch7Client.java | 277 ++++++++++++++++++ .../client/ElasticSearch7InsertRequest.java | 40 +++ .../client/ElasticSearch7UpdateRequest.java | 38 +++ .../elasticsearch7/dao/MetricsEs7DAO.java | 54 ++++ .../elasticsearch7/dao/StorageEs7DAO.java | 54 ++++ .../lock/RegisterLockEs77DAOImpl.java | 79 +++++ .../lock/RegisterLockEs7Installer.java | 57 ++++ .../query/AggregationQueryEs7DAO.java | 89 ++++++ .../query/AlarmQueryEs7DAO.java | 93 ++++++ .../elasticsearch7/query/LogQueryEs7DAO.java | 122 ++++++++ .../query/MetadataQueryEs7DAO.java | 86 ++++++ .../query/MetricsQueryEs7DAO.java | 112 +++++++ .../query/TraceQueryEs7DAO.java | 140 +++++++++ ...g.oap.server.library.module.ModuleProvider | 19 ++ pom.xml | 1 + test/e2e/e2e-cluster/test-runner/pom.xml | 3 +- .../test-runner/src/docker/clusterize.awk | 6 +- test/e2e/e2e-ttl/e2e-ttl-es/pom.xml | 3 +- .../e2e-ttl-es/src/docker/es_storage.awk | 6 +- test/e2e/run.sh | 18 +- tools/dependencies/check-LICENSE.sh | 14 + .../known-oap-backend-dependencies-es7.txt | 158 ++++++++++ 79 files changed, 2928 insertions(+), 418 deletions(-) rename {oap-server/server-starter => apm-dist}/src/main/assembly/alarm-settings-sample.yml (100%) rename {oap-server/server-starter => apm-dist}/src/main/assembly/alarm-settings.yml (100%) rename {oap-server/server-starter => apm-dist}/src/main/assembly/application.yml (85%) create mode 100644 apm-dist/src/main/assembly/binary-es7.xml rename {oap-server/server-starter => apm-dist}/src/main/assembly/log4j2.xml (100%) create mode 100644 oap-server/server-bootstrap/pom.xml create mode 100644 oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerBootstrap.java rename oap-server/{server-starter => server-bootstrap}/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java (100%) rename oap-server/{server-starter => server-bootstrap}/src/main/java/org/apache/skywalking/oap/server/starter/config/ConfigFileNotFoundException.java (100%) rename oap-server/{server-starter => server-bootstrap}/src/main/java/org/apache/skywalking/oap/server/starter/config/ConfigLoader.java (100%) rename oap-server/{server-starter => server-bootstrap}/src/main/resources/alarm-settings.yml (100%) rename oap-server/{server-starter => server-bootstrap}/src/main/resources/application.yml (83%) rename oap-server/{server-starter => server-bootstrap}/src/main/resources/component-libraries.yml (100%) rename oap-server/{server-starter => server-bootstrap}/src/main/resources/endpoint_naming_rules.properties (100%) rename oap-server/{server-starter/src/main/assembly => server-bootstrap/src/main/resources}/gateways.yml (100%) rename oap-server/{server-starter => server-bootstrap}/src/main/resources/log4j2.xml (100%) rename oap-server/{server-starter => server-bootstrap}/src/main/resources/official_analysis.oal (100%) rename oap-server/{server-starter => server-bootstrap}/src/test/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoaderTestCase.java (100%) rename oap-server/{server-starter => server-bootstrap}/src/test/resources/application.yml (100%) create mode 100644 oap-server/server-starter-es7/pom.xml create mode 100644 oap-server/server-starter-es7/src/main/assembly/assembly.xml create mode 100644 oap-server/server-starter-es7/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerStartUp.java mode change 100755 => 100644 oap-server/server-starter/src/main/assembly/assembly.xml create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/pom.xml create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/Es7DAO.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Config.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Provider.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/base/StorageEs7Installer.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/EndpointInventoryCacheEs7DAO.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/NetworkAddressInventoryCacheEs7DAO.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/ServiceInstanceInventoryCacheEs7DAO.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/ServiceInventoryCacheEs7DAO.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/client/ElasticSearch7Client.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/client/ElasticSearch7InsertRequest.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/client/ElasticSearch7UpdateRequest.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/MetricsEs7DAO.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/StorageEs7DAO.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/lock/RegisterLockEs77DAOImpl.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/lock/RegisterLockEs7Installer.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/AggregationQueryEs7DAO.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/AlarmQueryEs7DAO.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/LogQueryEs7DAO.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/MetadataQueryEs7DAO.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/MetricsQueryEs7DAO.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/TraceQueryEs7DAO.java create mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider create mode 100755 tools/dependencies/known-oap-backend-dependencies-es7.txt diff --git a/Jenkinsfile b/Jenkinsfile index 3b62b50e77d7..acf182ddeefc 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -72,7 +72,6 @@ pipeline { } } steps { - sh 'tar -zxf dist/apache-skywalking-apm-bin.tar.gz -C dist' sh 'tools/dependencies/check-LICENSE.sh' } } diff --git a/Jenkinsfile-E2E b/Jenkinsfile-E2E index cf767edc6fbd..1715de29e1ff 100755 --- a/Jenkinsfile-E2E +++ b/Jenkinsfile-E2E @@ -113,6 +113,12 @@ pipeline { sh 'E2E_VERSION=jdk8-1.3 bash -x test/e2e/run.sh e2e-agent-reboot' } } + + stage('Cluster Tests (ES7/ZK/JDK8)') { + steps { + sh 'E2E_VERSION=jdk8-1.3 DIST_PACKAGE=apache-skywalking-apm-bin-es7.tar.gz ES_VERSION=7.0.0 bash -x test/e2e/run.sh e2e-cluster/test-runner' + } + } } } @@ -129,6 +135,12 @@ pipeline { sh 'E2E_VERSION=jdk8-1.3 bash -x test/e2e/run.sh e2e-ttl/e2e-ttl-es' } } + + stage('TTL ES7 Tests(JDK8)') { + steps { + sh 'E2E_VERSION=jdk8-1.3 DIST_PACKAGE=apache-skywalking-apm-bin-es7.tar.gz ES_VERSION=7.0.0 bash -x test/e2e/run.sh e2e-ttl/e2e-ttl-es' + } + } } } } diff --git a/apm-dist/pom.xml b/apm-dist/pom.xml index ecb961f3280c..bf2422d4724e 100644 --- a/apm-dist/pom.xml +++ b/apm-dist/pom.xml @@ -71,7 +71,6 @@ - apache-skywalking-apm-bin maven-assembly-plugin @@ -82,15 +81,31 @@ single + + apache-skywalking-apm-bin + + ${project.basedir}/src/main/assembly/binary.xml + + + + + dist-es7 + package + + single + + + apache-skywalking-apm-bin-es7 + + ${project.basedir}/src/main/assembly/binary-es7.xml + + true posix false - - ${project.basedir}/src/main/assembly/binary.xml - false @@ -98,6 +113,7 @@ maven-antrun-plugin + dist package run @@ -109,6 +125,19 @@ + + dist-es7 + package + + run + + + + + + + + diff --git a/apm-dist/release-docs/LICENSE b/apm-dist/release-docs/LICENSE index 9e2186e8e36c..23d4ee0fd860 100755 --- a/apm-dist/release-docs/LICENSE +++ b/apm-dist/release-docs/LICENSE @@ -238,6 +238,7 @@ The text of each license is the standard Apache 2.0 license. Google: proto-google-common-protos 0.1.9: https://github.com/googleapis/googleapis , Apache 2.0 Google: jsr305 3.0.0: http://central.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.0/jsr305-3.0.0.pom , Apache 2.0 Elasticsearch BV (Elasticsearch) 6.3.2: https://www.elastic.co/products/elasticsearch , Apache 2.0 + Elasticsearch BV (Elasticsearch) 7.0.0: https://www.elastic.co/products/elasticsearch , Apache 2.0 lang-mustache-client 5.5.0: https://github.com/elastic/elasticsearch/tree/master/modules/lang-mustache , Apache 2.0 parent-join-client 5.5.0: https://github.com/elastic/elasticsearch/tree/master/modules/parent-join , Apache 2.0 reindex-client 5.5.0: https://github.com/elastic/elasticsearch/tree/master/modules/reindex , Apache 2.0 diff --git a/oap-server/server-starter/src/main/assembly/alarm-settings-sample.yml b/apm-dist/src/main/assembly/alarm-settings-sample.yml similarity index 100% rename from oap-server/server-starter/src/main/assembly/alarm-settings-sample.yml rename to apm-dist/src/main/assembly/alarm-settings-sample.yml diff --git a/oap-server/server-starter/src/main/assembly/alarm-settings.yml b/apm-dist/src/main/assembly/alarm-settings.yml similarity index 100% rename from oap-server/server-starter/src/main/assembly/alarm-settings.yml rename to apm-dist/src/main/assembly/alarm-settings.yml diff --git a/oap-server/server-starter/src/main/assembly/application.yml b/apm-dist/src/main/assembly/application.yml similarity index 85% rename from oap-server/server-starter/src/main/assembly/application.yml rename to apm-dist/src/main/assembly/application.yml index 3bc8ace92f98..e0b725794b5d 100644 --- a/oap-server/server-starter/src/main/assembly/application.yml +++ b/apm-dist/src/main/assembly/application.yml @@ -95,6 +95,28 @@ storage: # resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000} # metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000} # segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200} +# elasticsearch7: +# nameSpace: ${SW_NAMESPACE:""} +# clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200} +# protocol: ${SW_STORAGE_ES_HTTP_PROTOCOL:"http"} +# trustStorePath: ${SW_SW_STORAGE_ES_SSL_JKS_PATH:"../es_keystore.jks"} +# trustStorePass: ${SW_SW_STORAGE_ES_SSL_JKS_PASS:""} +# user: ${SW_ES_USER:""} +# password: ${SW_ES_PASSWORD:""} +# indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:2} +# indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:0} +# # Those data TTL settings will override the same settings in core module. +# recordDataTTL: ${SW_STORAGE_ES_RECORD_DATA_TTL:7} # Unit is day +# otherMetricsDataTTL: ${SW_STORAGE_ES_OTHER_METRIC_DATA_TTL:45} # Unit is day +# monthMetricsDataTTL: ${SW_STORAGE_ES_MONTH_METRIC_DATA_TTL:18} # Unit is month +# # Batch process setting, refer to https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.5/java-docs-bulk-processor.html +# bulkActions: ${SW_STORAGE_ES_BULK_ACTIONS:1000} # Execute the bulk every 1000 requests +# flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:10} # flush the bulk every 10 seconds whatever the number of requests +# concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2} # the number of concurrent requests +# resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000} +# metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000} +# segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200} +# indexMaxResultWindow: ${SW_STORAGE_ES_INDEX_MAX_RESULT_WINDOW:5000} h2: driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource} url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db} diff --git a/apm-dist/src/main/assembly/binary-es7.xml b/apm-dist/src/main/assembly/binary-es7.xml new file mode 100644 index 000000000000..39bbd4bf3f9f --- /dev/null +++ b/apm-dist/src/main/assembly/binary-es7.xml @@ -0,0 +1,105 @@ + + + + dist + + zip + tar.gz + + + + ${project.basedir}/bin + /bin + + *.sh + *.bat + + 0755 + + + src/main/assembly + /config + + log4j2.xml + application.yml + alarm-settings.yml + alarm-settings-sample.yml + + + + ${project.basedir}/../oap-server/server-bootstrap/src/main/resources + + component-libraries.yml + official_analysis.oal + gateways.yml + + /config + + + ${project.basedir}/../oap-server/server-starter-es7/target/skywalking-oap-assembly/skywalking-oap/config + /config + + *.yml + *.xml + *.properties + *.oal + + + + ${project.basedir}/../oap-server/server-starter-es7/target/skywalking-oap-assembly/skywalking-oap/libs + /oap-libs + + + + + ${project.basedir}/../skywalking-agent + /agent + + + + + ${project.basedir}/../ + / + + DISCLAIMER + CHANGES + + + + + ${project.basedir}/release-docs + / + + + + + ${project.basedir}/../apm-webapp/target/skywalking-webapp.jar + /webapp + 0644 + + + ${project.basedir}/../apm-webapp/src/main/assembly/webapp.yml + /webapp + 0644 + + + diff --git a/apm-dist/src/main/assembly/binary.xml b/apm-dist/src/main/assembly/binary.xml index 8e0cd0ff1329..82738997fce4 100644 --- a/apm-dist/src/main/assembly/binary.xml +++ b/apm-dist/src/main/assembly/binary.xml @@ -35,6 +35,25 @@ 0755 + + src/main/assembly + /config + + log4j2.xml + application.yml + alarm-settings.yml + alarm-settings-sample.yml + + + + ${project.basedir}/../oap-server/server-bootstrap/src/main/resources + + component-libraries.yml + official_analysis.oal + gateways.yml + + /config + ${project.basedir}/../oap-server/server-starter/target/skywalking-oap-assembly/skywalking-oap/config /config diff --git a/oap-server/server-starter/src/main/assembly/log4j2.xml b/apm-dist/src/main/assembly/log4j2.xml similarity index 100% rename from oap-server/server-starter/src/main/assembly/log4j2.xml rename to apm-dist/src/main/assembly/log4j2.xml diff --git a/docs/en/setup/backend/backend-storage.md b/docs/en/setup/backend/backend-storage.md index 8c70ab1b35cb..c1e6ee180899 100644 --- a/docs/en/setup/backend/backend-storage.md +++ b/docs/en/setup/backend/backend-storage.md @@ -4,7 +4,7 @@ use is by changing the `application.yml` Native supported storage - H2 -- ElasticSearch 6 +- ElasticSearch 6, 7 - MySQL - TiDB @@ -26,10 +26,16 @@ storage: user: sa ``` -## ElasticSearch 6 -Active ElasticSearch 6 as storage, set storage provider to **elasticsearch**. +## ElasticSearch +- In order to activate ElasticSearch 6 as storage, set storage provider to **elasticsearch** +- In order to activate ElasticSearch 7 as storage, set storage provider to **elasticsearch7** -**Required ElasticSearch 6.3.2 or higher, excepted 7.0.0 or higher. HTTP RestHighLevelClient is used to connect server.** +**Required ElasticSearch 6.3.2 or higher. HTTP RestHighLevelClient is used to connect server.** + +- For ElasticSearch 6.3.2 ~ 7.0.0 (excluded), please download the `apache-skywalking-bin.tar.gz` or `apache-skywalking-bin.zip`, +- For ElasticSearch 7.0.0 ~ 8.0.0 (excluded), please download the `apache-skywalking-bin-es7.tar.gz` or `apache-skywalking-bin-es7.zip`. + +ElasticSearch 6 and ElasticSearch 7 share most of the configurations, as follows: Setting fragment example @@ -54,6 +60,22 @@ storage: bulkSize: ${SW_STORAGE_ES_BULK_SIZE:20} # flush the bulk every 20mb flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:10} # flush the bulk every 10 seconds whatever the number of requests concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2} # the number of concurrent requests + resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000} + metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000} + segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200} +``` + +and there're also some configurations that are ES7 specific, as follows: + +```yaml +storage: + elasticsearch7: + # ... the configurations shared with ES6 that are listed above ... + + # Index max result window, for segment deep pagination, usually we don't recommend to scroll too many pages, + # instead, give more query criteria (e.g. service id or time range), to narrow the query results. + # see https://www.elastic.co/guide/en/elasticsearch/guide/current/pagination.html for more information + indexMaxResultWindow: ${SW_STORAGE_ES_INDEX_MAX_RESULT_WINDOW:5000} ``` ### ElasticSearch 6 With Https SSL Encrypting communications. @@ -87,9 +109,19 @@ storage: ### Data TTL TTL in ElasticSearch overrides the settings of core, read [ElasticSearch section in TTL document](ttl.md#elasticsearch-6-storage-ttl) -### ElasticSearch server settings -Read the [ElasticSearch storage FAQ](../../FAQ/ES-Server-FAQ.md) if you are new to ElasticSearch. -And recommend read more about these configuration from ElasticSearch official document. +### Recommended ElasticSearch server-side configurations +You could add following config to `elasticsearch.yml`, set the value based on your env. + +```yml +# In tracing scenario, consider to set more than this at least. +thread_pool.index.queue_size: 1000 # Only suitable for ElasticSearch 6 +thread_pool.write.queue_size: 1000 # Suitable for ElasticSearch 6 and 7 + +# When you face query error at trace page, remember to check this. +index.max_result_window: 1000000 # Only suitable for ElasticSearch 6. For ES 7, set `indexMaxResultWindow` under `storage`-`elasticsearch7` section in application.yml +``` + +We strongly advice you to read more about these configurations from ElasticSearch official document. This effects the performance of ElasticSearch very much. @@ -194,7 +226,7 @@ These settings can refer to the configuration of *MySQL* above. ## ElasticSearch 5 ElasticSearch 5 is incompatible with ElasticSearch 6 Java client jar, so it could not be included in native distribution. -[OpenSkywalking/SkyWalking-With-Es5x-Storage](https://github.com/OpenSkywalking/SkyWalking-With-Es5x-Storage) repo includes the distribution version. +[OpenSkyWalking/SkyWalking-With-Es5x-Storage](https://github.com/OpenSkywalking/SkyWalking-With-Es5x-Storage) repo includes the distribution version. ## More storage solution extension Follow [Storage extension development guide](../../guides/storage-extention.md) diff --git a/oap-server/pom.xml b/oap-server/pom.xml index d013ea25d14d..5b33e2207461 100755 --- a/oap-server/pom.xml +++ b/oap-server/pom.xml @@ -34,6 +34,7 @@ server-storage-plugin server-library server-starter + server-starter-es7 server-query-plugin server-alarm-plugin server-testing @@ -42,6 +43,7 @@ oal-grammar exporter server-configuration + server-bootstrap diff --git a/oap-server/server-bootstrap/pom.xml b/oap-server/server-bootstrap/pom.xml new file mode 100644 index 000000000000..be1db1021751 --- /dev/null +++ b/oap-server/server-bootstrap/pom.xml @@ -0,0 +1,234 @@ + + + + + + oap-server + org.apache.skywalking + 6.6.0-SNAPSHOT + + 4.0.0 + + server-bootstrap + + + + org.apache.skywalking + server-core + ${project.version} + + + + + org.apache.skywalking + oal-rt + ${project.version} + + + + + + org.apache.skywalking + cluster-standalone-plugin + ${project.version} + + + org.apache.skywalking + cluster-zookeeper-plugin + ${project.version} + + + org.apache.skywalking + cluster-kubernetes-plugin + ${project.version} + + + org.apache.skywalking + cluster-consul-plugin + ${project.version} + + + org.apache.skywalking + cluster-nacos-plugin + ${project.version} + + + org.apache.skywalking + cluster-etcd-plugin + ${project.version} + + + + + + org.apache.skywalking + skywalking-mesh-receiver-plugin + ${project.version} + + + org.apache.skywalking + skywalking-istio-telemetry-receiver-plugin + ${project.version} + + + org.apache.skywalking + skywalking-register-receiver-plugin + ${project.version} + + + org.apache.skywalking + skywalking-jvm-receiver-plugin + ${project.version} + + + org.apache.skywalking + skywalking-trace-receiver-plugin + ${project.version} + + + org.apache.skywalking + envoy-metrics-receiver-plugin + ${project.version} + + + org.apache.skywalking + skywalking-clr-receiver-plugin + ${project.version} + + + org.apache.skywalking + skywalking-so11y-receiver-plugin + ${project.version} + + + + + + org.apache.skywalking + storage-jdbc-hikaricp-plugin + ${project.version} + + + + + + org.apache.skywalking + query-graphql-plugin + ${project.version} + + + + + + org.apache.skywalking + server-alarm-plugin + ${project.version} + + + + + org.apache.skywalking + telemetry-prometheus + ${project.version} + + + org.apache.skywalking + telemetry-so11y + ${project.version} + + + + + org.apache.skywalking + exporter + ${project.version} + + + + + org.apache.skywalking + grpc-configuration-sync + ${project.version} + + + + org.apache.skywalking + configuration-apollo + ${project.version} + + + org.apache.skywalking + configuration-nacos + ${project.version} + + + org.apache.skywalking + configuration-zookeeper + ${project.version} + + + org.apache.skywalking + configuration-etcd + ${project.version} + + + org.apache.skywalking + configuration-consul + ${project.version} + + + + + + + maven-compiler-plugin + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-resources-plugin + + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.2 + + + application.yml + log4j2.xml + alarm-settings.yml + component-libraries.yml + endpoint_naming_rules.properties + official_analysis.oal + gateways.yml + + + + + + \ No newline at end of file diff --git a/oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerBootstrap.java b/oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerBootstrap.java new file mode 100644 index 000000000000..3c0b022b6062 --- /dev/null +++ b/oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerBootstrap.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.starter; + +import org.apache.skywalking.oap.server.core.RunningMode; +import org.apache.skywalking.oap.server.library.module.ApplicationConfiguration; +import org.apache.skywalking.oap.server.library.module.ModuleManager; +import org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoader; +import org.apache.skywalking.oap.server.telemetry.TelemetryModule; +import org.apache.skywalking.oap.server.telemetry.api.MetricsCreator; +import org.apache.skywalking.oap.server.telemetry.api.MetricsTag; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + * @author kezhenxu94 + */ +public class OAPServerBootstrap { + + private static final Logger logger = LoggerFactory.getLogger(OAPServerBootstrap.class); + + public static void start() { + String mode = System.getProperty("mode"); + RunningMode.setMode(mode); + + ApplicationConfigLoader configLoader = new ApplicationConfigLoader(); + ModuleManager manager = new ModuleManager(); + try { + ApplicationConfiguration applicationConfiguration = configLoader.load(); + manager.init(applicationConfiguration); + + manager.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class).createGauge("uptime", + "oap server start up time", MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE) + // Set uptime to second + .setValue(System.currentTimeMillis() / 1000d); + + if (RunningMode.isInitMode()) { + logger.info("OAP starts up in init mode successfully, exit now..."); + System.exit(0); + } + } catch (Throwable t) { + logger.error(t.getMessage(), t); + System.exit(1); + } + } +} diff --git a/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java b/oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java similarity index 100% rename from oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java rename to oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java diff --git a/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ConfigFileNotFoundException.java b/oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/config/ConfigFileNotFoundException.java similarity index 100% rename from oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ConfigFileNotFoundException.java rename to oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/config/ConfigFileNotFoundException.java diff --git a/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ConfigLoader.java b/oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/config/ConfigLoader.java similarity index 100% rename from oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ConfigLoader.java rename to oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/config/ConfigLoader.java diff --git a/oap-server/server-starter/src/main/resources/alarm-settings.yml b/oap-server/server-bootstrap/src/main/resources/alarm-settings.yml similarity index 100% rename from oap-server/server-starter/src/main/resources/alarm-settings.yml rename to oap-server/server-bootstrap/src/main/resources/alarm-settings.yml diff --git a/oap-server/server-starter/src/main/resources/application.yml b/oap-server/server-bootstrap/src/main/resources/application.yml similarity index 83% rename from oap-server/server-starter/src/main/resources/application.yml rename to oap-server/server-bootstrap/src/main/resources/application.yml index 2e7c46e0e284..112eed800ddb 100755 --- a/oap-server/server-starter/src/main/resources/application.yml +++ b/oap-server/server-bootstrap/src/main/resources/application.yml @@ -73,7 +73,28 @@ core: enableDatabaseSession: ${SW_CORE_ENABLE_DATABASE_SESSION:true} topNReportPeriod: ${SW_CORE_TOPN_REPORT_PERIOD:10} # top_n record worker report cycle, unit is minute storage: - elasticsearch: +# elasticsearch: +# nameSpace: ${SW_NAMESPACE:""} +# clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200} +# protocol: ${SW_STORAGE_ES_HTTP_PROTOCOL:"http"} +# #trustStorePath: ${SW_SW_STORAGE_ES_SSL_JKS_PATH:"../es_keystore.jks"} +# #trustStorePass: ${SW_SW_STORAGE_ES_SSL_JKS_PASS:""} +# user: ${SW_ES_USER:""} +# password: ${SW_ES_PASSWORD:""} +# indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:2} +# indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:0} +# # Those data TTL settings will override the same settings in core module. +# recordDataTTL: ${SW_STORAGE_ES_RECORD_DATA_TTL:7} # Unit is day +# otherMetricsDataTTL: ${SW_STORAGE_ES_OTHER_METRIC_DATA_TTL:45} # Unit is day +# monthMetricsDataTTL: ${SW_STORAGE_ES_MONTH_METRIC_DATA_TTL:18} # Unit is month +# # Batch process setting, refer to https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.5/java-docs-bulk-processor.html +# bulkActions: ${SW_STORAGE_ES_BULK_ACTIONS:1000} # Execute the bulk every 1000 requests +# flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:10} # flush the bulk every 10 seconds whatever the number of requests +# concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2} # the number of concurrent requests +# resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000} +# metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000} +# segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200} + elasticsearch7: nameSpace: ${SW_NAMESPACE:""} clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200} protocol: ${SW_STORAGE_ES_HTTP_PROTOCOL:"http"} @@ -94,6 +115,10 @@ storage: resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000} metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000} segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200} + # Index max result window, for segment deep pagination, usually we don't recommend to scroll too many pages, + # instead, give more query criteria (e.g. service id or time range), to narrow the query results. + # see https://www.elastic.co/guide/en/elasticsearch/guide/current/pagination.html for more information + indexMaxResultWindow: ${SW_STORAGE_ES_INDEX_MAX_RESULT_WINDOW:5000} # h2: # driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource} # url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db} diff --git a/oap-server/server-starter/src/main/resources/component-libraries.yml b/oap-server/server-bootstrap/src/main/resources/component-libraries.yml similarity index 100% rename from oap-server/server-starter/src/main/resources/component-libraries.yml rename to oap-server/server-bootstrap/src/main/resources/component-libraries.yml diff --git a/oap-server/server-starter/src/main/resources/endpoint_naming_rules.properties b/oap-server/server-bootstrap/src/main/resources/endpoint_naming_rules.properties similarity index 100% rename from oap-server/server-starter/src/main/resources/endpoint_naming_rules.properties rename to oap-server/server-bootstrap/src/main/resources/endpoint_naming_rules.properties diff --git a/oap-server/server-starter/src/main/assembly/gateways.yml b/oap-server/server-bootstrap/src/main/resources/gateways.yml similarity index 100% rename from oap-server/server-starter/src/main/assembly/gateways.yml rename to oap-server/server-bootstrap/src/main/resources/gateways.yml diff --git a/oap-server/server-starter/src/main/resources/log4j2.xml b/oap-server/server-bootstrap/src/main/resources/log4j2.xml similarity index 100% rename from oap-server/server-starter/src/main/resources/log4j2.xml rename to oap-server/server-bootstrap/src/main/resources/log4j2.xml diff --git a/oap-server/server-starter/src/main/resources/official_analysis.oal b/oap-server/server-bootstrap/src/main/resources/official_analysis.oal similarity index 100% rename from oap-server/server-starter/src/main/resources/official_analysis.oal rename to oap-server/server-bootstrap/src/main/resources/official_analysis.oal diff --git a/oap-server/server-starter/src/test/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoaderTestCase.java b/oap-server/server-bootstrap/src/test/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoaderTestCase.java similarity index 100% rename from oap-server/server-starter/src/test/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoaderTestCase.java rename to oap-server/server-bootstrap/src/test/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoaderTestCase.java diff --git a/oap-server/server-starter/src/test/resources/application.yml b/oap-server/server-bootstrap/src/test/resources/application.yml similarity index 100% rename from oap-server/server-starter/src/test/resources/application.yml rename to oap-server/server-bootstrap/src/test/resources/application.yml diff --git a/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/elasticsearch/ElasticSearchClient.java b/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/elasticsearch/ElasticSearchClient.java index c551eda13672..f49724e45e63 100644 --- a/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/elasticsearch/ElasticSearchClient.java +++ b/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/elasticsearch/ElasticSearchClient.java @@ -20,7 +20,6 @@ import com.google.common.base.Splitter; import com.google.gson.Gson; -import com.google.gson.JsonArray; import com.google.gson.JsonObject; import java.io.IOException; import java.io.InputStream; @@ -34,6 +33,7 @@ import java.security.cert.CertificateException; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -56,6 +56,8 @@ import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.SSLContexts; import org.apache.skywalking.oap.server.library.client.Client; +import org.apache.skywalking.oap.server.library.client.request.InsertRequest; +import org.apache.skywalking.oap.server.library.client.request.UpdateRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; @@ -72,7 +74,6 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.action.support.WriteRequest; -import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.client.Response; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClientBuilder; @@ -93,8 +94,8 @@ public class ElasticSearchClient implements Client { private static final Logger logger = LoggerFactory.getLogger(ElasticSearchClient.class); public static final String TYPE = "type"; - private final String clusterNodes; - private final String protocol; + protected final String clusterNodes; + protected final String protocol; private final String trustStorePath; private final String trustStorePass; private final String namespace; @@ -115,7 +116,12 @@ public ElasticSearchClient(String clusterNodes, String protocol, String trustSto @Override public void connect() throws IOException, KeyStoreException, NoSuchAlgorithmException, KeyManagementException, CertificateException { - List pairsList = parseClusterNodes(clusterNodes); + List hosts = parseClusterNodes(protocol, clusterNodes); + client = createClient(hosts); + client.ping(); + } + + protected RestHighLevelClient createClient(final List pairsList) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, KeyManagementException { RestClientBuilder builder; if (StringUtils.isNotBlank(user) && StringUtils.isNotBlank(password)) { final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); @@ -139,15 +145,14 @@ public void connect() throws IOException, KeyStoreException, NoSuchAlgorithmExce builder = RestClient.builder(pairsList.toArray(new HttpHost[0])); } - client = new RestHighLevelClient(builder); - client.ping(); + return new RestHighLevelClient(builder); } @Override public void shutdown() throws IOException { client.close(); } - private List parseClusterNodes(String nodes) { + public static List parseClusterNodes(String protocol, String nodes) { List httpHosts = new LinkedList<>(); logger.info("elasticsearch cluster nodes: {}", nodes); List nodesSplit = Splitter.on(",").omitEmptyStrings().splitToList(nodes); @@ -170,11 +175,12 @@ public boolean createIndex(String indexName) throws IOException { return response.isAcknowledged(); } - public boolean createIndex(String indexName, JsonObject settings, JsonObject mapping) throws IOException { + public boolean createIndex(String indexName, Map settings, Map mapping) throws IOException { indexName = formatIndexName(indexName); CreateIndexRequest request = new CreateIndexRequest(indexName); - request.settings(settings.toString(), XContentType.JSON); - request.mapping(TYPE, mapping.toString(), XContentType.JSON); + Gson gson = new Gson(); + request.settings(gson.toJson(settings), XContentType.JSON); + request.mapping(TYPE, gson.toJson(mapping), XContentType.JSON); CreateIndexResponse response = client.indices().create(request); logger.debug("create {} index finished, isAcknowledged: {}", indexName, response.isAcknowledged()); return response.isAcknowledged(); @@ -214,7 +220,7 @@ public boolean deleteByModelName(String modelName) throws IOException { return deleteIndex(modelName, true); } - private boolean deleteIndex(String indexName, boolean formatIndexName) throws IOException { + protected boolean deleteIndex(String indexName, boolean formatIndexName) throws IOException { if (formatIndexName) { indexName = formatIndexName(indexName); } @@ -247,22 +253,21 @@ public boolean isExistsTemplate(String indexName) throws IOException { } } - public boolean createTemplate(String indexName, JsonObject settings, JsonObject mapping) throws IOException { + public boolean createTemplate(String indexName, Map settings, Map mapping) throws IOException { indexName = formatIndexName(indexName); - JsonArray patterns = new JsonArray(); - patterns.add(indexName + "-*"); + String[] patterns = new String[] {indexName + "-*"}; - JsonObject aliases = new JsonObject(); - aliases.add(indexName, new JsonObject()); + Map aliases = new HashMap<>(); + aliases.put(indexName, new JsonObject()); - JsonObject template = new JsonObject(); - template.add("index_patterns", patterns); - template.add("aliases", aliases); - template.add("settings", settings); - template.add("mappings", mapping); + Map template = new HashMap<>(); + template.put("index_patterns", patterns); + template.put("aliases", aliases); + template.put("settings", settings); + template.put("mappings", mapping); - HttpEntity entity = new NStringEntity(template.toString(), ContentType.APPLICATION_JSON); + HttpEntity entity = new NStringEntity(new Gson().toJson(template), ContentType.APPLICATION_JSON); Response response = client.getLowLevelClient().performRequest(HttpPut.METHOD_NAME, "/_template/" + indexName, Collections.emptyMap(), entity); return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK; @@ -299,30 +304,30 @@ public SearchResponse ids(String indexName, String[] ids) throws IOException { } public void forceInsert(String indexName, String id, XContentBuilder source) throws IOException { - IndexRequest request = prepareInsert(indexName, id, source); + IndexRequest request = (IndexRequest) prepareInsert(indexName, id, source); request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); client.index(request); } public void forceUpdate(String indexName, String id, XContentBuilder source, long version) throws IOException { - UpdateRequest request = prepareUpdate(indexName, id, source); + org.elasticsearch.action.update.UpdateRequest request = (org.elasticsearch.action.update.UpdateRequest) prepareUpdate(indexName, id, source); request.version(version); request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); client.update(request); } public void forceUpdate(String indexName, String id, XContentBuilder source) throws IOException { - UpdateRequest request = prepareUpdate(indexName, id, source); + org.elasticsearch.action.update.UpdateRequest request = (org.elasticsearch.action.update.UpdateRequest) prepareUpdate(indexName, id, source); request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); client.update(request); } - public ElasticSearchInsertRequest prepareInsert(String indexName, String id, XContentBuilder source) { + public InsertRequest prepareInsert(String indexName, String id, XContentBuilder source) { indexName = formatIndexName(indexName); return new ElasticSearchInsertRequest(indexName, TYPE, id).source(source); } - public ElasticSearchUpdateRequest prepareUpdate(String indexName, String id, XContentBuilder source) { + public UpdateRequest prepareUpdate(String indexName, String id, XContentBuilder source) { indexName = formatIndexName(indexName); return new ElasticSearchUpdateRequest(indexName, TYPE, id).doc(source); } @@ -359,27 +364,7 @@ public void synchronousBulk(BulkRequest request) { } public BulkProcessor createBulkProcessor(int bulkActions, int flushInterval, int concurrentRequests) { - BulkProcessor.Listener listener = new BulkProcessor.Listener() { - @Override - public void beforeBulk(long executionId, BulkRequest request) { - int numberOfActions = request.numberOfActions(); - logger.debug("Executing bulk [{}] with {} requests", executionId, numberOfActions); - } - - @Override - public void afterBulk(long executionId, BulkRequest request, BulkResponse response) { - if (response.hasFailures()) { - logger.warn("Bulk [{}] executed with failures", executionId); - } else { - logger.info("Bulk execution id [{}] completed in {} milliseconds, size: {}", executionId, response.getTook().getMillis(), request.requests().size()); - } - } - - @Override - public void afterBulk(long executionId, BulkRequest request, Throwable failure) { - logger.error("Failed to execute bulk", failure); - } - }; + BulkProcessor.Listener listener = createBulkListener(); return BulkProcessor.builder(client::bulkAsync, listener) .setBulkActions(bulkActions) @@ -389,6 +374,30 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) .build(); } + protected BulkProcessor.Listener createBulkListener() { + return new BulkProcessor.Listener() { + @Override + public void beforeBulk(long executionId, BulkRequest request) { + int numberOfActions = request.numberOfActions(); + logger.debug("Executing bulk [{}] with {} requests", executionId, numberOfActions); + } + + @Override + public void afterBulk(long executionId, BulkRequest request, BulkResponse response) { + if (response.hasFailures()) { + logger.warn("Bulk [{}] executed with failures", executionId); + } else { + logger.info("Bulk execution id [{}] completed in {} milliseconds, size: {}", executionId, response.getTook().getMillis(), request.requests().size()); + } + } + + @Override + public void afterBulk(long executionId, BulkRequest request, Throwable failure) { + logger.error("Failed to execute bulk", failure); + } + }; + } + public String formatIndexName(String indexName) { if (StringUtils.isNotEmpty(namespace)) { return namespace + "_" + indexName; diff --git a/oap-server/server-library/library-client/src/test/java/org/apache/skywalking/oap/server/library/client/elasticsearch/ITElasticSearchClient.java b/oap-server/server-library/library-client/src/test/java/org/apache/skywalking/oap/server/library/client/elasticsearch/ITElasticSearchClient.java index a21413e3182e..edc9a039aa5b 100644 --- a/oap-server/server-library/library-client/src/test/java/org/apache/skywalking/oap/server/library/client/elasticsearch/ITElasticSearchClient.java +++ b/oap-server/server-library/library-client/src/test/java/org/apache/skywalking/oap/server/library/client/elasticsearch/ITElasticSearchClient.java @@ -81,17 +81,14 @@ public void after() throws IOException { @Test public void indexOperate() throws IOException { - JsonObject settings = new JsonObject(); - settings.addProperty("number_of_shards", 2); - settings.addProperty("number_of_replicas", 2); + Map settings = new HashMap<>(); + settings.put("number_of_shards", 2); + settings.put("number_of_replicas", 2); - JsonObject mapping = new JsonObject(); - mapping.add("_doc", new JsonObject()); - - JsonObject doc = mapping.getAsJsonObject("_doc"); + Map doc = new HashMap<>(); JsonObject properties = new JsonObject(); - doc.add("properties", properties); + doc.put("properties", properties); JsonObject column = new JsonObject(); column.addProperty("type", "text"); @@ -148,18 +145,18 @@ public void documentOperate() throws IOException { @Test public void templateOperate() throws IOException { - JsonObject settings = new JsonObject(); - settings.addProperty("number_of_shards", 1); - settings.addProperty("number_of_replicas", 0); - settings.addProperty("index.refresh_interval", "3s"); - settings.addProperty("analysis.analyzer.oap_analyzer.type", "stop"); + Map settings = new HashMap<>(); + settings.put("number_of_shards", 1); + settings.put("number_of_replicas", 0); + settings.put("index.refresh_interval", "3s"); + settings.put("analysis.analyzer.oap_analyzer.type", "stop"); - JsonObject mapping = new JsonObject(); - mapping.add("type", new JsonObject()); - JsonObject doc = mapping.getAsJsonObject("type"); + Map mapping = new HashMap<>(); + Map doc = new HashMap<>(); + mapping.put("type", doc); JsonObject properties = new JsonObject(); - doc.add("properties", properties); + doc.put("properties", properties); JsonObject column = new JsonObject(); column.addProperty("type", "text"); @@ -209,18 +206,18 @@ public void timeSeriesOperate() throws IOException { String indexName = "test_time_series_operate"; String timeSeriesIndexName = indexName + "-2019"; - JsonObject mapping = new JsonObject(); - mapping.add("type", new JsonObject()); - JsonObject doc = mapping.getAsJsonObject("type"); + Map mapping = new HashMap<>(); + Map doc = new HashMap<>(); + mapping.put("type", doc); JsonObject properties = new JsonObject(); - doc.add("properties", properties); + doc.put("properties", properties); JsonObject column = new JsonObject(); column.addProperty("type", "text"); properties.add("name", column); - client.createTemplate(indexName, new JsonObject(), mapping); + client.createTemplate(indexName, new HashMap<>(), mapping); XContentBuilder builder = XContentFactory.jsonBuilder().startObject() .field("name", "pengys") diff --git a/oap-server/server-starter-es7/pom.xml b/oap-server/server-starter-es7/pom.xml new file mode 100644 index 000000000000..428a746ce468 --- /dev/null +++ b/oap-server/server-starter-es7/pom.xml @@ -0,0 +1,72 @@ + + + + + + oap-server + org.apache.skywalking + 6.6.0-SNAPSHOT + + 4.0.0 + + server-starter-es7 + A backend starter specially for ElasticSearch 7 storage + jar + + + 7.0.0 + + + + + org.apache.skywalking + server-bootstrap + ${project.version} + + + org.apache.skywalking + storage-elasticsearch7-plugin + ${project.version} + + + + + skywalking-oap + + + org.apache.maven.plugins + maven-assembly-plugin + + + assembly + package + + single + + + + src/main/assembly/assembly.xml + + + + + + + + diff --git a/oap-server/server-starter-es7/src/main/assembly/assembly.xml b/oap-server/server-starter-es7/src/main/assembly/assembly.xml new file mode 100644 index 000000000000..bc3202b07cc3 --- /dev/null +++ b/oap-server/server-starter-es7/src/main/assembly/assembly.xml @@ -0,0 +1,33 @@ + + + + assembly + + dir + + + + /libs + runtime + + + diff --git a/oap-server/server-starter-es7/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerStartUp.java b/oap-server/server-starter-es7/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerStartUp.java new file mode 100644 index 000000000000..003dd09b8d28 --- /dev/null +++ b/oap-server/server-starter-es7/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerStartUp.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.starter; + +/** + * @author peng-yongsheng + * @author kezhenxu94 + */ +public class OAPServerStartUp { + + public static void main(String[] args) { + OAPServerBootstrap.start(); + } +} diff --git a/oap-server/server-starter/pom.xml b/oap-server/server-starter/pom.xml index 7f93ef4e5601..a0f032d1009b 100644 --- a/oap-server/server-starter/pom.xml +++ b/oap-server/server-starter/pom.xml @@ -26,108 +26,13 @@ 4.0.0 server-starter + A backend starter specially for ElasticSearch 6 storage jar org.apache.skywalking - server-core - ${project.version} - - - - - org.apache.skywalking - oal-rt - ${project.version} - - - - - - org.apache.skywalking - cluster-standalone-plugin - ${project.version} - - - org.apache.skywalking - cluster-zookeeper-plugin - ${project.version} - - - org.apache.skywalking - cluster-kubernetes-plugin - ${project.version} - - - org.apache.skywalking - cluster-consul-plugin - ${project.version} - - - org.apache.skywalking - cluster-nacos-plugin - ${project.version} - - - org.apache.skywalking - cluster-etcd-plugin - ${project.version} - - - - - - org.apache.skywalking - skywalking-mesh-receiver-plugin - ${project.version} - - - org.apache.skywalking - skywalking-istio-telemetry-receiver-plugin - ${project.version} - - - org.apache.skywalking - skywalking-register-receiver-plugin - ${project.version} - - - org.apache.skywalking - skywalking-jvm-receiver-plugin - ${project.version} - - - org.apache.skywalking - skywalking-trace-receiver-plugin - ${project.version} - - - org.apache.skywalking - envoy-metrics-receiver-plugin - ${project.version} - - - org.apache.skywalking - zipkin-receiver-plugin - ${project.version} - - - org.apache.skywalking - skywalking-clr-receiver-plugin - ${project.version} - - - org.apache.skywalking - skywalking-so11y-receiver-plugin - ${project.version} - - - - - - org.apache.skywalking - storage-jdbc-hikaricp-plugin + server-bootstrap ${project.version} @@ -145,109 +50,16 @@ jaeger-receiver-plugin ${project.version} - - - - - org.apache.skywalking - query-graphql-plugin - ${project.version} - - - - - - org.apache.skywalking - server-alarm-plugin - ${project.version} - - - - - org.apache.skywalking - telemetry-prometheus - ${project.version} - - - org.apache.skywalking - telemetry-so11y - ${project.version} - - - - - org.apache.skywalking - exporter - ${project.version} - - - - - org.apache.skywalking - grpc-configuration-sync - ${project.version} - - - - org.apache.skywalking - configuration-apollo - ${project.version} - - - org.apache.skywalking - configuration-nacos - ${project.version} - - - org.apache.skywalking - configuration-zookeeper - ${project.version} - - - org.apache.skywalking - configuration-etcd - ${project.version} - org.apache.skywalking - configuration-consul + zipkin-receiver-plugin ${project.version} + skywalking-oap - - maven-compiler-plugin - - ${compiler.version} - ${compiler.version} - ${project.build.sourceEncoding} - - - - org.apache.maven.plugins - maven-resources-plugin - - ${project.build.sourceEncoding} - - - - org.apache.maven.plugins - maven-jar-plugin - 2.3.2 - - - application.yml - log4j2.xml - alarm-settings.yml - component-libraries.yml - endpoint_naming_rules.properties - official_analysis.oal - gateways.yml - - - org.apache.maven.plugins maven-assembly-plugin diff --git a/oap-server/server-starter/src/main/assembly/assembly.xml b/oap-server/server-starter/src/main/assembly/assembly.xml old mode 100755 new mode 100644 index a1c87e9e6882..bc3202b07cc3 --- a/oap-server/server-starter/src/main/assembly/assembly.xml +++ b/oap-server/server-starter/src/main/assembly/assembly.xml @@ -30,25 +30,4 @@ runtime - - - src/main/assembly - /config - - log4j2.xml - application.yml - alarm-settings.yml - alarm-settings-sample.yml - gateways.yml - - - - src/main/resources - - component-libraries.yml - official_analysis.oal - - /config - - diff --git a/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerStartUp.java b/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerStartUp.java index 38b2efbe9d98..003dd09b8d28 100644 --- a/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerStartUp.java +++ b/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerStartUp.java @@ -18,42 +18,13 @@ package org.apache.skywalking.oap.server.starter; -import org.apache.skywalking.oap.server.core.RunningMode; -import org.apache.skywalking.oap.server.library.module.*; -import org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoader; -import org.apache.skywalking.oap.server.telemetry.TelemetryModule; -import org.apache.skywalking.oap.server.telemetry.api.*; -import org.slf4j.*; - /** * @author peng-yongsheng + * @author kezhenxu94 */ public class OAPServerStartUp { - private static final Logger logger = LoggerFactory.getLogger(OAPServerStartUp.class); - public static void main(String[] args) { - String mode = System.getProperty("mode"); - RunningMode.setMode(mode); - - ApplicationConfigLoader configLoader = new ApplicationConfigLoader(); - ModuleManager manager = new ModuleManager(); - try { - ApplicationConfiguration applicationConfiguration = configLoader.load(); - manager.init(applicationConfiguration); - - manager.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class).createGauge("uptime", - "oap server start up time", MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE) - // Set uptime to second - .setValue(System.currentTimeMillis() / 1000d); - - if (RunningMode.isInitMode()) { - logger.info("OAP starts up in init mode successfully, exit now..."); - System.exit(0); - } - } catch (Throwable t) { - logger.error(t.getMessage(), t); - System.exit(1); - } + OAPServerBootstrap.start(); } } diff --git a/oap-server/server-storage-plugin/pom.xml b/oap-server/server-storage-plugin/pom.xml index 3aaafb522c51..ae1d60d55c4b 100644 --- a/oap-server/server-storage-plugin/pom.xml +++ b/oap-server/server-storage-plugin/pom.xml @@ -30,6 +30,7 @@ storage-jdbc-hikaricp-plugin storage-elasticsearch-plugin + storage-elasticsearch7-plugin storage-zipkin-plugin storage-jaeger-plugin diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java index 706153186304..01d32ce47648 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java @@ -24,6 +24,8 @@ import org.apache.skywalking.oap.server.core.storage.*; import org.apache.skywalking.oap.server.core.storage.model.Model; import org.apache.skywalking.oap.server.library.client.elasticsearch.*; +import org.apache.skywalking.oap.server.library.client.request.InsertRequest; +import org.apache.skywalking.oap.server.library.client.request.UpdateRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -32,9 +34,9 @@ */ public class MetricsEsDAO extends EsDAO implements IMetricsDAO { - private final StorageBuilder storageBuilder; + protected final StorageBuilder storageBuilder; - MetricsEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { + protected MetricsEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { super(client); this.storageBuilder = storageBuilder; } @@ -50,13 +52,13 @@ public class MetricsEsDAO extends EsDAO implements IMetricsDAO { return result; } - @Override public ElasticSearchInsertRequest prepareBatchInsert(Model model, Metrics metrics) throws IOException { + @Override public InsertRequest prepareBatchInsert(Model model, Metrics metrics) throws IOException { XContentBuilder builder = map2builder(storageBuilder.data2Map(metrics)); String modelName = TimeSeriesUtils.timeSeries(model, metrics.getTimeBucket()); return getClient().prepareInsert(modelName, metrics.id(), builder); } - @Override public ElasticSearchUpdateRequest prepareBatchUpdate(Model model, Metrics metrics) throws IOException { + @Override public UpdateRequest prepareBatchUpdate(Model model, Metrics metrics) throws IOException { XContentBuilder builder = map2builder(storageBuilder.data2Map(metrics)); String modelName = TimeSeriesUtils.timeSeries(model, metrics.getTimeBucket()); return getClient().prepareUpdate(modelName, metrics.id(), builder); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RecordEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RecordEsDAO.java index 2e7a86442c03..bf90163c044b 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RecordEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RecordEsDAO.java @@ -33,7 +33,7 @@ public class RecordEsDAO extends EsDAO implements IRecordDAO { private final StorageBuilder storageBuilder; - RecordEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { + public RecordEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { super(client); this.storageBuilder = storageBuilder; } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RegisterEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RegisterEsDAO.java index c4bd28931a64..6eeceb6a8325 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RegisterEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RegisterEsDAO.java @@ -32,7 +32,7 @@ public class RegisterEsDAO extends EsDAO implements IRegisterDAO { private final StorageBuilder storageBuilder; - RegisterEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { + public RegisterEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { super(client); this.storageBuilder = storageBuilder; } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java index 0246cede6664..54fd6a90b707 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java @@ -18,15 +18,20 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base; -import com.google.gson.JsonObject; -import java.io.IOException; import org.apache.skywalking.oap.server.core.storage.StorageException; -import org.apache.skywalking.oap.server.core.storage.model.*; +import org.apache.skywalking.oap.server.core.storage.model.Model; +import org.apache.skywalking.oap.server.core.storage.model.ModelColumn; +import org.apache.skywalking.oap.server.core.storage.model.ModelInstaller; import org.apache.skywalking.oap.server.library.client.Client; import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.oap.server.library.module.ModuleManager; import org.elasticsearch.common.unit.TimeValue; -import org.slf4j.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; /** * @author peng-yongsheng @@ -35,10 +40,10 @@ public class StorageEsInstaller extends ModelInstaller { private static final Logger logger = LoggerFactory.getLogger(StorageEsInstaller.class); - private final int indexShardsNumber; - private final int indexReplicasNumber; - private final int indexRefreshInterval; - private final ColumnTypeEsMapping columnTypeEsMapping; + protected final int indexShardsNumber; + protected final int indexReplicasNumber; + protected final int indexRefreshInterval; + protected final ColumnTypeEsMapping columnTypeEsMapping; public StorageEsInstaller(ModuleManager moduleManager, int indexShardsNumber, int indexReplicasNumber, int indexRefreshInterval) { super(moduleManager); @@ -64,8 +69,8 @@ public StorageEsInstaller(ModuleManager moduleManager, int indexShardsNumber, in @Override protected void createTable(Client client, Model model) throws StorageException { ElasticSearchClient esClient = (ElasticSearchClient)client; - JsonObject settings = createSetting(model.isRecord()); - JsonObject mapping = createMapping(model); + Map settings = createSetting(model.isRecord()); + Map mapping = createMapping(model); logger.info("index {}'s columnTypeEsMapping builder str: {}", esClient.formatIndexName(model.getName()), mapping.toString()); try { @@ -97,46 +102,46 @@ public StorageEsInstaller(ModuleManager moduleManager, int indexShardsNumber, in } } - private JsonObject createSetting(boolean record) { - JsonObject setting = new JsonObject(); - setting.addProperty("index.number_of_shards", indexShardsNumber); - setting.addProperty("index.number_of_replicas", indexReplicasNumber); - setting.addProperty("index.refresh_interval", record ? TimeValue.timeValueSeconds(10).toString() : TimeValue.timeValueSeconds(indexRefreshInterval).toString()); - setting.addProperty("analysis.analyzer.oap_analyzer.type", "stop"); + protected Map createSetting(boolean record) { + Map setting = new HashMap<>(); + setting.put("index.number_of_shards", indexShardsNumber); + setting.put("index.number_of_replicas", indexReplicasNumber); + setting.put("index.refresh_interval", record ? TimeValue.timeValueSeconds(10).toString() : TimeValue.timeValueSeconds(indexRefreshInterval).toString()); + setting.put("analysis.analyzer.oap_analyzer.type", "stop"); return setting; } - private JsonObject createMapping(Model model) { - JsonObject mapping = new JsonObject(); - mapping.add(ElasticSearchClient.TYPE, new JsonObject()); + protected Map createMapping(Model model) { + Map mapping = new HashMap<>(); + Map type = new HashMap<>(); - JsonObject type = mapping.get(ElasticSearchClient.TYPE).getAsJsonObject(); + mapping.put(ElasticSearchClient.TYPE, type); - JsonObject properties = new JsonObject(); - type.add("properties", properties); + Map properties = new HashMap<>(); + type.put("properties", properties); for (ModelColumn columnDefine : model.getColumns()) { if (columnDefine.isMatchQuery()) { String matchCName = MatchCNameBuilder.INSTANCE.build(columnDefine.getColumnName().getName()); - JsonObject originalColumn = new JsonObject(); - originalColumn.addProperty("type", columnTypeEsMapping.transform(columnDefine.getType())); - originalColumn.addProperty("copy_to", matchCName); - properties.add(columnDefine.getColumnName().getName(), originalColumn); + Map originalColumn = new HashMap<>(); + originalColumn.put("type", columnTypeEsMapping.transform(columnDefine.getType())); + originalColumn.put("copy_to", matchCName); + properties.put(columnDefine.getColumnName().getName(), originalColumn); - JsonObject matchColumn = new JsonObject(); - matchColumn.addProperty("type", "text"); - matchColumn.addProperty("analyzer", "oap_analyzer"); - properties.add(matchCName, matchColumn); + Map matchColumn = new HashMap<>(); + matchColumn.put("type", "text"); + matchColumn.put("analyzer", "oap_analyzer"); + properties.put(matchCName, matchColumn); } else if (columnDefine.isContent()) { - JsonObject column = new JsonObject(); - column.addProperty("type", "text"); - column.addProperty("index", false); - properties.add(columnDefine.getColumnName().getName(), column); + Map column = new HashMap<>(); + column.put("type", "text"); + column.put("index", false); + properties.put(columnDefine.getColumnName().getName(), column); } else { - JsonObject column = new JsonObject(); - column.addProperty("type", columnTypeEsMapping.transform(columnDefine.getType())); - properties.add(columnDefine.getColumnName().getName(), column); + Map column = new HashMap<>(); + column.put("type", columnTypeEsMapping.transform(columnDefine.getType())); + properties.put(columnDefine.getColumnName().getName(), column); } } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/TimeSeriesUtils.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/TimeSeriesUtils.java index 381262c00f67..01bb8b07dacb 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/TimeSeriesUtils.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/TimeSeriesUtils.java @@ -26,7 +26,7 @@ */ public class TimeSeriesUtils { - static String timeSeries(Model model) { + public static String timeSeries(Model model) { long timeBucket = TimeBucket.getTimeBucket(System.currentTimeMillis(), model.getDownsampling()); return timeSeries(model, timeBucket); } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java index c33e0d978c78..f1ed56a24ed4 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java @@ -37,7 +37,7 @@ public class EndpointInventoryCacheEsDAO extends EsDAO implements IEndpointInven private static final Logger logger = LoggerFactory.getLogger(EndpointInventoryCacheEsDAO.class); - private final EndpointInventory.Builder builder = new EndpointInventory.Builder(); + protected final EndpointInventory.Builder builder = new EndpointInventory.Builder(); public EndpointInventoryCacheEsDAO(ElasticSearchClient client) { super(client); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressInventoryCacheEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressInventoryCacheEsDAO.java index 57338e228656..e823a42dfc18 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressInventoryCacheEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressInventoryCacheEsDAO.java @@ -38,8 +38,8 @@ public class NetworkAddressInventoryCacheEsDAO extends EsDAO implements INetwork private static final Logger logger = LoggerFactory.getLogger(NetworkAddressInventoryCacheEsDAO.class); - private final NetworkAddressInventory.Builder builder = new NetworkAddressInventory.Builder(); - private final int resultWindowMaxSize; + protected final NetworkAddressInventory.Builder builder = new NetworkAddressInventory.Builder(); + protected final int resultWindowMaxSize; public NetworkAddressInventoryCacheEsDAO(ElasticSearchClient client, int resultWindowMaxSize) { super(client); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInstanceInventoryCacheDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInstanceInventoryCacheDAO.java index 203ec07951bb..730e9e986667 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInstanceInventoryCacheDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInstanceInventoryCacheDAO.java @@ -37,7 +37,7 @@ public class ServiceInstanceInventoryCacheDAO extends EsDAO implements IServiceI private static final Logger logger = LoggerFactory.getLogger(ServiceInstanceInventoryCacheDAO.class); - private final ServiceInstanceInventory.Builder builder = new ServiceInstanceInventory.Builder(); + protected final ServiceInstanceInventory.Builder builder = new ServiceInstanceInventory.Builder(); public ServiceInstanceInventoryCacheDAO(ElasticSearchClient client) { super(client); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInventoryCacheEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInventoryCacheEsDAO.java index 23fc8f32e45e..a7ec6fcfc03a 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInventoryCacheEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInventoryCacheEsDAO.java @@ -39,8 +39,8 @@ public class ServiceInventoryCacheEsDAO extends EsDAO implements IServiceInvento private static final Logger logger = LoggerFactory.getLogger(ServiceInventoryCacheEsDAO.class); - private final ServiceInventory.Builder builder = new ServiceInventory.Builder(); - private final int resultWindowMaxSize; + protected final ServiceInventory.Builder builder = new ServiceInventory.Builder(); + protected final int resultWindowMaxSize; public ServiceInventoryCacheEsDAO(ElasticSearchClient client, int resultWindowMaxSize) { super(client); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/lock/RegisterLockInstaller.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/lock/RegisterLockInstaller.java index 26342033c58e..96d91ba51502 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/lock/RegisterLockInstaller.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/lock/RegisterLockInstaller.java @@ -18,15 +18,19 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.lock; -import com.google.gson.JsonObject; -import java.io.IOException; import org.apache.skywalking.oap.server.core.analysis.Stream; import org.apache.skywalking.oap.server.core.register.worker.InventoryStreamProcessor; import org.apache.skywalking.oap.server.core.storage.StorageException; import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.common.xcontent.*; -import org.slf4j.*; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; /** * @author peng-yongsheng @@ -35,7 +39,7 @@ public class RegisterLockInstaller { private static final Logger logger = LoggerFactory.getLogger(RegisterLockInstaller.class); - private final ElasticSearchClient client; + protected final ElasticSearchClient client; public RegisterLockInstaller(ElasticSearchClient client) { this.client = client; @@ -67,23 +71,23 @@ private void deleteIndex() throws IOException { client.deleteByModelName(RegisterLockIndex.NAME); } - private void createIndex() throws IOException { - JsonObject settings = new JsonObject(); - settings.addProperty("index.number_of_shards", 1); - settings.addProperty("index.number_of_replicas", 0); - settings.addProperty("index.refresh_interval", "1s"); + protected void createIndex() throws IOException { + Map settings = new HashMap<>(); + settings.put("index.number_of_shards", 1); + settings.put("index.number_of_replicas", 0); + settings.put("index.refresh_interval", "1s"); - JsonObject mapping = new JsonObject(); - mapping.add(ElasticSearchClient.TYPE, new JsonObject()); + Map mapping = new HashMap<>(); + Map type = new HashMap<>(); - JsonObject type = mapping.get(ElasticSearchClient.TYPE).getAsJsonObject(); + mapping.put(ElasticSearchClient.TYPE, type); - JsonObject properties = new JsonObject(); - type.add("properties", properties); + Map properties = new HashMap<>(); + type.put("properties", properties); - JsonObject column = new JsonObject(); - column.addProperty("type", "integer"); - properties.add(RegisterLockIndex.COLUMN_SEQUENCE, column); + Map column = new HashMap<>(); + column.put("type", "integer"); + properties.put(RegisterLockIndex.COLUMN_SEQUENCE, column); client.createIndex(RegisterLockIndex.NAME, settings, mapping); } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java index 2ff1e0d90e0f..2c53a8b41c80 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java @@ -104,21 +104,15 @@ public List getEndpointTopN(int serviceId, String indName, String va return aggregation(indexName, valueCName, sourceBuilder, topN, order); } - private List aggregation(String indexName, String valueCName, SearchSourceBuilder sourceBuilder, + protected List aggregation(String indexName, String valueCName, SearchSourceBuilder sourceBuilder, int topN, Order order) throws IOException { boolean asc = false; if (order.equals(Order.ASC)) { asc = true; } - TermsAggregationBuilder aggregationBuilder = AggregationBuilders - .terms(Metrics.ENTITY_ID) - .field(Metrics.ENTITY_ID) - .order(BucketOrder.aggregation(valueCName, asc)) - .size(topN) - .subAggregation( - AggregationBuilders.avg(valueCName).field(valueCName) - ); + TermsAggregationBuilder aggregationBuilder = aggregationBuilder(valueCName, topN, asc); + sourceBuilder.aggregation(aggregationBuilder); SearchResponse response = getClient().search(indexName, sourceBuilder); @@ -135,4 +129,15 @@ private List aggregation(String indexName, String valueCName, Search return topNEntities; } + + protected TermsAggregationBuilder aggregationBuilder(final String valueCName, final int topN, final boolean asc) { + return AggregationBuilders + .terms(Metrics.ENTITY_ID) + .field(Metrics.ENTITY_ID) + .order(BucketOrder.aggregation(valueCName, asc)) + .size(topN) + .subAggregation( + AggregationBuilders.avg(valueCName).field(valueCName) + ); + } } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java index 0d3ca1318e72..bc1852daa75d 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java @@ -292,7 +292,7 @@ private List buildServices(SearchResponse response) { return services; } - private BoolQueryBuilder timeRangeQueryBuild(long startTimestamp, long endTimestamp) { + protected BoolQueryBuilder timeRangeQueryBuild(long startTimestamp, long endTimestamp) { BoolQueryBuilder boolQuery1 = QueryBuilders.boolQuery(); boolQuery1.must().add(QueryBuilders.rangeQuery(RegisterSource.HEARTBEAT_TIME).gte(endTimestamp)); boolQuery1.must().add(QueryBuilders.rangeQuery(RegisterSource.REGISTER_TIME).lte(endTimestamp)); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricsQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricsQueryEsDAO.java index 337c8934c861..38e93e4639fb 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricsQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricsQueryEsDAO.java @@ -86,7 +86,7 @@ public MetricsQueryEsDAO(ElasticSearchClient client) { return intValues; } - private void functionAggregation(Function function, TermsAggregationBuilder parentAggBuilder, String valueCName) { + protected void functionAggregation(Function function, TermsAggregationBuilder parentAggBuilder, String valueCName) { switch (function) { case Avg: parentAggBuilder.subAggregation(AggregationBuilders.avg(valueCName).field(valueCName)); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/pom.xml b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/pom.xml new file mode 100644 index 000000000000..9b8f61fc6eab --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/pom.xml @@ -0,0 +1,55 @@ + + + + + + apm + org.apache.skywalking + 6.6.0-SNAPSHOT + ../../../pom.xml + + 4.0.0 + + storage-elasticsearch7-plugin + + + 7.0.0 + + + + + + org.elasticsearch.client + elasticsearch-rest-high-level-client + ${elasticsearch.version} + + + + + + + org.apache.skywalking + storage-elasticsearch-plugin + ${project.version} + + + + \ No newline at end of file diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/Es7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/Es7DAO.java new file mode 100644 index 000000000000..d9b0e7fe3ca0 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/Es7DAO.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7; + +import org.apache.skywalking.oap.server.core.storage.AbstractDAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.client.ElasticSearch7Client; + +/** + * @author kezhenxu94 + */ +public class Es7DAO extends AbstractDAO { + public Es7DAO(final ElasticSearch7Client client) { + super(client); + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Config.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Config.java new file mode 100644 index 000000000000..9999ea3dabe4 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Config.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7; + +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.StorageModuleElasticsearchConfig; + +/** + * @author kezhenxu94 + */ +public class StorageModuleElasticsearch7Config extends StorageModuleElasticsearchConfig { + private int indexMaxResultWindow; + + public int getIndexMaxResultWindow() { + return indexMaxResultWindow; + } + + public void setIndexMaxResultWindow(final int indexMaxResultWindow) { + this.indexMaxResultWindow = indexMaxResultWindow; + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Provider.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Provider.java new file mode 100644 index 000000000000..e3cffac9d9b3 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Provider.java @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7; + +import org.apache.skywalking.apm.util.StringUtil; +import org.apache.skywalking.oap.server.core.CoreModule; +import org.apache.skywalking.oap.server.core.config.ConfigService; +import org.apache.skywalking.oap.server.core.storage.IBatchDAO; +import org.apache.skywalking.oap.server.core.storage.IHistoryDeleteDAO; +import org.apache.skywalking.oap.server.core.storage.IRegisterLockDAO; +import org.apache.skywalking.oap.server.core.storage.StorageDAO; +import org.apache.skywalking.oap.server.core.storage.StorageException; +import org.apache.skywalking.oap.server.core.storage.StorageModule; +import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO; +import org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressInventoryCacheDAO; +import org.apache.skywalking.oap.server.core.storage.cache.IServiceInstanceInventoryCacheDAO; +import org.apache.skywalking.oap.server.core.storage.cache.IServiceInventoryCacheDAO; +import org.apache.skywalking.oap.server.core.storage.query.IAggregationQueryDAO; +import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO; +import org.apache.skywalking.oap.server.core.storage.query.ILogQueryDAO; +import org.apache.skywalking.oap.server.core.storage.query.IMetadataQueryDAO; +import org.apache.skywalking.oap.server.core.storage.query.IMetricsQueryDAO; +import org.apache.skywalking.oap.server.core.storage.query.ITopNRecordsQueryDAO; +import org.apache.skywalking.oap.server.core.storage.query.ITopologyQueryDAO; +import org.apache.skywalking.oap.server.core.storage.query.ITraceQueryDAO; +import org.apache.skywalking.oap.server.library.module.ModuleConfig; +import org.apache.skywalking.oap.server.library.module.ModuleDefine; +import org.apache.skywalking.oap.server.library.module.ModuleProvider; +import org.apache.skywalking.oap.server.library.module.ModuleStartException; +import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.BatchProcessEsDAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.HistoryDeleteEsDAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TopNRecordsQueryEsDAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TopologyQueryEsDAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.ttl.ElasticsearchStorageTTL; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.cache.EndpointInventoryCacheEs7DAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.cache.NetworkAddressInventoryCacheEs7DAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.cache.ServiceInstanceInventoryCacheEs7DAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.cache.ServiceInventoryCacheEs7DAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.client.ElasticSearch7Client; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.dao.StorageEs7DAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.base.StorageEs7Installer; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.lock.RegisterLockEs77DAOImpl; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.lock.RegisterLockEs7Installer; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.AggregationQueryEs7DAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.AlarmQueryEs7DAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.LogQueryEs7DAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.MetadataQueryEs7DAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.MetricsQueryEs7DAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query.TraceQueryEs7DAO; + +import java.io.IOException; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; + +/** + * @author peng-yongsheng, jian.tan + * @author kezhenxu94 + */ +public class StorageModuleElasticsearch7Provider extends ModuleProvider { + + protected final StorageModuleElasticsearch7Config config; + protected ElasticSearch7Client elasticSearch7Client; + + public StorageModuleElasticsearch7Provider() { + super(); + this.config = new StorageModuleElasticsearch7Config(); + } + + @Override + public String name() { + return "elasticsearch7"; + } + + @Override + public Class module() { + return StorageModule.class; + } + + @Override + public ModuleConfig createConfigBeanIfAbsent() { + return config; + } + + @Override + public void prepare() throws ServiceNotProvidedException { + if (!StringUtil.isEmpty(config.getNameSpace())) { + config.setNameSpace(config.getNameSpace().toLowerCase()); + } + elasticSearch7Client = new ElasticSearch7Client(config.getClusterNodes(), config.getProtocol(), config.getTrustStorePath(), config.getTrustStorePass(), config.getNameSpace(), config.getUser(), config.getPassword()); + + this.registerServiceImplementation(IBatchDAO.class, new BatchProcessEsDAO(elasticSearch7Client, config.getBulkActions(), config.getFlushInterval(), config.getConcurrentRequests())); + this.registerServiceImplementation(StorageDAO.class, new StorageEs7DAO(elasticSearch7Client)); + this.registerServiceImplementation(IRegisterLockDAO.class, new RegisterLockEs77DAOImpl(elasticSearch7Client)); + this.registerServiceImplementation(IHistoryDeleteDAO.class, new HistoryDeleteEsDAO(getManager(), elasticSearch7Client, new ElasticsearchStorageTTL())); + + this.registerServiceImplementation(IServiceInventoryCacheDAO.class, new ServiceInventoryCacheEs7DAO(elasticSearch7Client, config.getResultWindowMaxSize())); + this.registerServiceImplementation(IServiceInstanceInventoryCacheDAO.class, new ServiceInstanceInventoryCacheEs7DAO(elasticSearch7Client)); + this.registerServiceImplementation(IEndpointInventoryCacheDAO.class, new EndpointInventoryCacheEs7DAO(elasticSearch7Client)); + this.registerServiceImplementation(INetworkAddressInventoryCacheDAO.class, new NetworkAddressInventoryCacheEs7DAO(elasticSearch7Client, config.getResultWindowMaxSize())); + + this.registerServiceImplementation(ITopologyQueryDAO.class, new TopologyQueryEsDAO(elasticSearch7Client)); + this.registerServiceImplementation(IMetricsQueryDAO.class, new MetricsQueryEs7DAO(elasticSearch7Client)); + this.registerServiceImplementation(ITraceQueryDAO.class, new TraceQueryEs7DAO(elasticSearch7Client, config.getSegmentQueryMaxSize())); + this.registerServiceImplementation(IMetadataQueryDAO.class, new MetadataQueryEs7DAO(elasticSearch7Client, config.getMetadataQueryMaxSize())); + this.registerServiceImplementation(IAggregationQueryDAO.class, new AggregationQueryEs7DAO(elasticSearch7Client)); + this.registerServiceImplementation(IAlarmQueryDAO.class, new AlarmQueryEs7DAO(elasticSearch7Client)); + this.registerServiceImplementation(ITopNRecordsQueryDAO.class, new TopNRecordsQueryEsDAO(elasticSearch7Client)); + this.registerServiceImplementation(ILogQueryDAO.class, new LogQueryEs7DAO(elasticSearch7Client)); + } + + @Override + public void start() throws ModuleStartException { + overrideCoreModuleTTLConfig(); + + try { + elasticSearch7Client.connect(); + + StorageEs7Installer installer = new StorageEs7Installer(getManager(), config); + installer.install(elasticSearch7Client); + + RegisterLockEs7Installer lockInstaller = new RegisterLockEs7Installer(elasticSearch7Client); + lockInstaller.install(); + } catch (StorageException | IOException | KeyStoreException | NoSuchAlgorithmException | KeyManagementException | CertificateException e) { + throw new ModuleStartException(e.getMessage(), e); + } + } + + @Override + public void notifyAfterCompleted() { + } + + @Override + public String[] requiredModules() { + return new String[]{CoreModule.NAME}; + } + + private void overrideCoreModuleTTLConfig() { + ConfigService configService = getManager().find(CoreModule.NAME).provider().getService(ConfigService.class); + configService.getDataTTLConfig().setRecordDataTTL(config.getRecordDataTTL()); + configService.getDataTTLConfig().setMinuteMetricsDataTTL(config.getMinuteMetricsDataTTL()); + configService.getDataTTLConfig().setHourMetricsDataTTL(config.getHourMetricsDataTTL()); + configService.getDataTTLConfig().setDayMetricsDataTTL(config.getDayMetricsDataTTL()); + configService.getDataTTLConfig().setMonthMetricsDataTTL(config.getMonthMetricsDataTTL()); + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/base/StorageEs7Installer.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/base/StorageEs7Installer.java new file mode 100644 index 000000000000..b8788a384b11 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/base/StorageEs7Installer.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.base; + +import org.apache.skywalking.oap.server.core.storage.model.Model; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.library.module.ModuleManager; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.StorageEsInstaller; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.StorageModuleElasticsearch7Config; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; + +/** + * @author kezhenxu94 + */ +public class StorageEs7Installer extends StorageEsInstaller { + + private static final Logger logger = LoggerFactory.getLogger(StorageEs7Installer.class); + + private final StorageModuleElasticsearch7Config config; + + public StorageEs7Installer(final ModuleManager moduleManager, + final StorageModuleElasticsearch7Config config) { + super(moduleManager, config.getIndexShardsNumber(), config.getIndexReplicasNumber(), config.getIndexRefreshInterval()); + + this.config = config; + } + + @SuppressWarnings("unchecked") + protected Map createMapping(Model model) { + Map mapping = super.createMapping(model); + Map type = (Map) mapping.remove(ElasticSearchClient.TYPE); + mapping.put("properties", type.get("properties")); + + logger.debug("elasticsearch index template setting: {}", mapping.toString()); + + return mapping; + } + + protected Map createSetting(boolean record) { + Map setting = super.createSetting(record); + + if (config.getIndexMaxResultWindow() > 0) { + setting.put("index.max_result_window", config.getIndexMaxResultWindow()); + } + + return setting; + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/EndpointInventoryCacheEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/EndpointInventoryCacheEs7DAO.java new file mode 100644 index 000000000000..908f05f36a88 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/EndpointInventoryCacheEs7DAO.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.cache; + +import org.apache.skywalking.oap.server.core.register.EndpointInventory; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.cache.EndpointInventoryCacheEsDAO; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + * @author kezhenxu94 + */ +public class EndpointInventoryCacheEs7DAO extends EndpointInventoryCacheEsDAO { + + private static final Logger logger = LoggerFactory.getLogger(EndpointInventoryCacheEs7DAO.class); + + public EndpointInventoryCacheEs7DAO(ElasticSearchClient client) { + super(client); + } + + @Override + public EndpointInventory get(int endpointId) { + try { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + searchSourceBuilder.query(QueryBuilders.termQuery(EndpointInventory.SEQUENCE, endpointId)); + searchSourceBuilder.size(1); + + SearchResponse response = getClient().search(EndpointInventory.INDEX_NAME, searchSourceBuilder); + if (response.getHits().getTotalHits().value == 1) { + SearchHit searchHit = response.getHits().getAt(0); + return builder.map2Data(searchHit.getSourceAsMap()); + } else { + return null; + } + } catch (Throwable e) { + logger.error(e.getMessage(), e); + return null; + } + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/NetworkAddressInventoryCacheEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/NetworkAddressInventoryCacheEs7DAO.java new file mode 100644 index 000000000000..447c7e12594e --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/NetworkAddressInventoryCacheEs7DAO.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.cache; + +import org.apache.skywalking.oap.server.core.register.NetworkAddressInventory; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.cache.NetworkAddressInventoryCacheEsDAO; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, jian.tan + * @author kezhenxu94 + */ +public class NetworkAddressInventoryCacheEs7DAO extends NetworkAddressInventoryCacheEsDAO { + + private static final Logger logger = LoggerFactory.getLogger(NetworkAddressInventoryCacheEs7DAO.class); + + public NetworkAddressInventoryCacheEs7DAO(ElasticSearchClient client, int resultWindowMaxSize) { + super(client, resultWindowMaxSize); + } + + @Override public NetworkAddressInventory get(int addressId) { + try { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + searchSourceBuilder.query(QueryBuilders.termQuery(NetworkAddressInventory.SEQUENCE, addressId)); + searchSourceBuilder.size(1); + + SearchResponse response = getClient().search(NetworkAddressInventory.INDEX_NAME, searchSourceBuilder); + if (response.getHits().getTotalHits().value == 1) { + SearchHit searchHit = response.getHits().getAt(0); + return builder.map2Data(searchHit.getSourceAsMap()); + } else { + return null; + } + } catch (Throwable t) { + logger.error(t.getMessage(), t); + return null; + } + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/ServiceInstanceInventoryCacheEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/ServiceInstanceInventoryCacheEs7DAO.java new file mode 100644 index 000000000000..1d6c6df3e64e --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/ServiceInstanceInventoryCacheEs7DAO.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.cache; + +import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.cache.ServiceInstanceInventoryCacheDAO; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + * @author kezhenxu94 + */ +public class ServiceInstanceInventoryCacheEs7DAO extends ServiceInstanceInventoryCacheDAO { + + private static final Logger logger = LoggerFactory.getLogger(ServiceInstanceInventoryCacheEs7DAO.class); + + public ServiceInstanceInventoryCacheEs7DAO(ElasticSearchClient client) { + super(client); + } + + @Override + public ServiceInstanceInventory get(int serviceInstanceId) { + try { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + searchSourceBuilder.query(QueryBuilders.termQuery(ServiceInstanceInventory.SEQUENCE, serviceInstanceId)); + searchSourceBuilder.size(1); + + SearchResponse response = getClient().search(ServiceInstanceInventory.INDEX_NAME, searchSourceBuilder); + if (response.getHits().getTotalHits().value == 1) { + SearchHit searchHit = response.getHits().getAt(0); + return builder.map2Data(searchHit.getSourceAsMap()); + } else { + return null; + } + } catch (Throwable t) { + logger.error(t.getMessage(), t); + return null; + } + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/ServiceInventoryCacheEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/ServiceInventoryCacheEs7DAO.java new file mode 100644 index 000000000000..4a828ed33e8c --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/ServiceInventoryCacheEs7DAO.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.cache; + +import org.apache.skywalking.oap.server.core.register.ServiceInventory; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.cache.ServiceInventoryCacheEsDAO; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, jian.tan + * @author kezhenxu94 + */ +public class ServiceInventoryCacheEs7DAO extends ServiceInventoryCacheEsDAO { + + private static final Logger logger = LoggerFactory.getLogger(ServiceInventoryCacheEs7DAO.class); + + public ServiceInventoryCacheEs7DAO(final ElasticSearchClient client, final int resultWindowMaxSize) { + super(client, resultWindowMaxSize); + } + + @Override public ServiceInventory get(int serviceId) { + try { + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + searchSourceBuilder.query(QueryBuilders.termQuery(ServiceInventory.SEQUENCE, serviceId)); + searchSourceBuilder.size(1); + + SearchResponse response = getClient().search(ServiceInventory.INDEX_NAME, searchSourceBuilder); + if (response.getHits().getTotalHits().value == 1) { + SearchHit searchHit = response.getHits().getAt(0); + return builder.map2Data(searchHit.getSourceAsMap()); + } else { + return null; + } + } catch (Throwable t) { + logger.error(t.getMessage(), t); + return null; + } + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/client/ElasticSearch7Client.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/client/ElasticSearch7Client.java new file mode 100644 index 000000000000..ea3c49d647c1 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/client/ElasticSearch7Client.java @@ -0,0 +1,277 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.client; + +import org.apache.http.HttpHost; +import org.apache.http.HttpStatus; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.library.client.request.InsertRequest; +import org.apache.skywalking.oap.server.library.client.request.UpdateRequest; +import org.elasticsearch.action.admin.indices.alias.Alias; +import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; +import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; +import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest; +import org.elasticsearch.action.bulk.BackoffPolicy; +import org.elasticsearch.action.bulk.BulkProcessor; +import org.elasticsearch.action.bulk.BulkRequest; +import org.elasticsearch.action.bulk.BulkResponse; +import org.elasticsearch.action.get.GetRequest; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.search.SearchRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.support.ActiveShardCount; +import org.elasticsearch.action.support.WriteRequest; +import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.client.GetAliasesResponse; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.indices.CreateIndexRequest; +import org.elasticsearch.client.indices.CreateIndexResponse; +import org.elasticsearch.client.indices.GetIndexRequest; +import org.elasticsearch.client.indices.IndexTemplatesExistRequest; +import org.elasticsearch.client.indices.PutIndexTemplateRequest; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.elasticsearch.index.reindex.DeleteByQueryRequest; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * @author peng-yongsheng + * @author kezhenxu94 + */ +public class ElasticSearch7Client extends ElasticSearchClient { + + private static final Logger logger = LoggerFactory.getLogger(ElasticSearch7Client.class); + + public ElasticSearch7Client(final String clusterNodes, + final String protocol, + final String trustStorePath, + final String trustStorePass, + final String namespace, final String user, final String password) { + super(clusterNodes, protocol, trustStorePath, trustStorePass, namespace, user, password); + } + + @Override + public void connect() throws IOException, KeyStoreException, NoSuchAlgorithmException, KeyManagementException, CertificateException { + List hosts = parseClusterNodes(protocol, clusterNodes); + client = createClient(hosts); + client.ping(RequestOptions.DEFAULT); + } + + public boolean createIndex(String indexName) throws IOException { + indexName = formatIndexName(indexName); + + CreateIndexRequest request = new CreateIndexRequest(indexName); + CreateIndexResponse response = client.indices().create(request, RequestOptions.DEFAULT); + logger.debug("create {} index finished, isAcknowledged: {}", indexName, response.isAcknowledged()); + return response.isAcknowledged(); + } + + public boolean createIndex(String indexName, + Map settings, + Map mapping) throws IOException { + indexName = formatIndexName(indexName); + CreateIndexRequest request = new CreateIndexRequest(indexName); + request.settings(settings); + request.mapping(mapping); + CreateIndexResponse response = client.indices().create(request, RequestOptions.DEFAULT); + logger.debug("create {} index finished, isAcknowledged: {}", indexName, response.isAcknowledged()); + return response.isAcknowledged(); + } + + /** + * {@inheritDoc} + */ + @Override + public List retrievalIndexByAliases(String aliases) throws IOException { + aliases = formatIndexName(aliases); + + GetAliasesRequest getAliasesRequest = new GetAliasesRequest(aliases); + GetAliasesResponse alias = client.indices().getAlias(getAliasesRequest, RequestOptions.DEFAULT); + return new ArrayList<>(alias.getAliases().keySet()); + } + + protected boolean deleteIndex(String indexName, boolean formatIndexName) throws IOException { + if (formatIndexName) { + indexName = formatIndexName(indexName); + } + DeleteIndexRequest request = new DeleteIndexRequest(indexName); + AcknowledgedResponse response = client.indices().delete(request, RequestOptions.DEFAULT); + logger.debug("delete {} index finished, isAcknowledged: {}", indexName, response.isAcknowledged()); + return response.isAcknowledged(); + } + + public boolean isExistsIndex(String indexName) throws IOException { + indexName = formatIndexName(indexName); + GetIndexRequest request = new GetIndexRequest(indexName); + return client.indices().exists(request, RequestOptions.DEFAULT); + } + + public boolean isExistsTemplate(String indexName) throws IOException { + indexName = formatIndexName(indexName); + + IndexTemplatesExistRequest indexTemplatesExistRequest = new IndexTemplatesExistRequest(indexName); + + return client.indices().existsTemplate(indexTemplatesExistRequest, RequestOptions.DEFAULT); + } + + public boolean createTemplate(String indexName, + Map settings, + Map mapping) throws IOException { + indexName = formatIndexName(indexName); + + PutIndexTemplateRequest putIndexTemplateRequest = + new PutIndexTemplateRequest(indexName) + .patterns(Collections.singletonList(indexName + "-*")) + .alias(new Alias(indexName)) + .settings(settings) + .mapping(mapping); + + AcknowledgedResponse acknowledgedResponse = + client.indices().putTemplate(putIndexTemplateRequest, RequestOptions.DEFAULT); + + return acknowledgedResponse.isAcknowledged(); + } + + public boolean deleteTemplate(String indexName) throws IOException { + indexName = formatIndexName(indexName); + + DeleteIndexTemplateRequest deleteIndexTemplateRequest = new DeleteIndexTemplateRequest(indexName); + AcknowledgedResponse acknowledgedResponse = client.indices().deleteTemplate(deleteIndexTemplateRequest, RequestOptions.DEFAULT); + + return acknowledgedResponse.isAcknowledged(); + } + + public SearchResponse search( + String indexName, + SearchSourceBuilder searchSourceBuilder) throws IOException { + indexName = formatIndexName(indexName); + SearchRequest searchRequest = new SearchRequest(indexName); + searchRequest.source(searchSourceBuilder); + return client.search(searchRequest, RequestOptions.DEFAULT); + } + + public GetResponse get(String indexName, String id) throws IOException { + indexName = formatIndexName(indexName); + GetRequest request = new GetRequest(indexName, id); + return client.get(request, RequestOptions.DEFAULT); + } + + public SearchResponse ids( + String indexName, + String[] ids) throws IOException { + indexName = formatIndexName(indexName); + + SearchRequest searchRequest = new SearchRequest(indexName); + searchRequest.source().query(QueryBuilders.idsQuery().addIds(ids)).size(ids.length); + return client.search(searchRequest, RequestOptions.DEFAULT); + } + + public void forceInsert(String indexName, String id, XContentBuilder source) throws IOException { + IndexRequest request = (IndexRequest) prepareInsert(indexName, id, source); + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + client.index(request, RequestOptions.DEFAULT); + } + + public void forceUpdate(String indexName, + String id, + XContentBuilder source, + long seqNo, + long primaryTerm) throws IOException { + org.elasticsearch.action.update.UpdateRequest request = (org.elasticsearch.action.update.UpdateRequest) prepareUpdate(indexName, id, source); + request.setIfSeqNo(seqNo); + request.setIfPrimaryTerm(primaryTerm); + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + client.update(request, RequestOptions.DEFAULT); + } + + public void forceUpdate(String indexName, String id, XContentBuilder source) throws IOException { + org.elasticsearch.action.update.UpdateRequest request = (org.elasticsearch.action.update.UpdateRequest) prepareUpdate(indexName, id, source); + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + client.update(request, RequestOptions.DEFAULT); + } + + public InsertRequest prepareInsert(String indexName, String id, XContentBuilder source) { + indexName = formatIndexName(indexName); + return new ElasticSearch7InsertRequest(indexName, id).source(source); + } + + public UpdateRequest prepareUpdate(String indexName, String id, XContentBuilder source) { + indexName = formatIndexName(indexName); + return new ElasticSearch7UpdateRequest(indexName, id).doc(source); + } + + public int delete( + String indexName, + String timeBucketColumnName, + long endTimeBucket) throws IOException { + indexName = formatIndexName(indexName); + + DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest(indexName); + deleteByQueryRequest.setAbortOnVersionConflict(false); + deleteByQueryRequest.setQuery( + QueryBuilders.rangeQuery(timeBucketColumnName).lte(endTimeBucket) + ); + BulkByScrollResponse bulkByScrollResponse = client.deleteByQuery(deleteByQueryRequest, RequestOptions.DEFAULT); + logger.debug( + "delete indexName: {}, by query request: {}, response: {}", + indexName, deleteByQueryRequest, bulkByScrollResponse + ); + return HttpStatus.SC_OK; + } + + public void synchronousBulk(BulkRequest request) { + request.timeout(TimeValue.timeValueMinutes(2)); + request.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL); + request.waitForActiveShards(ActiveShardCount.ONE); + try { + int size = request.requests().size(); + BulkResponse responses = client.bulk(request, RequestOptions.DEFAULT); + logger.info("Synchronous bulk took time: {} millis, size: {}", responses.getTook().getMillis(), size); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } + + public BulkProcessor createBulkProcessor(int bulkActions, int flushInterval, int concurrentRequests) { + BulkProcessor.Listener listener = createBulkListener(); + + return BulkProcessor.builder( + (bulkRequest, bulkResponseActionListener) -> client.bulkAsync(bulkRequest, RequestOptions.DEFAULT, bulkResponseActionListener), listener) + .setBulkActions(bulkActions) + .setFlushInterval(TimeValue.timeValueSeconds(flushInterval)) + .setConcurrentRequests(concurrentRequests) + .setBackoffPolicy(BackoffPolicy.exponentialBackoff(TimeValue.timeValueMillis(100), 3)) + .build(); + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/client/ElasticSearch7InsertRequest.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/client/ElasticSearch7InsertRequest.java new file mode 100644 index 000000000000..378cf16aca7b --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/client/ElasticSearch7InsertRequest.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.client; + +import org.apache.skywalking.oap.server.library.client.request.InsertRequest; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.common.xcontent.XContentBuilder; + +/** + * @author peng-yongsheng + * @author kezhenxu94 + */ +public class ElasticSearch7InsertRequest extends IndexRequest implements InsertRequest { + + public ElasticSearch7InsertRequest(String index, String id) { + super(index); + id(id); + } + + @Override + public ElasticSearch7InsertRequest source(XContentBuilder sourceBuilder) { + super.source(sourceBuilder); + return this; + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/client/ElasticSearch7UpdateRequest.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/client/ElasticSearch7UpdateRequest.java new file mode 100644 index 000000000000..8ddd6a795c83 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/client/ElasticSearch7UpdateRequest.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.client; + +import org.elasticsearch.action.update.UpdateRequest; +import org.elasticsearch.common.xcontent.XContentBuilder; + +/** + * @author peng-yongsheng + * @author kezhenxu94 + */ +public class ElasticSearch7UpdateRequest extends UpdateRequest implements org.apache.skywalking.oap.server.library.client.request.UpdateRequest { + + public ElasticSearch7UpdateRequest(String index, String id) { + super(index, id); + } + + @Override + public ElasticSearch7UpdateRequest doc(XContentBuilder source) { + super.doc(source); + return this; + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/MetricsEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/MetricsEs7DAO.java new file mode 100644 index 000000000000..6c41b001e9d3 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/MetricsEs7DAO.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.dao; + +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.storage.StorageBuilder; +import org.apache.skywalking.oap.server.core.storage.model.Model; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.MetricsEsDAO; +import org.elasticsearch.action.search.SearchResponse; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * @author peng-yongsheng + * @author kezhenxu94 + */ +public class MetricsEs7DAO extends MetricsEsDAO { + + MetricsEs7DAO(final ElasticSearchClient client, + final StorageBuilder storageBuilder) { + super(client, storageBuilder); + } + + @Override + public List multiGet(Model model, List ids) throws IOException { + SearchResponse response = getClient().ids(model.getName(), ids.toArray(new String[0])); + + List result = new ArrayList<>((int) response.getHits().getTotalHits().value); + for (int i = 0; i < response.getHits().getTotalHits().value; i++) { + Metrics source = storageBuilder.map2Data(response.getHits().getAt(i).getSourceAsMap()); + result.add(source); + } + return result; + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/StorageEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/StorageEs7DAO.java new file mode 100644 index 000000000000..6ba0cf147856 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/StorageEs7DAO.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.dao; + +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.analysis.record.Record; +import org.apache.skywalking.oap.server.core.register.RegisterSource; +import org.apache.skywalking.oap.server.core.storage.IMetricsDAO; +import org.apache.skywalking.oap.server.core.storage.IRecordDAO; +import org.apache.skywalking.oap.server.core.storage.IRegisterDAO; +import org.apache.skywalking.oap.server.core.storage.StorageBuilder; +import org.apache.skywalking.oap.server.core.storage.StorageDAO; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.RecordEsDAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.RegisterEsDAO; + +/** + * @author peng-yongsheng + */ +public class StorageEs7DAO extends EsDAO implements StorageDAO { + + public StorageEs7DAO(ElasticSearchClient client) { + super(client); + } + + @Override public IMetricsDAO newMetricsDao(StorageBuilder storageBuilder) { + return new MetricsEs7DAO(getClient(), storageBuilder); + } + + @Override public IRegisterDAO newRegisterDao(StorageBuilder storageBuilder) { + return new RegisterEsDAO(getClient(), storageBuilder); + } + + @Override public IRecordDAO newRecordDao(StorageBuilder storageBuilder) { + return new RecordEsDAO(getClient(), storageBuilder); + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/lock/RegisterLockEs77DAOImpl.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/lock/RegisterLockEs77DAOImpl.java new file mode 100644 index 000000000000..6b47775ecc0e --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/lock/RegisterLockEs77DAOImpl.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.lock; + +import org.apache.skywalking.oap.server.core.Const; +import org.apache.skywalking.oap.server.core.register.RegisterSource; +import org.apache.skywalking.oap.server.core.storage.IRegisterLockDAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.lock.RegisterLockIndex; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.Es7DAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.client.ElasticSearch7Client; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Map; + +/** + * @author kezhenxu94 + */ +public class RegisterLockEs77DAOImpl extends Es7DAO implements IRegisterLockDAO { + + private static final Logger logger = LoggerFactory.getLogger(RegisterLockEs77DAOImpl.class); + + public RegisterLockEs77DAOImpl(ElasticSearch7Client client) { + super(client); + } + + @Override + public int getId(int scopeId, RegisterSource registerSource) { + String id = String.valueOf(scopeId); + + int sequence = Const.NONE; + try { + GetResponse response = getClient().get(RegisterLockIndex.NAME, id); + if (response.isExists()) { + Map source = response.getSource(); + + sequence = ((Number) source.get(RegisterLockIndex.COLUMN_SEQUENCE)).intValue(); + + sequence++; + + lock(id, sequence, response.getSeqNo(), response.getPrimaryTerm()); + } + } catch (Throwable t) { + logger.warn("Try to lock the row with the id {} failure, error message: {}", id, t.getMessage(), t); + return Const.NONE; + } + return sequence; + } + + private void lock(String id, int sequence, final long seqNo, long primaryTerm) throws IOException { + + XContentBuilder source = XContentFactory.jsonBuilder().startObject(); + source.field(RegisterLockIndex.COLUMN_SEQUENCE, sequence); + source.endObject(); + + getClient().forceUpdate(RegisterLockIndex.NAME, id, source, seqNo, primaryTerm); + } +} + + diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/lock/RegisterLockEs7Installer.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/lock/RegisterLockEs7Installer.java new file mode 100644 index 000000000000..d741c08623d2 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/lock/RegisterLockEs7Installer.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.lock; + +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.lock.RegisterLockIndex; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.lock.RegisterLockInstaller; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * @author peng-yongsheng + * @author kezhenxu94 + */ +public class RegisterLockEs7Installer extends RegisterLockInstaller { + + public RegisterLockEs7Installer(final ElasticSearchClient client) { + super(client); + } + + @Override + protected void createIndex() throws IOException { + Map settings = new HashMap<>(); + settings.put("index.number_of_shards", 1); + settings.put("index.number_of_replicas", 0); + settings.put("index.refresh_interval", "1s"); + + Map mapping = new HashMap<>(); + + Map properties = new HashMap<>(); + mapping.put("properties", properties); + + Map column = new HashMap<>(); + column.put("type", "integer"); + + properties.put(RegisterLockIndex.COLUMN_SEQUENCE, column); + + client.createIndex(RegisterLockIndex.NAME, settings, mapping); + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/AggregationQueryEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/AggregationQueryEs7DAO.java new file mode 100644 index 000000000000..77158fd443b2 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/AggregationQueryEs7DAO.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query; + +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.query.entity.Order; +import org.apache.skywalking.oap.server.core.query.entity.TopNEntity; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.AggregationQueryEsDAO; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.BucketOrder; +import org.elasticsearch.search.aggregations.bucket.terms.Terms; +import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; +import org.elasticsearch.search.aggregations.metrics.Avg; +import org.elasticsearch.search.builder.SearchSourceBuilder; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * @author peng-yongsheng + * @author kezhenxu94 + */ +public class AggregationQueryEs7DAO extends AggregationQueryEsDAO { + + public AggregationQueryEs7DAO(ElasticSearchClient client) { + super(client); + } + + protected List aggregation( + String indexName, + String valueCName, + SearchSourceBuilder sourceBuilder, + int topN, + Order order) throws IOException { + + boolean asc = false; + if (order.equals(Order.ASC)) { + asc = true; + } + + TermsAggregationBuilder aggregationBuilder = aggregationBuilder(valueCName, topN, asc); + + sourceBuilder.aggregation(aggregationBuilder); + + SearchResponse response = getClient().search(indexName, sourceBuilder); + + List topNEntities = new ArrayList<>(); + Terms idTerms = response.getAggregations().get(Metrics.ENTITY_ID); + for (Terms.Bucket termsBucket : idTerms.getBuckets()) { + TopNEntity topNEntity = new TopNEntity(); + topNEntity.setId(termsBucket.getKeyAsString()); + Avg value = termsBucket.getAggregations().get(valueCName); + topNEntity.setValue((long) value.getValue()); + topNEntities.add(topNEntity); + } + + return topNEntities; + } + + protected TermsAggregationBuilder aggregationBuilder(final String valueCName, final int topN, final boolean asc) { + return AggregationBuilders + .terms(Metrics.ENTITY_ID) + .field(Metrics.ENTITY_ID) + .order(BucketOrder.aggregation(valueCName, asc)) + .size(topN) + .subAggregation( + AggregationBuilders.avg(valueCName).field(valueCName) + ); + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/AlarmQueryEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/AlarmQueryEs7DAO.java new file mode 100644 index 000000000000..350189854655 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/AlarmQueryEs7DAO.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query; + +import com.google.common.base.Strings; +import org.apache.skywalking.oap.server.core.alarm.AlarmRecord; +import org.apache.skywalking.oap.server.core.query.entity.AlarmMessage; +import org.apache.skywalking.oap.server.core.query.entity.Alarms; +import org.apache.skywalking.oap.server.core.query.entity.Scope; +import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.MatchCNameBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.search.sort.SortOrder; + +import java.io.IOException; +import java.util.Objects; + +/** + * @author peng-yongsheng + * @author kezhenxu94 + */ +public class AlarmQueryEs7DAO extends EsDAO implements IAlarmQueryDAO { + + public AlarmQueryEs7DAO(ElasticSearchClient client) { + super(client); + } + + public Alarms getAlarm(final Integer scopeId, + final String keyword, + final int limit, + final int from, + final long startTB, + final long endTB) throws IOException { + SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); + + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); + boolQueryBuilder.must().add(QueryBuilders.rangeQuery(AlarmRecord.TIME_BUCKET).gte(startTB).lte(endTB)); + + if (Objects.nonNull(scopeId)) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(AlarmRecord.SCOPE, scopeId.intValue())); + } + + if (!Strings.isNullOrEmpty(keyword)) { + String matchCName = MatchCNameBuilder.INSTANCE.build(AlarmRecord.ALARM_MESSAGE); + boolQueryBuilder.must().add(QueryBuilders.matchPhraseQuery(matchCName, keyword)); + } + + sourceBuilder.query(boolQueryBuilder).sort(AlarmRecord.START_TIME, SortOrder.DESC); + sourceBuilder.size(limit); + sourceBuilder.from(from); + + SearchResponse response = getClient().search(AlarmRecord.INDEX_NAME, sourceBuilder); + + Alarms alarms = new Alarms(); + alarms.setTotal((int) response.getHits().getTotalHits().value); + + for (SearchHit searchHit : response.getHits().getHits()) { + AlarmRecord.Builder builder = new AlarmRecord.Builder(); + AlarmRecord alarmRecord = builder.map2Data(searchHit.getSourceAsMap()); + + AlarmMessage message = new AlarmMessage(); + message.setId(String.valueOf(alarmRecord.getId0())); + message.setMessage(alarmRecord.getAlarmMessage()); + message.setStartTime(alarmRecord.getStartTime()); + message.setScope(Scope.Finder.valueOf(alarmRecord.getScope())); + message.setScopeId(alarmRecord.getScope()); + alarms.getMsgs().add(message); + } + return alarms; + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/LogQueryEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/LogQueryEs7DAO.java new file mode 100644 index 000000000000..7dca18eb2a9b --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/LogQueryEs7DAO.java @@ -0,0 +1,122 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query; + +import com.google.common.base.Strings; +import org.apache.skywalking.oap.server.core.Const; +import org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord; +import org.apache.skywalking.oap.server.core.analysis.record.Record; +import org.apache.skywalking.oap.server.core.query.entity.ContentType; +import org.apache.skywalking.oap.server.core.query.entity.Log; +import org.apache.skywalking.oap.server.core.query.entity.LogState; +import org.apache.skywalking.oap.server.core.query.entity.Logs; +import org.apache.skywalking.oap.server.core.query.entity.Pagination; +import org.apache.skywalking.oap.server.core.storage.query.ILogQueryDAO; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.library.util.BooleanUtils; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.builder.SearchSourceBuilder; + +import java.io.IOException; +import java.util.List; + +import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.TRACE_ID; + +/** + * @author wusheng + * @author kezhenxu94 + */ +public class LogQueryEs7DAO extends EsDAO implements ILogQueryDAO { + public LogQueryEs7DAO(ElasticSearchClient client) { + super(client); + } + + @Override + public Logs queryLogs(String metricName, + int serviceId, + int serviceInstanceId, + int endpointId, + String traceId, + LogState state, + String stateCode, + Pagination paging, + int from, + int limit, + long startSecondTB, + long endSecondTB) throws IOException { + SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); + + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); + sourceBuilder.query(boolQueryBuilder); + List mustQueryList = boolQueryBuilder.must(); + + if (startSecondTB != 0 && endSecondTB != 0) { + mustQueryList.add(QueryBuilders.rangeQuery(Record.TIME_BUCKET).gte(startSecondTB).lte(endSecondTB)); + } + + if (serviceId != Const.NONE) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(AbstractLogRecord.SERVICE_ID, serviceId)); + } + if (serviceInstanceId != Const.NONE) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(AbstractLogRecord.SERVICE_INSTANCE_ID, serviceInstanceId)); + } + if (endpointId != Const.NONE) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(AbstractLogRecord.ENDPOINT_ID, endpointId)); + } + if (!Strings.isNullOrEmpty(stateCode)) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(AbstractLogRecord.STATUS_CODE, stateCode)); + } + if (!Strings.isNullOrEmpty(traceId)) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(TRACE_ID, traceId)); + } + if (LogState.ERROR.equals(state)) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(AbstractLogRecord.IS_ERROR, BooleanUtils.booleanToValue(true))); + } else if (LogState.SUCCESS.equals(state)) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(AbstractLogRecord.IS_ERROR, BooleanUtils.booleanToValue(false))); + } + + sourceBuilder.size(limit); + sourceBuilder.from(from); + + SearchResponse response = getClient().search(metricName, sourceBuilder); + + Logs logs = new Logs(); + logs.setTotal((int) response.getHits().getTotalHits().value); + + for (SearchHit searchHit : response.getHits().getHits()) { + Log log = new Log(); + log.setServiceId(((Number) searchHit.getSourceAsMap().get(AbstractLogRecord.SERVICE_ID)).intValue()); + log.setServiceInstanceId(((Number) searchHit.getSourceAsMap().get(AbstractLogRecord.SERVICE_INSTANCE_ID)).intValue()); + log.setEndpointId(((Number) searchHit.getSourceAsMap().get(AbstractLogRecord.ENDPOINT_ID)).intValue()); + log.setError(BooleanUtils.valueToBoolean(((Number) searchHit.getSourceAsMap().get(AbstractLogRecord.IS_ERROR)).intValue())); + log.setStatusCode((String) searchHit.getSourceAsMap().get(AbstractLogRecord.STATUS_CODE)); + log.setContentType(ContentType.instanceOf(((Number) searchHit.getSourceAsMap().get(AbstractLogRecord.CONTENT_TYPE)).intValue())); + log.setContent((String) searchHit.getSourceAsMap().get(AbstractLogRecord.CONTENT)); + + logs.getLogs().add(log); + } + + return logs; + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/MetadataQueryEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/MetadataQueryEs7DAO.java new file mode 100644 index 000000000000..03951d984025 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/MetadataQueryEs7DAO.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query; + +import org.apache.skywalking.oap.server.core.register.EndpointInventory; +import org.apache.skywalking.oap.server.core.register.ServiceInventory; +import org.apache.skywalking.oap.server.core.source.DetectPoint; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.library.util.BooleanUtils; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.MetadataQueryEsDAO; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.builder.SearchSourceBuilder; + +import java.io.IOException; + +/** + * @author peng-yongsheng + */ +public class MetadataQueryEs7DAO extends MetadataQueryEsDAO { + + public MetadataQueryEs7DAO(final ElasticSearchClient client, final int queryMaxSize) { + super(client, queryMaxSize); + } + + @Override + public int numOfService(long startTimestamp, long endTimestamp) throws IOException { + SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); + + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); + boolQueryBuilder.must().add(timeRangeQueryBuild(startTimestamp, endTimestamp)); + + boolQueryBuilder.must().add(QueryBuilders.termQuery(ServiceInventory.IS_ADDRESS, BooleanUtils.FALSE)); + + sourceBuilder.query(boolQueryBuilder); + sourceBuilder.size(0); + + SearchResponse response = getClient().search(ServiceInventory.INDEX_NAME, sourceBuilder); + return (int) response.getHits().getTotalHits().value; + } + + @Override + public int numOfEndpoint() throws IOException { + SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); + + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); + + boolQueryBuilder.must().add(QueryBuilders.termQuery(EndpointInventory.DETECT_POINT, DetectPoint.SERVER.ordinal())); + + sourceBuilder.query(boolQueryBuilder); + sourceBuilder.size(0); + + SearchResponse response = getClient().search(EndpointInventory.INDEX_NAME, sourceBuilder); + return (int) response.getHits().getTotalHits().value; + } + + @Override + public int numOfConjectural(int nodeTypeValue) throws IOException { + SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); + + sourceBuilder.query(QueryBuilders.termQuery(ServiceInventory.NODE_TYPE, nodeTypeValue)); + sourceBuilder.size(0); + + SearchResponse response = getClient().search(ServiceInventory.INDEX_NAME, sourceBuilder); + + return (int) response.getHits().getTotalHits().value; + } + +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/MetricsQueryEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/MetricsQueryEs7DAO.java new file mode 100644 index 000000000000..077898bc41e6 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/MetricsQueryEs7DAO.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query; + +import org.apache.skywalking.oap.server.core.analysis.Downsampling; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.query.entity.IntValues; +import org.apache.skywalking.oap.server.core.query.entity.KVInt; +import org.apache.skywalking.oap.server.core.query.sql.Function; +import org.apache.skywalking.oap.server.core.query.sql.Where; +import org.apache.skywalking.oap.server.core.storage.model.ModelName; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.MetricsQueryEsDAO; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.bucket.terms.Terms; +import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; +import org.elasticsearch.search.aggregations.metrics.Avg; +import org.elasticsearch.search.aggregations.metrics.Sum; +import org.elasticsearch.search.builder.SearchSourceBuilder; + +import java.io.IOException; + +/** + * @author peng-yongsheng + * @author kezhenxu94 + */ +public class MetricsQueryEs7DAO extends MetricsQueryEsDAO { + + public MetricsQueryEs7DAO(ElasticSearchClient client) { + super(client); + } + + @Override + public IntValues getValues( + String indName, + Downsampling downsampling, + long startTB, + long endTB, + Where where, + String valueCName, + Function function) throws IOException { + + String indexName = ModelName.build(downsampling, indName); + + SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); + queryBuild(sourceBuilder, where, startTB, endTB); + + TermsAggregationBuilder entityIdAggregation = AggregationBuilders.terms(Metrics.ENTITY_ID).field(Metrics.ENTITY_ID).size(1000); + functionAggregation(function, entityIdAggregation, valueCName); + + sourceBuilder.aggregation(entityIdAggregation); + + SearchResponse response = getClient().search(indexName, sourceBuilder); + + IntValues intValues = new IntValues(); + Terms idTerms = response.getAggregations().get(Metrics.ENTITY_ID); + for (Terms.Bucket idBucket : idTerms.getBuckets()) { + long value; + switch (function) { + case Sum: + Sum sum = idBucket.getAggregations().get(valueCName); + value = (long) sum.getValue(); + break; + case Avg: + Avg avg = idBucket.getAggregations().get(valueCName); + value = (long) avg.getValue(); + break; + default: + avg = idBucket.getAggregations().get(valueCName); + value = (long) avg.getValue(); + break; + } + + KVInt kvInt = new KVInt(); + kvInt.setId(idBucket.getKeyAsString()); + kvInt.setValue(value); + intValues.getValues().add(kvInt); + } + return intValues; + } + + protected void functionAggregation(Function function, TermsAggregationBuilder parentAggBuilder, String valueCName) { + switch (function) { + case Avg: + parentAggBuilder.subAggregation(AggregationBuilders.avg(valueCName).field(valueCName)); + break; + case Sum: + parentAggBuilder.subAggregation(AggregationBuilders.sum(valueCName).field(valueCName)); + break; + default: + parentAggBuilder.subAggregation(AggregationBuilders.avg(valueCName).field(valueCName)); + break; + } + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/TraceQueryEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/TraceQueryEs7DAO.java new file mode 100644 index 000000000000..3e0ba5389dba --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/TraceQueryEs7DAO.java @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query; + +import com.google.common.base.Strings; +import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord; +import org.apache.skywalking.oap.server.core.query.entity.BasicTrace; +import org.apache.skywalking.oap.server.core.query.entity.QueryOrder; +import org.apache.skywalking.oap.server.core.query.entity.TraceBrief; +import org.apache.skywalking.oap.server.core.query.entity.TraceState; +import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.oap.server.library.util.BooleanUtils; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.MatchCNameBuilder; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TraceQueryEsDAO; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.query.RangeQueryBuilder; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.search.sort.SortOrder; + +import java.io.IOException; +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class TraceQueryEs7DAO extends TraceQueryEsDAO { + + public TraceQueryEs7DAO(ElasticSearchClient client, int segmentQueryMaxSize) { + super(client, segmentQueryMaxSize); + } + + @Override + public TraceBrief queryBasicTraces(long startSecondTB, + long endSecondTB, + long minDuration, + long maxDuration, + String endpointName, + int serviceId, + int serviceInstanceId, + int endpointId, + String traceId, + int limit, + int from, + TraceState traceState, + QueryOrder queryOrder) throws IOException { + SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); + + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); + sourceBuilder.query(boolQueryBuilder); + List mustQueryList = boolQueryBuilder.must(); + + if (startSecondTB != 0 && endSecondTB != 0) { + mustQueryList.add(QueryBuilders.rangeQuery(SegmentRecord.TIME_BUCKET).gte(startSecondTB).lte(endSecondTB)); + } + + if (minDuration != 0 || maxDuration != 0) { + RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(SegmentRecord.LATENCY); + if (minDuration != 0) { + rangeQueryBuilder.gte(minDuration); + } + if (maxDuration != 0) { + rangeQueryBuilder.lte(maxDuration); + } + boolQueryBuilder.must().add(rangeQueryBuilder); + } + if (!Strings.isNullOrEmpty(endpointName)) { + String matchCName = MatchCNameBuilder.INSTANCE.build(SegmentRecord.ENDPOINT_NAME); + mustQueryList.add(QueryBuilders.matchPhraseQuery(matchCName, endpointName)); + } + if (serviceId != 0) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentRecord.SERVICE_ID, serviceId)); + } + if (serviceInstanceId != 0) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentRecord.SERVICE_INSTANCE_ID, serviceInstanceId)); + } + if (endpointId != 0) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentRecord.ENDPOINT_ID, endpointId)); + } + if (!Strings.isNullOrEmpty(traceId)) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentRecord.TRACE_ID, traceId)); + } + switch (traceState) { + case ERROR: + mustQueryList.add(QueryBuilders.matchQuery(SegmentRecord.IS_ERROR, BooleanUtils.TRUE)); + break; + case SUCCESS: + mustQueryList.add(QueryBuilders.matchQuery(SegmentRecord.IS_ERROR, BooleanUtils.FALSE)); + break; + } + switch (queryOrder) { + case BY_START_TIME: + sourceBuilder.sort(SegmentRecord.START_TIME, SortOrder.DESC); + break; + case BY_DURATION: + sourceBuilder.sort(SegmentRecord.LATENCY, SortOrder.DESC); + break; + } + sourceBuilder.size(limit); + sourceBuilder.from(from); + + SearchResponse response = getClient().search(SegmentRecord.INDEX_NAME, sourceBuilder); + + TraceBrief traceBrief = new TraceBrief(); + traceBrief.setTotal((int) response.getHits().getTotalHits().value); + + for (SearchHit searchHit : response.getHits().getHits()) { + BasicTrace basicTrace = new BasicTrace(); + + basicTrace.setSegmentId((String) searchHit.getSourceAsMap().get(SegmentRecord.SEGMENT_ID)); + basicTrace.setStart(String.valueOf(searchHit.getSourceAsMap().get(SegmentRecord.START_TIME))); + basicTrace.getEndpointNames().add((String) searchHit.getSourceAsMap().get(SegmentRecord.ENDPOINT_NAME)); + basicTrace.setDuration(((Number) searchHit.getSourceAsMap().get(SegmentRecord.LATENCY)).intValue()); + basicTrace.setError(BooleanUtils.valueToBoolean(((Number) searchHit.getSourceAsMap().get(SegmentRecord.IS_ERROR)).intValue())); + basicTrace.getTraceIds().add((String) searchHit.getSourceAsMap().get(SegmentRecord.TRACE_ID)); + traceBrief.getTraces().add(basicTrace); + } + + return traceBrief; + } +} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider new file mode 100644 index 000000000000..1c2f1982bb0d --- /dev/null +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider @@ -0,0 +1,19 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + +org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.StorageModuleElasticsearch7Provider \ No newline at end of file diff --git a/pom.xml b/pom.xml index 1243ec3cc5e8..1ef740cc9f97 100755 --- a/pom.xml +++ b/pom.xml @@ -558,6 +558,7 @@ org/apache/skywalking/oal/rt/grammar/*.class org/apache/skywalking/oap/server/exporter/grpc/*.class org/apache/skywalking/oap/server/configuration/service/*.class + org/apache/skywalking/oap/server/starter/OAPServerStartUp.class org/apache/skywalking/apm/toolkit/**/*Activation.class org/apache/skywalking/apm/plugin/**/*Instrumentation.class diff --git a/test/e2e/e2e-cluster/test-runner/pom.xml b/test/e2e/e2e-cluster/test-runner/pom.xml index d4410d4f5a13..4cda3ba8f02d 100755 --- a/test/e2e/e2e-cluster/test-runner/pom.xml +++ b/test/e2e/e2e-cluster/test-runner/pom.xml @@ -92,8 +92,6 @@ single-node - 500 - 500 @@ -116,6 +114,7 @@ cluster + ${elasticsearch.version} ${e2e.container.name.prefix}-elasticsearch:9200 diff --git a/test/e2e/e2e-cluster/test-runner/src/docker/clusterize.awk b/test/e2e/e2e-cluster/test-runner/src/docker/clusterize.awk index 870e43bb4580..830ede77e2c6 100644 --- a/test/e2e/e2e-cluster/test-runner/src/docker/clusterize.awk +++ b/test/e2e/e2e-cluster/test-runner/src/docker/clusterize.awk @@ -61,7 +61,11 @@ BEGIN { # in the storage: section now # disable h2 module if (in_storage_es_section == 0) { - in_storage_es_section=$0 ~ /^#?\s+elasticsearch:$/ + if (ENVIRON["ES_VERSION"] ~ /^6.+/) { + in_storage_es_section=$0 ~ /^#?\s+elasticsearch:$/ + } else if (ENVIRON["ES_VERSION"] ~ /^7.+/) { + in_storage_es_section=$0 ~ /^#?\s+elasticsearch7:$/ + } } else { in_storage_es_section=$0 ~ /^#?\s{4}/ } diff --git a/test/e2e/e2e-ttl/e2e-ttl-es/pom.xml b/test/e2e/e2e-ttl/e2e-ttl-es/pom.xml index 7d9552476588..e6295cd99da5 100644 --- a/test/e2e/e2e-ttl/e2e-ttl-es/pom.xml +++ b/test/e2e/e2e-ttl/e2e-ttl-es/pom.xml @@ -87,8 +87,6 @@ single-node - 500 - 500 @@ -98,6 +96,7 @@ standalone + ${elasticsearch.version} ${e2e.container.name.prefix}-elasticsearch:9200 diff --git a/test/e2e/e2e-ttl/e2e-ttl-es/src/docker/es_storage.awk b/test/e2e/e2e-ttl/e2e-ttl-es/src/docker/es_storage.awk index 8dbdf75839de..2487b5a4ca8c 100644 --- a/test/e2e/e2e-ttl/e2e-ttl-es/src/docker/es_storage.awk +++ b/test/e2e/e2e-ttl/e2e-ttl-es/src/docker/es_storage.awk @@ -33,7 +33,11 @@ BEGIN { # in the storage: section now # disable h2 module if (in_storage_es_section == 0) { - in_storage_es_section=$0 ~ /^#?\s+elasticsearch:$/ + if (ENVIRON["ES_VERSION"] ~ /^6.+/) { + in_storage_es_section=$0 ~ /^#?\s+elasticsearch:$/ + } else if (ENVIRON["ES_VERSION"] ~ /^7.+/) { + in_storage_es_section=$0 ~ /^#?\s+elasticsearch7:$/ + } } else { in_storage_es_section=$0 ~ /^#?\s{4}/ } diff --git a/test/e2e/run.sh b/test/e2e/run.sh index 5c76cecc269d..97bdac1e3de4 100755 --- a/test/e2e/run.sh +++ b/test/e2e/run.sh @@ -22,6 +22,9 @@ base_dir=$(pwd) build=0 cases=() +DIST_PACKAGE=${DIST_PACKAGE:-apache-skywalking-apm-bin.tar.gz} +ES_VERSION=${ES_VERSION:-6.3.2} + # Parse the arguments # --build-dist: build the distribution package ignoring the existance of `dist` folder, useful when running e2e locally @@ -30,6 +33,9 @@ while [[ $# -gt 0 ]]; do --build) build=1 ;; + --profiles=*) + profiles=${1#*=} + ;; *) cases+=($1) esac @@ -46,7 +52,7 @@ done [[ ${build} -eq 1 ]] \ && echo 'Building distribution package...' \ - && ./mvnw -q -Dcheckstyle.skip -Drat.skip -T2 -Dmaven.compile.fork -DskipTests clean install + && ./mvnw --activate-profiles "${profiles}" -q -Dcheckstyle.skip -Drat.skip -T2 -Dmaven.compile.fork -DskipTests -am clean install echo "Running cases: $(IFS=$' '; echo "${cases[*]}")" @@ -58,9 +64,13 @@ do # Some of the tests will modify files in the distribution folder, e.g. cluster test will modify the application.yml # so we give each test a separate distribution folder here - mkdir -p "$test_case" && tar -zxf dist/apache-skywalking-apm-bin.tar.gz -C "$test_case" - - ./mvnw -Dbuild.id="${BUILD_ID:-local}" -De2e.container.version="${E2E_VERSION}" -Dsw.home="${base_dir}/$test_case/apache-skywalking-apm-bin" -f test/e2e/pom.xml -pl "$test_case" -am verify + mkdir -p "$test_case" && tar -zxf dist/${DIST_PACKAGE} -C "$test_case" + + ./mvnw -Dbuild.id="${BUILD_ID:-local}" \ + -De2e.container.version="${E2E_VERSION}" \ + -Delasticsearch.version="${ES_VERSION}" \ + -Dsw.home="${base_dir}/$test_case/${DIST_PACKAGE//.tar.gz/}" \ + -f test/e2e/pom.xml -pl "$test_case" -am verify status_code=$? diff --git a/tools/dependencies/check-LICENSE.sh b/tools/dependencies/check-LICENSE.sh index 5f2c74ce5f98..f9f762b76dcf 100755 --- a/tools/dependencies/check-LICENSE.sh +++ b/tools/dependencies/check-LICENSE.sh @@ -17,6 +17,8 @@ # limitations under the License. # +tar -zxf dist/apache-skywalking-apm-bin.tar.gz -C dist + # List all modules(jars) that belong to the SkyWalking itself, these will be ignored # when checking the dependency licenses ./mvnw -Pbackend -Dexec.executable='echo' -Dexec.args='${project.artifactId}-${project.version}.jar' exec:exec -q > self-modules.txt @@ -33,3 +35,15 @@ grep -vf self-modules.txt all-dependencies.txt > third-party-dependencies.txt # used to sort the file `known-oap-backend-dependencies.txt`, # i.e. "sort the two file using the same command (and default arguments)" diff -w -B -U0 <(cat tools/dependencies/known-oap-backend-dependencies.txt | sort) <(cat third-party-dependencies.txt | sort) + +[[ $? -ne 0 ]] && exit $? + +# Check ES7 distribution package + +tar -zxf dist/apache-skywalking-apm-bin-es7.tar.gz -C dist + +ls dist/apache-skywalking-apm-bin-es7/oap-libs > all-dependencies-es7.txt + +grep -vf self-modules.txt all-dependencies-es7.txt > third-party-dependencies-es7.txt + +diff -w -B -U0 <(cat tools/dependencies/known-oap-backend-dependencies-es7.txt | sort) <(cat third-party-dependencies-es7.txt | sort) diff --git a/tools/dependencies/known-oap-backend-dependencies-es7.txt b/tools/dependencies/known-oap-backend-dependencies-es7.txt new file mode 100755 index 000000000000..b9e1a87c55e4 --- /dev/null +++ b/tools/dependencies/known-oap-backend-dependencies-es7.txt @@ -0,0 +1,158 @@ +aggs-matrix-stats-client-7.0.0.jar +animal-sniffer-annotations-1.14.jar +annotations-13.0.jar +antlr4-runtime-4.7.1.jar +aopalliance-1.0.jar +apollo-client-1.4.0.jar +apollo-core-1.4.0.jar +bcpkix-jdk15on-1.59.jar +bcprov-ext-jdk15on-1.59.jar +bcprov-jdk15on-1.59.jar +builder-annotations-0.9.2.jar +client-java-4.0.0.jar +client-java-api-4.0.0.jar +client-java-proto-4.0.0.jar +commons-codec-1.11.jar +commons-compress-1.18.jar +commons-dbcp-1.4.jar +commons-io-2.6.jar +commons-lang3-3.7.jar +commons-pool-1.5.4.jar +commons-text-1.4.jar +consul-client-1.2.6.jar +converter-jackson-2.3.0.jar +compiler-0.9.3.jar +curator-client-4.0.1.jar +curator-framework-4.0.1.jar +curator-recipes-4.0.1.jar +curator-x-discovery-4.0.1.jar +elasticsearch-7.0.0.jar +elasticsearch-cli-7.0.0.jar +elasticsearch-core-7.0.0.jar +elasticsearch-geo-7.0.0.jar +elasticsearch-rest-client-7.0.0.jar +elasticsearch-rest-high-level-client-7.0.0.jar +elasticsearch-secure-sm-7.0.0.jar +elasticsearch-x-content-7.0.0.jar +error_prone_annotations-2.0.18.jar +etcd4j-2.17.0.jar +fastjson-1.2.47.jar +freemarker-2.3.28.jar +graphql-java-8.0.jar +graphql-java-tools-5.2.3.jar +groovy-2.4.5-indy.jar +grpc-context-1.15.1.jar +grpc-core-1.15.1.jar +grpc-netty-1.15.1.jar +grpc-protobuf-1.15.1.jar +grpc-protobuf-lite-1.15.1.jar +grpc-stub-1.15.1.jar +gson-2.8.1.jar +guava-23.1-jre.jar +guice-4.1.0.jar +h2-1.4.196.jar +HdrHistogram-2.1.9.jar +HikariCP-3.1.0.jar +hppc-0.7.1.jar +httpasyncclient-4.1.4.jar +httpclient-4.5.7.jar +httpcore-4.4.11.jar +httpcore-nio-4.4.11.jar +jackson-annotations-2.9.5.jar +jackson-core-2.9.5.jar +jackson-core-asl-1.9.13.jar +jackson-databind-2.9.5.jar +jackson-dataformat-cbor-2.8.11.jar +jackson-dataformat-smile-2.8.11.jar +jackson-dataformat-yaml-2.8.11.jar +jackson-datatype-guava-2.9.5.jar +jackson-datatype-jdk8-2.9.5.jar +jackson-mapper-asl-1.9.13.jar +jackson-module-afterburner-2.9.5.jar +jackson-module-kotlin-2.8.8.jar +java-dataloader-2.0.2.jar +javassist-3.25.0-GA.jar +javax.inject-1.jar +javax.servlet-api-3.1.0.jar +jcl-over-slf4j-1.7.25.jar +jetty-http-9.4.2.v20170220.jar +jetty-io-9.4.2.v20170220.jar +jetty-security-9.4.2.v20170220.jar +jetty-server-9.4.2.v20170220.jar +jetty-servlet-9.4.2.v20170220.jar +jetty-util-9.4.2.v20170220.jar +jline-0.9.94.jar +jna-4.5.1.jar +joda-convert-1.2.jar +joda-time-2.10.5.jar +jopt-simple-4.6.jar +json-flattener-0.6.0.jar +jsr305-1.3.9.jar +kotlin-reflect-1.1.1.jar +kotlin-stdlib-1.1.60.jar +lang-mustache-client-7.0.0.jar +log4j-1.2.16.jar +log4j-api-2.9.0.jar +log4j-core-2.9.0.jar +log4j-over-slf4j-1.7.25.jar +log4j-slf4j-impl-2.9.0.jar +logging-interceptor-2.7.5.jar +lucene-analyzers-common-8.0.0.jar +lucene-backward-codecs-8.0.0.jar +lucene-core-8.0.0.jar +lucene-grouping-8.0.0.jar +lucene-highlighter-8.0.0.jar +lucene-join-8.0.0.jar +lucene-memory-8.0.0.jar +lucene-misc-8.0.0.jar +lucene-queries-8.0.0.jar +lucene-queryparser-8.0.0.jar +lucene-sandbox-8.0.0.jar +lucene-spatial-8.0.0.jar +lucene-spatial-extras-8.0.0.jar +lucene-spatial3d-8.0.0.jar +lucene-suggest-8.0.0.jar +minimal-json-0.9.5.jar +nacos-api-1.0.0.jar +nacos-client-1.0.0.jar +nacos-common-1.0.0.jar +netty-3.10.5.Final.jar +netty-buffer-4.1.27.Final.jar +netty-codec-4.1.27.Final.jar +netty-codec-dns-4.1.27.Final.jar +netty-codec-http-4.1.27.Final.jar +netty-codec-http2-4.1.27.Final.jar +netty-codec-socks-4.1.27.Final.jar +netty-common-4.1.27.Final.jar +netty-handler-4.1.27.Final.jar +netty-handler-proxy-4.1.27.Final.jar +netty-resolver-4.1.27.Final.jar +netty-resolver-dns-4.1.27.Final.jar +netty-tcnative-boringssl-static-2.0.7.Final.jar +netty-transport-4.1.27.Final.jar +okhttp-2.7.5.jar +okhttp-3.9.0.jar +okhttp-ws-2.7.5.jar +okio-1.13.0.jar +opencensus-api-0.12.3.jar +opencensus-contrib-grpc-metrics-0.12.3.jar +parent-join-client-7.0.0.jar +proto-google-common-protos-1.0.0.jar +protobuf-java-3.4.0.jar +rank-eval-client-7.0.0.jar +reactive-streams-1.0.2.jar +reflectasm-1.11.7.jar +resourcecify-annotations-0.9.2.jar +retrofit-2.3.0.jar +sharding-jdbc-core-2.0.3.jar +simpleclient-0.6.0.jar +simpleclient_common-0.6.0.jar +simpleclient_hotspot-0.6.0.jar +simpleclient_httpserver-0.6.0.jar +slf4j-api-1.7.25.jar +snakeyaml-1.18.jar +sundr-codegen-0.9.2.jar +sundr-core-0.9.2.jar +swagger-annotations-1.5.12.jar +t-digest-3.2.jar +zookeeper-3.4.10.jar