diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/trace/ServiceTypeProperty.java b/commons/src/main/java/com/navercorp/pinpoint/common/trace/ServiceTypeProperty.java index 2bfdbe2a1f66c..7d54ed6257b4a 100644 --- a/commons/src/main/java/com/navercorp/pinpoint/common/trace/ServiceTypeProperty.java +++ b/commons/src/main/java/com/navercorp/pinpoint/common/trace/ServiceTypeProperty.java @@ -24,5 +24,6 @@ public enum ServiceTypeProperty { QUEUE, RECORD_STATISTICS, INCLUDE_DESTINATION_ID, + @Deprecated ALIAS } diff --git a/plugins-it/elasticsearch-bbose-it/pom.xml b/plugins-it/elasticsearch-bbose-it/pom.xml deleted file mode 100644 index c28502e3b663e..0000000000000 --- a/plugins-it/elasticsearch-bbose-it/pom.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - 4.0.0 - - com.navercorp.pinpoint - pinpoint-plugins-it - 2.5.0-SNAPSHOT - - - pinpoint-elasticsearch-bboss-plugin-it - - jar - - - 1.8 - ${env.JAVA_8_HOME} - - - - - com.bbossgroups.plugins - bboss-elasticsearch-rest-jdbc - 5.6.9 - test - - - org.slf4j - slf4j-log4j12 - - - com.bbossgroups - bboss-persistent - - - - - org.elasticsearch.client - elasticsearch-rest-high-level-client - 7.3.0 - test - - - pl.allegro.tech - embedded-elasticsearch - 2.10.0 - test - - - - com.navercorp.pinpoint - pinpoint-plugin-it-utils - ${project.version} - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - org.apache.maven.plugins - maven-failsafe-plugin - - ${env.JAVA_8_HOME}/bin/java - - - - - diff --git a/plugins-it/elasticsearch-bbose-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/Car.java b/plugins-it/elasticsearch-bbose-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/Car.java deleted file mode 100644 index bf0c1fd0ce768..0000000000000 --- a/plugins-it/elasticsearch-bbose-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/Car.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2018 Naver Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance,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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - -import com.frameworkset.orm.annotation.ESId; - -/** - *

Description: Car PO along to cars indice mapping struction

- * - * @author yinbp[yin-bp@163.com] - */ -public class Car { - @ESId(persistent = true, readSet = true) - private String carId; - private String manufacturer; - private String model; - private String description; - - public String getManufacturer() { - return manufacturer; - } - - public void setManufacturer(String manufacturer) { - this.manufacturer = manufacturer; - } - - public String getModel() { - return model; - } - - public void setModel(String model) { - this.model = model; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCarId() { - return carId; - } - - public void setCarId(String carId) { - this.carId = carId; - } -} \ No newline at end of file diff --git a/plugins-it/elasticsearch-bbose-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchExecutor569IT.java b/plugins-it/elasticsearch-bbose-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchExecutor569IT.java deleted file mode 100644 index b4da183527036..0000000000000 --- a/plugins-it/elasticsearch-bbose-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchExecutor569IT.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - - -import com.navercorp.pinpoint.pluginit.utils.AgentPath; -import com.navercorp.pinpoint.test.plugin.Dependency; -import com.navercorp.pinpoint.test.plugin.JvmVersion; -import com.navercorp.pinpoint.test.plugin.PinpointAgent; -import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite; -import org.junit.runner.RunWith; - - -/** - * @author yinbp[yin-bp@163.com] - */ - -@RunWith(PinpointPluginTestSuite.class) -@PinpointAgent(AgentPath.PATH) -@Dependency({"com.bbossgroups.plugins:bboss-elasticsearch-rest-jdbc:[5.6.9,5.8.3)", - "pl.allegro.tech:embedded-elasticsearch:2.8.0"}) -@JvmVersion(8) -public class ElasticsearchExecutor569IT extends ElasticsearchExecutorIT { - - -} \ No newline at end of file diff --git a/plugins-it/elasticsearch-bbose-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchExecutorIT.java b/plugins-it/elasticsearch-bbose-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchExecutorIT.java deleted file mode 100644 index 01bdee27ed414..0000000000000 --- a/plugins-it/elasticsearch-bbose-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchExecutorIT.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - - -import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier; -import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifierHolder; -import com.navercorp.pinpoint.test.plugin.shared.AfterSharedClass; -import com.navercorp.pinpoint.test.plugin.shared.BeforeSharedClass; - -import org.frameworkset.elasticsearch.ElasticSearchHelper; -import org.frameworkset.elasticsearch.client.ClientInterface; -import org.frameworkset.elasticsearch.entity.ESDatas; -import org.junit.BeforeClass; -import org.junit.Test; -import pl.allegro.tech.embeddedelasticsearch.EmbeddedElastic; -import pl.allegro.tech.embeddedelasticsearch.PopularProperties; - -import java.io.IOException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static com.navercorp.pinpoint.bootstrap.plugin.test.Expectations.event; -import static java.util.concurrent.TimeUnit.MINUTES; - - -/** - * @author yinbp[yin-bp@163.com] - */ - - -public abstract class ElasticsearchExecutorIT { - private static EmbeddedElastic embeddedElastic; - private static ClientInterface clientInterface; - private static ClientInterface configRestClientInterface; - private String serviceType = "ElasticsearchBBoss"; - - @BeforeSharedClass - public static void sharedSetup() throws IOException, InterruptedException { - // BBoss support elasticsearch 1.x,2.x,5.x,6.x,7.x,+ - // and we use elasticsearch 6.3.0 to test the Elasticsearch BBoss client plugin. - - // BBoss connect elasticsearch use localhost and http port 9200 default. - -// Here is a bboss web demo base spring boot and elasticsearch 5.x,6.x,7.x,8.x: -// https://github.com/bbossgroups/es_bboss_web -// -// Here is a quickstart tutorial: -// https://esdoc.bbossgroups.com/#/quickstart - embeddedElastic = EmbeddedElastic.builder() - .withElasticVersion("6.8.0") - .withSetting(PopularProperties.HTTP_PORT, 9200) - .withEsJavaOpts("-Xms128m -Xmx512m") - .withStartTimeout(2, MINUTES) - .build() - .start(); - } - - @AfterSharedClass - public static void sharedTearDown() { - if (embeddedElastic != null) { - embeddedElastic.stop(); - } - } - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - //Build a elasticsearch client instance(Return a single instance but multithreaded security) with dsl config file elasticsearchbboss/car-mapping.xml. - configRestClientInterface = ElasticSearchHelper.getConfigRestClientUtil("elasticsearchbboss/car-mapping.xml"); - // Create an elasticsearch client interface instance with a specific Elasticserch datasource name and with dsl config file elasticsearchbboss/car-mapping.xml. - //configRestClientInterface = ElasticSearchHelper.getConfigRestClientUtil("esdatasourceName","elasticsearchbboss/car-mapping.xml"); - - //build a elasticsearch client instance(Return a single instance but multithreaded security) for do not need dsl or direct dsl operations. - clientInterface = ElasticSearchHelper.getRestClientUtil(); - // Create an elasticsearch client interface instance with a specific Elasticserch datasource name - //clientInterface = ElasticSearchHelper.getRestClientUtil("esdatasourceName"); - - // A multidatasource spring boot demo: https://github.com/bbossgroups/es_bboss_web/tree/multiesdatasource - } - - @Test - public void indiceCreate() throws Exception { - PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance(); - Class configClass = Class.forName("org.frameworkset.elasticsearch.client.ConfigRestClientUtil"); - Method createIndiceMappingMethod = configClass.getMethod("createIndiceMapping", String.class, String.class); - try { - configRestClientInterface.createIndiceMapping("cars", "createCarIndice"); - - } catch (Exception ignored) { - - } - - verifier.verifyTrace(event(serviceType, createIndiceMappingMethod)); - - - } - - @Test - public void indiceDrop() throws Exception { - PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance(); - Class configClass = Class.forName("org.frameworkset.elasticsearch.client.ConfigRestClientUtil"); - Method dropIndiceMethod = configClass.getMethod("dropIndice", String.class); - try { - configRestClientInterface.dropIndice("cars"); - } catch (Exception ignored) { - - } - - verifier.verifyTrace(event(serviceType, dropIndiceMethod)); - - - } - - @Test - public void indiceExist() throws Exception { - - //Validate the indice twitter exist or not - PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance(); - - //Validate the indice cars exist or not - boolean existIndice = clientInterface.existIndice("cars"); - -// Assert.assertEquals(existIndice,true); - Class restClientUtilClass = Class.forName("org.frameworkset.elasticsearch.client.RestClientUtil"); - Method existIndiceMethod = restClientUtilClass.getMethod("existIndice", String.class); - verifier.verifyTrace(event(serviceType, existIndiceMethod)); - - } - - @Test - public void addDocument() throws Exception { - Class restClientUtilClass = Class.forName("org.frameworkset.elasticsearch.client.RestClientUtil"); - Method addDocumentMethod = restClientUtilClass.getDeclaredMethod("addDocument", String.class, String.class, - Object.class, String.class); - PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance(); - Car car = new Car(); - //set carid as the index documentid - car.setCarId("1"); - car.setManufacturer("Volkswagenwerk"); - car.setModel("passat1.8T"); - car.setDescription("passat 2018"); - - //add data to cars/car indice. Use force refresh when test case,but product mode does not use forcerefresh - // and should use: - // clientInterface.addDocument("cars",car). - try { - clientInterface.addDocument("cars", "car", car, "refresh=true"); - } catch (Exception ignored) { - - } - - verifier.verifyTrace(event(serviceType, addDocumentMethod)); - - } - - @Test - public void getDocument() throws Exception { - PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance(); - //get car by document id "1" - try { - Car car = clientInterface.getDocument("cars", "1", Car.class); - } catch (Exception ignored) { - - } - - - Class restClientUtilClass = Class.forName("org.frameworkset.elasticsearch.client.RestClientUtil"); - Method getDocumentMethod = restClientUtilClass.getDeclaredMethod("getDocument", String.class, - String.class, Class.class); - verifier.verifyTrace(event(serviceType, getDocumentMethod)); - } - - @Test - public void bulkDocuments() throws Exception { - PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance(); - List cars = new ArrayList<>(); - Car car = new Car(); - //set carid as the index documentid - car.setCarId("2"); - car.setManufacturer("Volkswagenwerk"); - car.setModel("passat1.8T"); - car.setDescription("passat 2018"); - cars.add(car); - car = new Car(); - //set carid as the index documentid - car.setCarId("3"); - car.setManufacturer("Volkswagenwerk"); - car.setModel("2.0T"); - car.setDescription("passat 2019"); - cars.add(car); - //add datas to cars/car indice.Use force refresh when test case,but product mode does not use forcerefresh - // and should use: - // clientInterface.addDocuments("cars",cars); - - try { - clientInterface.addDocuments("cars", "car", cars, "refresh=true"); - } catch (Exception ignored) { - - } - Class restClientUtilClass = Class.forName("org.frameworkset.elasticsearch.client.RestClientUtil"); - Method addDocumentsMethod = restClientUtilClass.getDeclaredMethod("addDocuments", String.class, String.class, - List.class, String.class); - verifier.verifyTrace(event(serviceType, addDocumentsMethod)); - - } - - - @Test - public void searchDocuments() throws Exception { - PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance(); - try { - Map condition = new HashMap<>(); - //set description as search condition - condition.put("description", "passat"); - - //search data to cars/car indice that match condition with a simple query dsl named testSearch defined in elasticsearchbboss/car-mapping.xml. - ESDatas carESDatas = configRestClientInterface.searchList("cars/_search", "testSearch", condition, Car.class); - //datas that match condition - List cars = carESDatas.getDatas(); - //totalsize that match condition - long totalSize = carESDatas.getTotalSize(); - } catch (Exception ignored) { - - } - - Class configClass = Class.forName("org.frameworkset.elasticsearch.client.ConfigRestClientUtil"); - Method searchListMethod = configClass.getDeclaredMethod("searchList", String.class, - String.class, Map.class, Class.class); - verifier.verifyTrace(event(serviceType, searchListMethod)); - } - - @Test - public void updateDocument() throws Exception { - PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance(); - Car car = new Car(); - //set carid as the index documentid - car.setCarId("1"); - car.setManufacturer("Volkswagenwerk"); - // Update model from 1.4T to 1.0T - car.setModel("1.0T"); - car.setDescription("passat 2017"); - // Update data on cars/car indice that document id is 1. - // Use force refresh when test case,but product mode does not use forcerefresh - // and should use: - // clientInterface.updateDocument("cars","1",car); - - try { - clientInterface.updateDocument("cars", "car", "1", car, "refresh=true"); - } catch (Exception ignored) { - - } - Class restClientUtilClass = Class.forName("org.frameworkset.elasticsearch.client.RestClientUtil"); - Method updateDocumentMethod = restClientUtilClass.getDeclaredMethod("updateDocument", String.class, String.class, - Object.class, Object.class, String.class); - verifier.verifyTrace(event(serviceType, updateDocumentMethod)); - - } - - @Test - public void deleteDocument() throws Exception { - PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance(); - // Delete data on cars/car indice that document id is 1. - // Use force refresh when test case,but product mode does not use forcerefresh - // and should use: - // clientInterface.deleteDocument("cars","1"); - - try { - clientInterface.deleteDocument("cars", "car", "1", "refresh=true"); - } catch (Exception ignored) { - - } - Class restClientUtilClass = Class.forName("org.frameworkset.elasticsearch.client.RestClientUtil"); - Method deleteDocument = restClientUtilClass.getDeclaredMethod("deleteDocument", String.class, String.class, - String.class, String.class); - verifier.verifyTrace(event(serviceType, deleteDocument)); - - } - -} \ No newline at end of file diff --git a/plugins-it/elasticsearch-bbose-it/src/test/resources/elasticsearchbboss/car-mapping.xml b/plugins-it/elasticsearch-bbose-it/src/test/resources/elasticsearchbboss/car-mapping.xml deleted file mode 100644 index b64824e9954ba..0000000000000 --- a/plugins-it/elasticsearch-bbose-it/src/test/resources/elasticsearchbboss/car-mapping.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/plugins-it/pom.xml b/plugins-it/pom.xml index 2994ed7517225..54fe7173aaec1 100644 --- a/plugins-it/pom.xml +++ b/plugins-it/pom.xml @@ -38,7 +38,6 @@ cxf-it druid-it dubbo-it - elasticsearch-bbose-it elasticsearch-it elasticsearch-7.16-it fastjson-it diff --git a/plugins/elasticsearch-bboss/README.md b/plugins/elasticsearch-bboss/README.md deleted file mode 100644 index d1aba2ce1fca8..0000000000000 --- a/plugins/elasticsearch-bboss/README.md +++ /dev/null @@ -1,155 +0,0 @@ -ElasticSearch is an Open Source (Apache 2), Distributed, RESTful, Search Engine built on top of Apache Lucene. - -This agent plugin is worked with elasticsearch bboss highlevel rest client [BBoss][bs]. - -[BBoss][bs] is a best Java Highlevel Rest client for [ElasticSearch][es]. - - -If there is trace in the context, add context trace as span event. - -Some work pictures of this plugin: -Elasticsearch Bboss work in tomcat -![GitHub Logo](https://oscimg.oschina.net/oscnet/a6aa8b7e84db0437dd6cbff88bdf1160fab.jpg) -![GitHub Logo](https://oscimg.oschina.net/oscnet/9665c0376579bbf1ca6093c1a0cf11c6c45.jpg) -Async parallel slice scoll query -![GitHub Logo](https://oscimg.oschina.net/oscnet/2ad63bcb0ad2de30a2cc13aa5f8a8ea86b4.jpg) -Simple indice and indice type exist query -![GitHub Logo](https://oscimg.oschina.net/oscnet/4c2e63e159786c28909ca2a003c8ee28432.jpg) -dsl query -![GitHub Logo](https://oscimg.oschina.net/oscnet/90fe224aee8b52c50b22fdfe0860658324d.jpg) - - -How to use Elasticsearch BBoss. - -First add the maven dependency of BBoss to your pom.xml: - -```xml - - com.bbossgroups.plugins - bboss-elasticsearch-rest-jdbc - 5.6.9 - -``` - -If it's a spring boot project, you can replace the Maven coordinates above with the following Maven coordinates: - -```xml - - com.bbossgroups.plugins - bboss-elasticsearch-spring-boot-starter - 5.6.9 - -``` - - - -Next, add the Elasticsearch addresses to the application.properties file under the project resource directory, and create a new one if the file does not exist: - -```properties -elasticsearch.rest.hostNames=10.21.20.168:9200 - -#Cluster addresses are separated by commas - -#elasticsearch.rest.hostNames=10.180.211.27:9200,10.180.211.28:9200,10.180.211.29:9200 -``` - - - -And last create a jsp file named testElasticsearch.jsp : - -```jsp -<%@ page import="org.frameworkset.elasticsearch.ElasticSearchHelper" %> -<%@ page import="org.frameworkset.elasticsearch.client.ClientInterface" %> -<%@ page import="org.frameworkset.elasticsearch.entity.ESDatas" %> -<%@ page import="org.frameworkset.elasticsearch.scroll.ScrollHandler" %> -<%@ page import="java.util.List" %> -<%@ page import="java.util.Map" %> -<%@ page import="org.frameworkset.elasticsearch.scroll.HandlerInfo" %> -<%@ page language="java" pageEncoding="UTF-8"%> - -<% - ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil(); - //get elasticsearch cluster state - String result = clientUtil.executeHttp("_cluster/state?pretty",ClientInterface.HTTP_GET); - - //check indice twitter and index type tweet exist or not. - boolean exist1 = clientUtil.existIndiceType("twitter","tweet"); - out.println("twitter tweet type exist:"+exist1); - //check indice twitter exist or not - exist1 = clientUtil.existIndice("twitter"); - out.println("twitter exist:"+exist1); - //count documents in indice twitter - long count = clientUtil.countAll("demo"); - out.println(count); - - //Get All documents of indice twitter,DEFAULT_FETCHSIZE is 5000 - ESDatas esDatas = clientUtil.searchAll("demo", Map.class); - - //Get All documents of indice twitter,Set fetchsize to 10000, Using ScrollHandler to process each batch of datas. - clientUtil.searchAll("demo",10000,new ScrollHandler() { - public void handle(ESDatas esDatas, HandlerInfo handlerInfo) throws Exception { - List dataList = esDatas.getDatas(); - System.out.println("TotalSize:"+esDatas.getTotalSize()); - if(dataList != null) { - System.out.println("dataList.size:" + dataList.size()); - } - else - { - System.out.println("dataList.size:0"); - } - //do something other such as do a db query. - //SQLExecutor.queryList(Map.class,"select * from td_sm_user"); - } - },Map.class); - //Use slice parallel scoll query all documents of indice twitter by 2 thread tasks. DEFAULT_FETCHSIZE is 5000 - //You can also use ScrollHandler to process each batch of datas on your own. - clientUtil.searchAllParallel("demo", Map.class,2); - //use query dsl to execute scroll search and use ScrollHandler to parallel handle each page scroll search result. - clientUtil.scrollParallel("demo/_search","{ \"size\":10,\"query\": {\"match_all\": {}},\"sort\": [\"_doc\"]}","1m",Map.class,new ScrollHandler() { - public void handle(ESDatas esDatas, HandlerInfo handlerInfo) throws Exception { - List dataList = esDatas.getDatas(); - System.out.println("TotalSize:"+esDatas.getTotalSize()); - if(dataList != null) { - System.out.println("dataList.size:" + dataList.size()); - } - else - { - System.out.println("dataList.size:0"); - } - //do something other such as do a db query. - //SQLExecutor.queryList(Map.class,"select * from td_sm_user"); - } - }); - out.println("searchAllParallel:ok"); -%> - -``` - -Put the file into the web project that has been connected to pinpoint, run the program, log on pinpoint to see the execution effect of bboss plugin. - -For more BBoss Elasticsearch Highlevel Rest Client detail see : - https://esdoc.bbossgroups.com/#/README - -github sourcecode: -https://github.com/bbossgroups/bboss-elasticsearch - -Fast import bboss to your project: -1. For Spring boot project see -https://esdoc.bbossgroups.com/#/spring-booter-with-bboss -2. For normal maven or gradle project see -https://esdoc.bbossgroups.com/#/common-project-with-bboss - -ElasticsearchBBoss Demo - -[eshelloworld-booter][booter] - -[eshelloword-spring-boot-starter][springbooter] - -[booter]: https://github.com/bbossgroups/elasticsearch-example -[springbooter]: https://github.com/bbossgroups/elasticsearch-springboot-example - -[bs]: https://github.com/bbossgroups/bboss-elasticsearch -[es]: http://www.elasticsearch.org -[DocumentCRUDTest]: https://github.com/bbossgroups/elasticsearch-example/blob/master/src/test/java/org/bboss/elasticsearchtest/crud/DocumentCRUDTest.java - - diff --git a/plugins/elasticsearch-bboss/mysql.png b/plugins/elasticsearch-bboss/mysql.png deleted file mode 100644 index 1b5daba3b4515..0000000000000 Binary files a/plugins/elasticsearch-bboss/mysql.png and /dev/null differ diff --git a/plugins/elasticsearch-bboss/pom.xml b/plugins/elasticsearch-bboss/pom.xml deleted file mode 100644 index 4bb78f1878017..0000000000000 --- a/plugins/elasticsearch-bboss/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - 4.0.0 - - com.navercorp.pinpoint - pinpoint-plugins - 2.5.0-SNAPSHOT - - pinpoint-elasticsearch-bboss-plugin - pinpoint-elasticsearch-bboss-plugin - jar - - - - - - - com.navercorp.pinpoint - pinpoint-bootstrap-core - provided - - - - diff --git a/plugins/elasticsearch-bboss/problem1.png b/plugins/elasticsearch-bboss/problem1.png deleted file mode 100644 index e12ec385f097e..0000000000000 Binary files a/plugins/elasticsearch-bboss/problem1.png and /dev/null differ diff --git a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ClusterVersionAccessor.java b/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ClusterVersionAccessor.java deleted file mode 100644 index 535d96ce70758..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ClusterVersionAccessor.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - -/** - * @author yinbp[yin-bp@163.com] - */ -public interface ClusterVersionAccessor { - void _$PINPOINT$_setClusterVersion(String clusterVersion); - String _$PINPOINT$_getClusterVersion(); -} diff --git a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchConstants.java b/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchConstants.java deleted file mode 100644 index bf56ebb15821b..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchConstants.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - -import com.navercorp.pinpoint.common.trace.*; - -import static com.navercorp.pinpoint.common.trace.ServiceTypeProperty.*; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchConstants { - public static final AnnotationKey ARGS_ANNOTATION_KEY = AnnotationKeyFactory.of(171, "es.args", AnnotationKeyProperty.VIEW_IN_RECORD_SET); - public static final int maxDslSize = 50000; - public static final ServiceType ELASTICSEARCH = ServiceTypeFactory.of(9201, "ElasticsearchBBoss"); - - public static final AnnotationKey ARGS_URL_ANNOTATION_KEY = AnnotationKeyFactory.of(172, "es.url", AnnotationKeyProperty.VIEW_IN_RECORD_SET); - public static final AnnotationKey ARGS_DSL_ANNOTATION_KEY = AnnotationKeyFactory.of(173, "es.dsl", AnnotationKeyProperty.VIEW_IN_RECORD_SET); - public static final AnnotationKey ARGS_ACTION_ANNOTATION_KEY = AnnotationKeyFactory.of(174, "es.action", AnnotationKeyProperty.VIEW_IN_RECORD_SET); - public static final AnnotationKey ARGS_RESPONSEHANDLE_ANNOTATION_KEY = AnnotationKeyFactory.of(175, "es.responseHandle", AnnotationKeyProperty.VIEW_IN_RECORD_SET); - public static final AnnotationKey ARGS_VERSION_ANNOTATION_KEY = AnnotationKeyFactory.of(176, "es.version", AnnotationKeyProperty.VIEW_IN_RECORD_SET); - public static final ServiceType ELASTICSEARCH_EXECUTOR = ServiceTypeFactory.of(9202, "ElasticsearchBBossExecutor", ALIAS); - public static final String ELASTICSEARCH_SCOPE = "ElasticsearchBBoss_SCOPE"; - public static final String ELASTICSEARCH_Parallel_SCOPE = "ElasticsearchBBoss_Parallel_SCOPE"; - public static final String ELASTICSEARCH_EXECUTOR_SCOPE = "ElasticsearchBBossExecutor_SCOPE"; - public static final String[] clazzInterceptors = new String[]{ - "org.frameworkset.elasticsearch.client.ConfigRestClientUtil", - "org.frameworkset.elasticsearch.client.RestClientUtil" - }; -} diff --git a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchCustomMethodFilter.java b/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchCustomMethodFilter.java deleted file mode 100644 index 2e3dea07022f9..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchCustomMethodFilter.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - - -import com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod; -import com.navercorp.pinpoint.bootstrap.instrument.MethodFilter; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchCustomMethodFilter implements MethodFilter { - - public ElasticsearchCustomMethodFilter( ) { - } - - @Override - public boolean accept(InstrumentMethod method) { - - - if(method.getName().equals("runSliceTask") - || method.getName().equals("runScrollTask") - || method.getName().equals("runSliceScrollTask") ){ //parallel handle method - return REJECT; - } - else - { - return ACCEPT; - } - } - -} diff --git a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchMetadataProvider.java b/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchMetadataProvider.java deleted file mode 100644 index e15b1a6db7730..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchMetadataProvider.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - -import com.navercorp.pinpoint.common.trace.TraceMetadataProvider; -import com.navercorp.pinpoint.common.trace.TraceMetadataSetupContext; - - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchMetadataProvider implements TraceMetadataProvider { - - @Override - public void setup(TraceMetadataSetupContext context) { - - if(context == null) - return; - context.addServiceType(ElasticsearchConstants.ELASTICSEARCH); - context.addServiceType(ElasticsearchConstants.ELASTICSEARCH_EXECUTOR); - - context.addAnnotationKey(ElasticsearchConstants.ARGS_VERSION_ANNOTATION_KEY);//Elasticsearch version info - context.addAnnotationKey(ElasticsearchConstants.ARGS_URL_ANNOTATION_KEY);//HTTP request URL parameters - context.addAnnotationKey(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY);//HTTP DSL body conent - context.addAnnotationKey(ElasticsearchConstants.ARGS_ACTION_ANNOTATION_KEY);//HTTP Elasticsearch restful ACTION method - context.addAnnotationKey(ElasticsearchConstants.ARGS_RESPONSEHANDLE_ANNOTATION_KEY);//HTTP Response handler class name, - context.addAnnotationKey(ElasticsearchConstants.ARGS_ANNOTATION_KEY);//Elasticsearch client api arguments - - } - -} diff --git a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchPlugin.java b/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchPlugin.java deleted file mode 100644 index 152dfae78bf47..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchPlugin.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - -import com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor; -import com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass; -import com.navercorp.pinpoint.bootstrap.instrument.InstrumentException; -import com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod; -import com.navercorp.pinpoint.bootstrap.instrument.Instrumentor; -import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback; -import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformTemplate; -import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformTemplateAware; -import com.navercorp.pinpoint.bootstrap.interceptor.scope.ExecutionPolicy; -import com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScope; -import com.navercorp.pinpoint.bootstrap.logging.PLogger; -import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory; -import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin; -import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPluginSetupContext; -import com.navercorp.pinpoint.plugin.elasticsearchbboss.interceptor.*; - -import java.security.ProtectionDomain; -import java.util.List; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchPlugin implements ProfilerPlugin, TransformTemplateAware { - - - - - private final PLogger logger = PLoggerFactory.getLogger(this.getClass()); - private TransformTemplate transformTemplate; - private static RestSeachExecutorMethodFilter restSeachExecutorMethodFilter = new RestSeachExecutorMethodFilter(); - static final ElasticsearchCustomMethodFilter elasticsearchCustomMethodFilter = new ElasticsearchCustomMethodFilter(); - @Override - public void setup(ProfilerPluginSetupContext context) { - if (context == null) { - return; - } - - final ElasticsearchPluginConfig elasticsearchPluginConfig = new ElasticsearchPluginConfig(context.getConfig()); - if (logger.isInfoEnabled()) { - logger.info("ElasticsearchPlugin config:{}", elasticsearchPluginConfig); - } - - if (!elasticsearchPluginConfig.isEnabled()) { - return; - } - addElasticsearchInterceptors(); - addElasticsearchExecutorInterceptors(); - this.addParallelElasticsearchInterceptors(); - } - - - // implementations - private void addElasticsearchInterceptors() { - transformTemplate.transform("org.frameworkset.elasticsearch.client.ConfigRestClientUtil",ConfigRestClientTransformCallback.class); - transformTemplate.transform("org.frameworkset.elasticsearch.client.RestClientUtil",RestClientTransformCallback.class); - - } - - // implementations - private void addElasticsearchExecutorInterceptors() { - - transformTemplate.transform("org.frameworkset.elasticsearch.client.RestSearchExecutor", RestSearchExecutorTransformCallback.class); - - - } - - // implementations - private void addParallelElasticsearchInterceptors() { - - transformTemplate.transform("org.frameworkset.elasticsearch.SliceRunTask", ParallelRunTaskTransformCallback.class); - transformTemplate.transform("org.frameworkset.elasticsearch.scroll.thread.ScrollTask", ParallelRunTaskTransformCallback.class); - } - - @Override - public void setTransformTemplate(TransformTemplate transformTemplate) { - this.transformTemplate = transformTemplate; - } - - public static class RestSearchExecutorTransformCallback implements TransformCallback{ - @Override - public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, - String className, Class classBeingRedefined, ProtectionDomain protectionDomain, - byte[] classfileBuffer) throws InstrumentException { - - final InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer); - target.addField(ClusterVersionAccessor.class); - final List methodsToTrace = target.getDeclaredMethods(restSeachExecutorMethodFilter); - for (InstrumentMethod methodToTrace : methodsToTrace) { - - methodToTrace.addScopedInterceptor(ElasticsearchExecutorOperationInterceptor.class, ElasticsearchConstants.ELASTICSEARCH_EXECUTOR_SCOPE, ExecutionPolicy.ALWAYS); - } - - return target.toBytecode(); - } - - } - - public static class ParallelRunTaskTransformCallback implements TransformCallback{ - @Override - public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, - String className, Class classBeingRedefined, ProtectionDomain protectionDomain, - byte[] classfileBuffer) throws InstrumentException { - - final InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer); - InterceptorScope scope = instrumentor.getInterceptorScope(ElasticsearchConstants.ELASTICSEARCH_Parallel_SCOPE); - - target.addField(AsyncContextAccessor.class); - - InstrumentMethod constructor = target.getConstructor("org.frameworkset.elasticsearch.client.RestClientUtil","int", - "java.lang.String","java.lang.String", "java.lang.String", "java.lang.Class", - "org.frameworkset.elasticsearch.scroll.ParallelSliceScrollResult","org.frameworkset.elasticsearch.serial.SerialContext" ); - if(constructor != null) - constructor.addScopedInterceptor(ParallelWorkerConstructorInterceptor.class, scope, ExecutionPolicy.INTERNAL); - - constructor = target.getConstructor("org.frameworkset.elasticsearch.scroll.ScrollHandler","org.frameworkset.elasticsearch.entity.ESDatas", - "org.frameworkset.elasticsearch.scroll.HandlerInfo"); - if(constructor != null) - constructor.addScopedInterceptor(ParallelWorkerConstructorInterceptor.class, scope, ExecutionPolicy.INTERNAL); - - constructor = target.getConstructor("org.frameworkset.elasticsearch.scroll.ScrollHandler","org.frameworkset.elasticsearch.entity.ESDatas", - "org.frameworkset.elasticsearch.scroll.HandlerInfo","org.frameworkset.elasticsearch.scroll.SliceScrollResultInf"); - if(constructor != null) - constructor.addScopedInterceptor(ParallelWorkerConstructorInterceptor.class, scope, ExecutionPolicy.INTERNAL); - InstrumentMethod run = target.getDeclaredMethod("run"); - run.addInterceptor(ParallelWorkerRunInterceptor.class); - - return target.toBytecode(); - } - } - - public static abstract class BaseClientTransformCallback implements TransformCallback{ - protected byte[] toBytecode(InstrumentClass target) throws InstrumentException{ - List methodsToTrace = target.getDeclaredMethods(elasticsearchCustomMethodFilter); - for (InstrumentMethod methodToTrace : methodsToTrace) { - methodToTrace.addScopedInterceptor(ElasticsearchOperationInterceptor.class, ElasticsearchConstants.ELASTICSEARCH_SCOPE, ExecutionPolicy.BOUNDARY); - } - - InstrumentMethod runSliceTaskMethod = target.getDeclaredMethod("runSliceTask", - "int","java.lang.String","java.lang.String","java.lang.String","java.lang.Class" - ,"org.frameworkset.elasticsearch.scroll.ParallelSliceScrollResult" - ,"java.util.concurrent.ExecutorService" - ,"java.util.List" - ,"org.frameworkset.elasticsearch.serial.SerialContext" ); - - if(runSliceTaskMethod != null) { - runSliceTaskMethod.addScopedInterceptor(ElasticsearchOperationAsyncInitiatorInterceptor.class, ElasticsearchConstants.ELASTICSEARCH_Parallel_SCOPE); - } - - InstrumentMethod runScrollTask = target.getDeclaredMethod("runScrollTask", - "java.util.List","org.frameworkset.elasticsearch.scroll.ScrollHandler", - "org.frameworkset.elasticsearch.entity.ESDatas","org.frameworkset.elasticsearch.scroll.HandlerInfo" - ,"java.util.concurrent.ExecutorService" ); - - if(runScrollTask != null) { - runScrollTask.addScopedInterceptor(ElasticsearchOperationAsyncInitiatorInterceptor.class, ElasticsearchConstants.ELASTICSEARCH_Parallel_SCOPE); - } - - InstrumentMethod runSliceScrollTask = target.getDeclaredMethod("runSliceScrollTask", - "java.util.List","org.frameworkset.elasticsearch.scroll.ScrollHandler", - "org.frameworkset.elasticsearch.entity.ESDatas","org.frameworkset.elasticsearch.scroll.HandlerInfo" - ,"org.frameworkset.elasticsearch.scroll.SliceScrollResultInf" - ,"java.util.concurrent.ExecutorService" ); - - if(runSliceScrollTask != null) { - runSliceScrollTask.addScopedInterceptor(ElasticsearchOperationAsyncInitiatorInterceptor.class, ElasticsearchConstants.ELASTICSEARCH_Parallel_SCOPE); - } - - return target.toBytecode(); - } - } - public static class RestClientTransformCallback extends BaseClientTransformCallback{ - @Override - public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, - String className, Class classBeingRedefined, ProtectionDomain protectionDomain, - byte[] classfileBuffer) throws InstrumentException { - - final InstrumentClass target = instrumentor.getInstrumentClass(loader, "org.frameworkset.elasticsearch.client.RestClientUtil", classfileBuffer); - return toBytecode(target); - } - } - - public static class ConfigRestClientTransformCallback extends BaseClientTransformCallback{ - @Override - public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, - String className, Class classBeingRedefined, ProtectionDomain protectionDomain, - byte[] classfileBuffer) throws InstrumentException { - - final InstrumentClass target = instrumentor.getInstrumentClass(loader, "org.frameworkset.elasticsearch.client.ConfigRestClientUtil", classfileBuffer); - return toBytecode(target); - } - } -} diff --git a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchPluginConfig.java b/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchPluginConfig.java deleted file mode 100644 index dd126d61123f2..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchPluginConfig.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - -import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig; - - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchPluginConfig { - - private final boolean elasticsearchEnabled; - private final boolean recordResult ; - private final boolean recordArgs ; - private final boolean recordDsl ; - private final boolean recordESVersion ; - private final boolean recordResponseHandler ; - - private final int maxDslSize; - public boolean isEnabled() { - return elasticsearchEnabled; - } - - - - public ElasticsearchPluginConfig(ProfilerConfig profilerConfig) { - if(profilerConfig != null) { - this.elasticsearchEnabled = profilerConfig.readBoolean("profiler.elasticsearchbboss.enabled", true); - recordResult = profilerConfig.readBoolean("profiler.elasticsearchbboss.recordResult",false); - recordArgs = profilerConfig.readBoolean("profiler.elasticsearchbboss.recordArgs",true); - recordDsl = profilerConfig.readBoolean("profiler.elasticsearchbboss.recordDsl",true); - maxDslSize = profilerConfig.readInt("profiler.elasticsearchbboss.maxDslSize",ElasticsearchConstants.maxDslSize); - recordResponseHandler = profilerConfig.readBoolean("profiler.elasticsearchbboss.recordResponseHandlerClass",false); - recordESVersion = profilerConfig.readBoolean("profiler.elasticsearchbboss.recordESVersion",true); - - } - else { - this.elasticsearchEnabled = false; - recordResult = false; - recordArgs = true; - recordDsl = true; - maxDslSize = ElasticsearchConstants.maxDslSize; - recordResponseHandler = false; - recordESVersion = true; - } - } - - - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder("ElasticsearchBBossPluginConfig{"); - sb.append("elasticsearchBBossEnabled=").append(elasticsearchEnabled); - sb.append(",recordResult=").append(recordResult); - sb.append(",recordArgs=").append(recordArgs); - sb.append(",recordDsl=").append(recordDsl); - sb.append(",maxDslSize=").append(maxDslSize); - sb.append(",recordResponseHandler=").append(recordResponseHandler); - sb.append(",recordESVersion=").append(recordESVersion); - sb.append('}'); - return sb.toString(); - } - - public boolean isRecordResult() { - return recordResult; - } - - public boolean isRecordArgs() { - return recordArgs; - } - - public boolean isRecordDsl() { - return recordDsl; - } - - public boolean isRecordESVersion() { - return recordESVersion; - } - - public boolean isRecordResponseHandler() { - return recordResponseHandler; - } - - public int getMaxDslSize() { - return maxDslSize; - } -} diff --git a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/RestSeachExecutorMethodFilter.java b/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/RestSeachExecutorMethodFilter.java deleted file mode 100644 index 24f505aa4f48b..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/RestSeachExecutorMethodFilter.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - -import com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod; -import com.navercorp.pinpoint.bootstrap.instrument.MethodFilter; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class RestSeachExecutorMethodFilter implements MethodFilter { - @Override - public boolean accept(InstrumentMethod instrumentMethod) { - String name = instrumentMethod.getName(); - return name.equals("execute") || name.equals("executeHttp") - || name.equals("executeSimpleRequest") - || name.equals("executeRequest") - || name.equals("discoverHost") - ; - - } -} diff --git a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchExecutorOperationInterceptor.java b/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchExecutorOperationInterceptor.java deleted file mode 100644 index da1c13c65d594..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchExecutorOperationInterceptor.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss.interceptor; - -import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor; -import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder; -import com.navercorp.pinpoint.bootstrap.context.TraceContext; -import com.navercorp.pinpoint.bootstrap.interceptor.SpanEventSimpleAroundInterceptorForPlugin; -import com.navercorp.pinpoint.common.trace.AnnotationKey; -import com.navercorp.pinpoint.common.util.ArrayUtils; -import com.navercorp.pinpoint.plugin.elasticsearchbboss.ClusterVersionAccessor; -import com.navercorp.pinpoint.plugin.elasticsearchbboss.ElasticsearchConstants; -import com.navercorp.pinpoint.plugin.elasticsearchbboss.ElasticsearchPluginConfig; - -import java.lang.reflect.Method; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchExecutorOperationInterceptor extends SpanEventSimpleAroundInterceptorForPlugin { - private final boolean recordResult; - private final boolean recordArgs; - private final boolean recordDsl; - private final boolean recordResponseHandler; - private final boolean recordESVersion; - private volatile Method getClusterVersionInfo; - private final int maxDslSize; - - public ElasticsearchExecutorOperationInterceptor(TraceContext context, MethodDescriptor descriptor) { - super(context, descriptor); - final ElasticsearchPluginConfig elasticsearchPluginConfig = new ElasticsearchPluginConfig(context.getProfilerConfig()); - recordResult = elasticsearchPluginConfig.isRecordResult(); - recordArgs = elasticsearchPluginConfig.isRecordArgs(); - recordDsl = elasticsearchPluginConfig.isRecordDsl(); - maxDslSize = elasticsearchPluginConfig.getMaxDslSize(); - recordResponseHandler = elasticsearchPluginConfig.isRecordResponseHandler(); - recordESVersion = elasticsearchPluginConfig.isRecordESVersion(); - - - } - - @Override - public void before(Object target, Object[] args) { - super.before(target, args); - - } - - @Override - public void after(Object target, Object[] args, Object result, Throwable throwable) { - - - super.after(target, args, result, throwable); - } - - - @Override - protected void doInBeforeTrace(SpanEventRecorder recorder, Object target, Object[] args) { - - recorder.recordServiceType(ElasticsearchConstants.ELASTICSEARCH_EXECUTOR); - } - - private String getClusterVersionInfo(Object target) { - if (target instanceof ClusterVersionAccessor) { - ClusterVersionAccessor clusterVersionAccessor = (ClusterVersionAccessor) target; - if (clusterVersionAccessor._$PINPOINT$_getClusterVersion() != null) { - return clusterVersionAccessor._$PINPOINT$_getClusterVersion(); - } else { - synchronized (target.getClass()) { - if (clusterVersionAccessor._$PINPOINT$_getClusterVersion() == null) { - try { - Method _getClusterVersionInfo = target.getClass().getMethod("getClusterVersionInfo"); - String version = (String) _getClusterVersionInfo.invoke(target); - if (version == null) { - clusterVersionAccessor._$PINPOINT$_setClusterVersion("UNKNOWN_VERSION"); - } else { - clusterVersionAccessor._$PINPOINT$_setClusterVersion(version); - } - - } catch (Exception e) { - clusterVersionAccessor._$PINPOINT$_setClusterVersion("UNKNOWN_VERSION"); - } - } - - } - return clusterVersionAccessor._$PINPOINT$_getClusterVersion(); - } - } else { - if (getClusterVersionInfo == null) { - synchronized (target.getClass()) { - if (getClusterVersionInfo == null) { - try { - getClusterVersionInfo = target.getClass().getMethod("getClusterVersionInfo"); - } catch (Exception ignored) { - } - } - } - } - if (getClusterVersionInfo != null) { - try { - String version = (String) getClusterVersionInfo.invoke(target); - if (version == null) { - return "UNKNOWN_VERSION"; - } else { - return version; - } - - } catch (Exception e) { - return "UNKNOWN_VERSION"; - } - } else { - return "UNKNOWN_VERSION"; - } - } - } - - private String getEndPoint(Object[] args) { - String url = (String) args[0]; - //http://xxx:9200/ - int idx = url.indexOf("://"); - String endPoint = null; - if (idx > 0) { - int sub = url.indexOf('/', idx + 3); - if (sub > 0) { - endPoint = url.substring(idx + 3, sub); - } else { - endPoint = url.substring(idx + 3); - } - } else { - endPoint = "Unknown"; - } - return endPoint; - - } - - @Override - protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, - Throwable throwable) { - - recorder.recordApi(getMethodDescriptor()); - recorder.recordDestinationId("ElasticsearchBBoss"); - if (ArrayUtils.hasLength(args)) { - recorder.recordEndPoint(getEndPoint(args)); - } - if (recordESVersion) { - // Each target(ClientInstance) has a specific version of Elasticsearch Datasource in one application, - // and each Elasticsearch Datasource retains its corresponding Elasticsearch cluster version information - // such as Elasticsearch 1.x or 2.x or 5.x or 6.x or 7.x or 8.x and so on. - // so we should get elasticsearchClusterVersionInfo in target everytime. - String elasticsearchClusterVersionInfo = getClusterVersionInfo(target); - recorder.recordAttribute(ElasticsearchConstants.ARGS_VERSION_ANNOTATION_KEY, elasticsearchClusterVersionInfo);//record elasticsearch version and cluster name. - } - recorder.recordException(throwable); - if (recordArgs && ArrayUtils.hasLength(args)) { - recordAttributes(recorder, methodDescriptor, args); - } - - if (recordResult) { - recorder.recordAttribute(AnnotationKey.RETURN_DATA, result); - } - } - - - private void recordAttributes(SpanEventRecorder recorder, MethodDescriptor methodDescriptor, Object[] args) { - if (methodDescriptor.getMethodName().equals("execute")) { - - recorder.recordAttribute(ElasticsearchConstants.ARGS_URL_ANNOTATION_KEY, args[0]); - if (recordDsl) { - recorder.recordAttribute(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY, chunkDsl((String) args[1])); - } - recorder.recordAttribute(ElasticsearchConstants.ARGS_ACTION_ANNOTATION_KEY, "POST"); - if (recordResponseHandler) { - recorder.recordAttribute(ElasticsearchConstants.ARGS_RESPONSEHANDLE_ANNOTATION_KEY, args[2]); - } - } else if (methodDescriptor.getMethodName().equals("executeHttp")) { - recorder.recordAttribute(ElasticsearchConstants.ARGS_URL_ANNOTATION_KEY, args[0]); - if (recordDsl) { - recorder.recordAttribute(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY, chunkDsl((String) args[1])); - } - recorder.recordAttribute(ElasticsearchConstants.ARGS_ACTION_ANNOTATION_KEY, args[2]); - if (recordResponseHandler) { - recorder.recordAttribute(ElasticsearchConstants.ARGS_RESPONSEHANDLE_ANNOTATION_KEY, args[3]); - } - } else if (methodDescriptor.getMethodName().equals("executeSimpleRequest")) { - recorder.recordAttribute(ElasticsearchConstants.ARGS_URL_ANNOTATION_KEY, args[0]); - if (recordDsl) { - recorder.recordAttribute(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY, chunkDsl((String) args[1])); - } - recorder.recordAttribute(ElasticsearchConstants.ARGS_ACTION_ANNOTATION_KEY, "POST"); - if (recordResponseHandler) { - recorder.recordAttribute(ElasticsearchConstants.ARGS_RESPONSEHANDLE_ANNOTATION_KEY, args[2]); - } - - } else if (methodDescriptor.getMethodName().equals("executeRequest")) { - recorder.recordAttribute(ElasticsearchConstants.ARGS_URL_ANNOTATION_KEY, args[0]); - if (recordDsl) { - recorder.recordAttribute(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY, chunkDsl((String) args[1])); - } - recorder.recordAttribute(ElasticsearchConstants.ARGS_ACTION_ANNOTATION_KEY, args[2]); - if (recordResponseHandler) { - recorder.recordAttribute(ElasticsearchConstants.ARGS_RESPONSEHANDLE_ANNOTATION_KEY, args[3]); - } - - } - } - - private String chunkDsl(String dsl) { - if (dsl == null) { - return null; - } - if (dsl.length() <= maxDslSize || maxDslSize <= 0) { - return dsl; - } else { - return dsl.substring(0, maxDslSize); - } - } - - -} diff --git a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchOperationAsyncInitiatorInterceptor.java b/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchOperationAsyncInitiatorInterceptor.java deleted file mode 100644 index c5e6c274cdaf0..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchOperationAsyncInitiatorInterceptor.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss.interceptor; - -import com.navercorp.pinpoint.bootstrap.context.*; -import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor; -import com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScope; -import com.navercorp.pinpoint.plugin.elasticsearchbboss.ElasticsearchConstants; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchOperationAsyncInitiatorInterceptor implements AroundInterceptor { - - private final MethodDescriptor descriptor; - private final TraceContext traceContext; - private final InterceptorScope scope; - - public ElasticsearchOperationAsyncInitiatorInterceptor(TraceContext traceContext, MethodDescriptor descriptor, InterceptorScope scope) { - this.traceContext = traceContext; - this.descriptor = descriptor; - this.scope = scope; - } - - @Override - public void before(Object target, Object arg[]) { - Trace trace = traceContext.currentTraceObject(); - if (trace == null) { - return; - } - - SpanEventRecorder recorder = trace.traceBlockBegin(); - recorder.recordServiceType(ElasticsearchConstants.ELASTICSEARCH); - recorder.recordApi(descriptor); - - // To trace async invocations, you have to create AsyncContext like below, automatically attaching it to the current span event. - AsyncContext asyncContext = recorder.recordNextAsyncContext(); - - // Finally, you have to pass the AsyncContext to the thread which handles the async task. - // How to do this depends on the target library implementation. - // - // In this sample, we set the id as scope invocation attachment like below to pass it to the constructor interceptor of TargetClass12_Worker which has run() method that handles the async task. - // Then the constructor interceptor will get the attached AsyncContext and set to the initializing TargetClass12_Worker object. - scope.getCurrentInvocation().setAttachment(asyncContext); - } - - @Override - public void after(Object target, Object arg[], Object result, Throwable throwable) { - Trace trace = traceContext.currentTraceObject(); - if (trace == null) { - return; - } - - try { - if (throwable != null) { - SpanEventRecorder recorder = trace.currentSpanEventRecorder(); - recorder.recordException(throwable); - } - } finally { - trace.traceBlockEnd(); - } - } -} diff --git a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchOperationInterceptor.java b/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchOperationInterceptor.java deleted file mode 100644 index 62a2a18ebf345..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchOperationInterceptor.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss.interceptor; - -import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor; -import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder; -import com.navercorp.pinpoint.bootstrap.context.TraceContext; -import com.navercorp.pinpoint.bootstrap.interceptor.SpanEventSimpleAroundInterceptorForPlugin; -import com.navercorp.pinpoint.common.trace.AnnotationKey; -import com.navercorp.pinpoint.plugin.elasticsearchbboss.ElasticsearchConstants; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchOperationInterceptor extends SpanEventSimpleAroundInterceptorForPlugin { - protected boolean recordResult = false; - protected boolean recordArgs = false; - public ElasticsearchOperationInterceptor(TraceContext context, MethodDescriptor descriptor) { - super(context, descriptor); - recordResult = this.getTraceContext().getProfilerConfig().readBoolean("profiler.elasticsearchbboss.recordResult",false); - recordArgs = this.getTraceContext().getProfilerConfig().readBoolean("profiler.elasticsearchbboss.recordArgs",true); - } - - @Override - protected void doInBeforeTrace(SpanEventRecorder recorder, Object target, Object[] args) { - - } - - - protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) { - recorder.recordServiceType(ElasticsearchConstants.ELASTICSEARCH); - recorder.recordException(throwable); - recorder.recordApi(getMethodDescriptor()); -// if (recordArgs && ArrayUtils.hasLength(args)) { -//// recorder.recordAttribute(ElasticsearchConstants.ARGS_ANNOTATION_KEY,convertParams(args)); -// } - - if (recordResult) { - recorder.recordAttribute(AnnotationKey.RETURN_DATA,result); - } - } - -} diff --git a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ParallelWorkerConstructorInterceptor.java b/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ParallelWorkerConstructorInterceptor.java deleted file mode 100644 index e5e983d581c2b..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ParallelWorkerConstructorInterceptor.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss.interceptor; - -import com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor; -import com.navercorp.pinpoint.bootstrap.context.AsyncContext; -import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor; -import com.navercorp.pinpoint.bootstrap.interceptor.annotation.IgnoreMethod; -import com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScope; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ParallelWorkerConstructorInterceptor implements AroundInterceptor { - private final InterceptorScope scope; - - public ParallelWorkerConstructorInterceptor(InterceptorScope scope) { - this.scope = scope; - } - - @IgnoreMethod - public void before(Object target, Object arg[]) { - - } - - - public void after(Object target, Object arg[], Object result, Throwable throwable) { - AsyncContext asyncContext = (AsyncContext) scope.getCurrentInvocation().getAttachment(); - ((AsyncContextAccessor) target)._$PINPOINT$_setAsyncContext(asyncContext); - } -} diff --git a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ParallelWorkerRunInterceptor.java b/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ParallelWorkerRunInterceptor.java deleted file mode 100644 index 342ec10a64b20..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ParallelWorkerRunInterceptor.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss.interceptor; - -import com.navercorp.pinpoint.bootstrap.context.AsyncContext; -import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor; -import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder; -import com.navercorp.pinpoint.bootstrap.context.TraceContext; -import com.navercorp.pinpoint.bootstrap.interceptor.AsyncContextSpanEventSimpleAroundInterceptor; -import com.navercorp.pinpoint.plugin.elasticsearchbboss.ElasticsearchConstants; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ParallelWorkerRunInterceptor extends AsyncContextSpanEventSimpleAroundInterceptor { - - public ParallelWorkerRunInterceptor(TraceContext traceContext, MethodDescriptor methodDescriptor) { - super(traceContext, methodDescriptor); - } - - @Override - protected void doInBeforeTrace(SpanEventRecorder recorder, AsyncContext asyncContext, Object target, Object[] args) { - // do nothing - } - - @Override - protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) { - recorder.recordServiceType(ElasticsearchConstants.ELASTICSEARCH); - recorder.recordApi(methodDescriptor); - recorder.recordException(throwable); - } -} diff --git a/plugins/elasticsearch-bboss/src/main/resources/META-INF/services/com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin b/plugins/elasticsearch-bboss/src/main/resources/META-INF/services/com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin deleted file mode 100644 index b96bd9989d548..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/resources/META-INF/services/com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin +++ /dev/null @@ -1 +0,0 @@ -com.navercorp.pinpoint.plugin.elasticsearchbboss.ElasticsearchPlugin \ No newline at end of file diff --git a/plugins/elasticsearch-bboss/src/main/resources/META-INF/services/com.navercorp.pinpoint.common.trace.TraceMetadataProvider b/plugins/elasticsearch-bboss/src/main/resources/META-INF/services/com.navercorp.pinpoint.common.trace.TraceMetadataProvider deleted file mode 100644 index 8087c5eb8354c..0000000000000 --- a/plugins/elasticsearch-bboss/src/main/resources/META-INF/services/com.navercorp.pinpoint.common.trace.TraceMetadataProvider +++ /dev/null @@ -1 +0,0 @@ -com.navercorp.pinpoint.plugin.elasticsearchbboss.ElasticsearchMetadataProvider \ No newline at end of file diff --git a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchCustomMethodFilterTest.java b/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchCustomMethodFilterTest.java deleted file mode 100644 index 5bd2c6cb4c8dd..0000000000000 --- a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchCustomMethodFilterTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - - -import com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod; -import org.junit.Assert; -import org.junit.Test; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchCustomMethodFilterTest { - - @Test - public void testReject() { - InstrumentMethod instrumentMethod = mock(InstrumentMethod.class); - when(instrumentMethod.getName()).thenReturn("runSliceTask"); - ElasticsearchCustomMethodFilter elasticsearchCustomMethodFilter = new ElasticsearchCustomMethodFilter(); - Assert.assertFalse(elasticsearchCustomMethodFilter.accept(instrumentMethod)); - } - - @Test - public void testAccept() { - ElasticsearchCustomMethodFilter elasticsearchCustomMethodFilter = new ElasticsearchCustomMethodFilter(); - InstrumentMethod instrumentMethod = mock(InstrumentMethod.class); - when(instrumentMethod.getName()).thenReturn("execute"); - Assert.assertTrue(elasticsearchCustomMethodFilter.accept(instrumentMethod)); - instrumentMethod = mock(InstrumentMethod.class); - when(instrumentMethod.getName()).thenReturn("runSliceTask"); - Assert.assertFalse(elasticsearchCustomMethodFilter.accept(instrumentMethod)); - } - -} diff --git a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchMetadataProviderTest.java b/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchMetadataProviderTest.java deleted file mode 100644 index bb5d7a2672476..0000000000000 --- a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchMetadataProviderTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - -import com.navercorp.pinpoint.common.trace.TraceMetadataSetupContext; -import org.junit.Test; - -import static org.mockito.Mockito.mock; - - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchMetadataProviderTest{ - - @Test - public void setup() { - ElasticsearchMetadataProvider elasticsearchMetadataProvider = new ElasticsearchMetadataProvider(); - TraceMetadataSetupContext traceMetadataSetupContext = mock( TraceMetadataSetupContext.class); - elasticsearchMetadataProvider.setup(traceMetadataSetupContext); - - } - -} diff --git a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchPluginConfigTest.java b/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchPluginConfigTest.java deleted file mode 100644 index 8412ed2555557..0000000000000 --- a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchPluginConfigTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchPluginConfigTest { - private ElasticsearchPluginConfig elasticsearchPluginConfig = null; - - @Before - public void setUp() { - elasticsearchPluginConfig = new ElasticsearchPluginConfig(null); - } - - @Test - public void testIsEnabled() { - Assert.assertFalse(elasticsearchPluginConfig.isEnabled()); - } - - @Test - public void testToString() { - Assert.assertNotNull(elasticsearchPluginConfig.toString()); - } -} diff --git a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchPluginTest.java b/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchPluginTest.java deleted file mode 100644 index 178522610a4ad..0000000000000 --- a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/ElasticsearchPluginTest.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - -import com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig; -import com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass; -import com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext; -import com.navercorp.pinpoint.bootstrap.instrument.Instrumentor; -import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformTemplate; -import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPluginSetupContext; -import org.junit.Assert; -import org.junit.Test; - -import java.security.ProtectionDomain; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchPluginTest { - private ElasticsearchPlugin elasticsearchPlugin = new ElasticsearchPlugin(); - - @Test - public void testSetup() { - ProfilerPluginSetupContext profilerPluginSetupContext = mock(ProfilerPluginSetupContext.class); - when(profilerPluginSetupContext.getConfig()).thenReturn(new DefaultProfilerConfig()); - InstrumentContext instrumentContext = mock(InstrumentContext.class); - elasticsearchPlugin.setTransformTemplate(new TransformTemplate(instrumentContext)); - try { - elasticsearchPlugin.setup(profilerPluginSetupContext); - } - catch (Exception e){ - e.printStackTrace(); - } - } - @Test - public void setTransformTemplate() { - InstrumentContext instrumentContext = mock(InstrumentContext.class); - elasticsearchPlugin.setTransformTemplate(new TransformTemplate(instrumentContext)); - } - - - @Test - public void testBaseClientTransformCallback() { - ElasticsearchPlugin.BaseClientTransformCallback baseClientTransformCallback = mock(ElasticsearchPlugin.BaseClientTransformCallback.class); - InstrumentClass instrumentClass = mock(InstrumentClass.class); - try { - baseClientTransformCallback.toBytecode(instrumentClass); - } - catch (Exception e){ - e.printStackTrace(); - Assert.assertNotNull(e); - } - } - - @Test - public void testConfigRestClientTransformCallback() { - ElasticsearchPlugin.ConfigRestClientTransformCallback configRestClientTransformCallback = mock(ElasticsearchPlugin.ConfigRestClientTransformCallback.class); - Instrumentor instrumentor = mock(Instrumentor.class); - Class classBeingRedefined = this.getClass(); - byte[] classfileBuffer = new byte[]{}; - ProtectionDomain protectionDomain = mock(ProtectionDomain.class); - try { - configRestClientTransformCallback.doInTransform( instrumentor, this.getClass().getClassLoader(), - "org.frameworkset.elasticsearch.client.ConfigRestClientUtil", classBeingRedefined, protectionDomain, - classfileBuffer) ; - } - catch (Exception e){ - e.printStackTrace(); - Assert.assertNotNull(e); - } - } - - @Test - public void testRestClientTransformCallback() { - ElasticsearchPlugin.RestClientTransformCallback restClientTransformCallback = mock(ElasticsearchPlugin.RestClientTransformCallback.class); - Instrumentor instrumentor = mock(Instrumentor.class); - Class classBeingRedefined = this.getClass(); - byte[] classfileBuffer = new byte[]{}; - ProtectionDomain protectionDomain = mock(ProtectionDomain.class); - try { - restClientTransformCallback.doInTransform( instrumentor, this.getClass().getClassLoader(), - "org.frameworkset.elasticsearch.client.RestClientUtil", classBeingRedefined, protectionDomain, - classfileBuffer) ; - } - catch (Exception e){ - e.printStackTrace(); - Assert.assertNotNull(e); - } - } - @Test - public void testRestSearchExecutorTransformCallback() { - ElasticsearchPlugin.RestSearchExecutorTransformCallback restSearchExecutorTransformCallback = mock(ElasticsearchPlugin.RestSearchExecutorTransformCallback.class); - Instrumentor instrumentor = mock(Instrumentor.class); - Class classBeingRedefined = this.getClass(); - byte[] classfileBuffer = new byte[]{}; - ProtectionDomain protectionDomain = mock(ProtectionDomain.class); - try { - restSearchExecutorTransformCallback.doInTransform( instrumentor, this.getClass().getClassLoader(), - "org.frameworkset.elasticsearch.client.RestSearchExecutor", classBeingRedefined, protectionDomain, - classfileBuffer) ; - } - catch (Exception e){ - e.printStackTrace(); - Assert.assertNotNull(e); - } - } - @Test - public void testSliceRunTaskTransformCallback() { - ElasticsearchPlugin.ParallelRunTaskTransformCallback sliceRunTaskTransformCallback = mock(ElasticsearchPlugin.ParallelRunTaskTransformCallback.class); - Instrumentor instrumentor = mock(Instrumentor.class); - Class classBeingRedefined = this.getClass(); - byte[] classfileBuffer = new byte[]{}; - ProtectionDomain protectionDomain = mock(ProtectionDomain.class); - try { - sliceRunTaskTransformCallback.doInTransform( instrumentor, this.getClass().getClassLoader(), - "org.frameworkset.elasticsearch.SliceRunTask", classBeingRedefined, protectionDomain, - classfileBuffer) ; - } - catch (Exception e){ - e.printStackTrace(); - Assert.assertNotNull(e); - } - } - - @Test - public void testScrollRunTaskTransformCallback() { - ElasticsearchPlugin.ParallelRunTaskTransformCallback sliceRunTaskTransformCallback = mock(ElasticsearchPlugin.ParallelRunTaskTransformCallback.class); - Instrumentor instrumentor = mock(Instrumentor.class); - Class classBeingRedefined = this.getClass(); - byte[] classfileBuffer = new byte[]{}; - ProtectionDomain protectionDomain = mock(ProtectionDomain.class); - try { - sliceRunTaskTransformCallback.doInTransform( instrumentor, this.getClass().getClassLoader(), - "org.frameworkset.elasticsearch.scroll.thread.ScrollTask", classBeingRedefined, protectionDomain, - classfileBuffer) ; - } - catch (Exception e){ - e.printStackTrace(); - Assert.assertNotNull(e); - } - } -} diff --git a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/RestSeachExecutorMethodFilterTest.java b/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/RestSeachExecutorMethodFilterTest.java deleted file mode 100644 index b474c2191370c..0000000000000 --- a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/RestSeachExecutorMethodFilterTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss; - -import com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -/** - * @author yinbp[yin-bp@163.com] - */ -public class RestSeachExecutorMethodFilterTest { - private RestSeachExecutorMethodFilter restSeachExecutorMethodFilter; - - @Before - public void setUp() { - restSeachExecutorMethodFilter = new RestSeachExecutorMethodFilter(); - } - - @Test - public void testAccept() { - InstrumentMethod instrumentMethod = mock(InstrumentMethod.class); - when(instrumentMethod.getName()).thenReturn("executeSimpleRequest"); - Assert.assertTrue(restSeachExecutorMethodFilter.accept(instrumentMethod)); - } -} diff --git a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchExecutorOperationInterceptorTest.java b/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchExecutorOperationInterceptorTest.java deleted file mode 100644 index c8e2c551cf712..0000000000000 --- a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchExecutorOperationInterceptorTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss.interceptor; - -import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig; -import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor; -import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder; -import com.navercorp.pinpoint.bootstrap.context.TraceContext; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchExecutorOperationInterceptorTest { - ElasticsearchExecutorOperationInterceptor elasticsearchExecutorOperationInterceptor = null; - Object[] args = null; - @Before - public void setUp(){ - MethodDescriptor methodDescriptor = mock(MethodDescriptor.class); - when(methodDescriptor.getClassName()).thenReturn(" "); - TraceContext traceContext = mock(TraceContext.class); - ProfilerConfig profilerConfig = mock(ProfilerConfig.class); - when(traceContext.getProfilerConfig()).thenReturn(profilerConfig); - - elasticsearchExecutorOperationInterceptor = new ElasticsearchExecutorOperationInterceptor( traceContext, methodDescriptor); - args = new Object[]{"1","2","3","4","5","6"}; - } - @Test - public void testConstruction(){ - MethodDescriptor methodDescriptor = mock(MethodDescriptor.class); - when(methodDescriptor.getClassName()).thenReturn(" "); - TraceContext traceContext = mock(TraceContext.class); - ProfilerConfig profilerConfig = mock(ProfilerConfig.class); - when(traceContext.getProfilerConfig()).thenReturn(profilerConfig); - ElasticsearchExecutorOperationInterceptor elasticsearchExecutorOperationInterceptor = new ElasticsearchExecutorOperationInterceptor(traceContext, methodDescriptor); - } - @Test - public void testBefore(){ - - - try { - elasticsearchExecutorOperationInterceptor.before(new Object(),args); - } - catch (Exception e){ - Assert.assertTrue(e instanceof NullPointerException); - } - - } - - @Test - public void testAfter(){ - - - try { - elasticsearchExecutorOperationInterceptor.after(new Object(), args, "ok", null); - } - catch (Exception e){ - Assert.assertTrue(e instanceof NullPointerException); - } - } - - - - @Test - public void doInEventAfterTrace() { - try { - elasticsearchExecutorOperationInterceptor.doInAfterTrace(mock(SpanEventRecorder.class),new Object(),args,"aa",null); - } - catch (Exception e){ - - } - - } - - -} diff --git a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchOperationAsyncInitiatorInterceptorTest.java b/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchOperationAsyncInitiatorInterceptorTest.java deleted file mode 100644 index f093dc9e751c5..0000000000000 --- a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchOperationAsyncInitiatorInterceptorTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss.interceptor; - -import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor; -import com.navercorp.pinpoint.bootstrap.context.TraceContext; -import com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScope; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static com.navercorp.pinpoint.plugin.elasticsearchbboss.ElasticsearchConstants.ELASTICSEARCH_Parallel_SCOPE; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchOperationAsyncInitiatorInterceptorTest { - - ElasticsearchOperationAsyncInitiatorInterceptor elasticsearchExecutorOperationInterceptor = null; - Object[] args = null; - @Before - public void setUp(){ - InterceptorScope interceptorScopeIT = mock(InterceptorScope.class); - when(interceptorScopeIT.getName()).thenReturn(ELASTICSEARCH_Parallel_SCOPE); - elasticsearchExecutorOperationInterceptor = new ElasticsearchOperationAsyncInitiatorInterceptor(mock(TraceContext.class), mock(MethodDescriptor.class),interceptorScopeIT); - args = new Object[]{"1","2","3","4","5","6"}; - } - - @Test - public void testConstruction(){ - InterceptorScope interceptorScopeIT = mock(InterceptorScope.class); - when(interceptorScopeIT.getName()).thenReturn(ELASTICSEARCH_Parallel_SCOPE); -// InterceptorScopeIT interceptorScopeIT = new InterceptorScopeIT(ELASTICSEARCH_Parallel_SCOPE); - ElasticsearchOperationAsyncInitiatorInterceptor elasticsearchExecutorOperationInterceptor = new ElasticsearchOperationAsyncInitiatorInterceptor(mock(TraceContext.class), mock(MethodDescriptor.class),interceptorScopeIT); - Assert.assertNotNull(elasticsearchExecutorOperationInterceptor); - } - @Test - public void beforeTest() { - try { - elasticsearchExecutorOperationInterceptor.before(new Object(),args); - } - catch (Exception e){ - Assert.assertTrue(e instanceof NullPointerException); - } - } - - @Test - public void afterTest() { - try { - elasticsearchExecutorOperationInterceptor.after(new Object(),args,null,null); - } - catch (Exception e){ - Assert.assertTrue(e instanceof NullPointerException); - } - } -} diff --git a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchOperationInterceptorTest.java b/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchOperationInterceptorTest.java deleted file mode 100644 index f7238fe7b9145..0000000000000 --- a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/ElasticsearchOperationInterceptorTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss.interceptor; - -import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig; -import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor; -import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder; -import com.navercorp.pinpoint.bootstrap.context.TraceContext; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class ElasticsearchOperationInterceptorTest { - ElasticsearchOperationInterceptor elasticsearchExecutorOperationInterceptor = null; - Object[] args = null; - @Before - public void setUp(){ - MethodDescriptor methodDescriptor = mock(MethodDescriptor.class); - when(methodDescriptor.getClassName()).thenReturn(" "); - TraceContext traceContext = mock(TraceContext.class); - ProfilerConfig profilerConfig = mock(ProfilerConfig.class); - when(traceContext.getProfilerConfig()).thenReturn(profilerConfig); - elasticsearchExecutorOperationInterceptor = new ElasticsearchOperationInterceptor(traceContext, methodDescriptor); - args = new Object[]{"1","2","3","4","5","6"}; - } - @Test - public void testConstruction(){ - MethodDescriptor methodDescriptor = mock(MethodDescriptor.class); - when(methodDescriptor.getClassName()).thenReturn(" "); - TraceContext traceContext = mock(TraceContext.class); - ProfilerConfig profilerConfig = mock(ProfilerConfig.class); - when(traceContext.getProfilerConfig()).thenReturn(profilerConfig); - ElasticsearchOperationInterceptor elasticsearchExecutorOperationInterceptor = new ElasticsearchOperationInterceptor(traceContext, methodDescriptor); - } - @Test - public void testBefore(){ - - - try { - elasticsearchExecutorOperationInterceptor.before(new Object(),args); - } - catch (Exception e) { - Assert.assertTrue(e instanceof NullPointerException); - } - - } - - @Test - public void testAfter(){ - - - try { - elasticsearchExecutorOperationInterceptor.after(new Object(), args, "ok", null); - } - catch (Exception e){ - Assert.assertTrue(e instanceof NullPointerException); - } - } - - - - - - - - @Test - public void doInEventAfterTrace() { - try { - - elasticsearchExecutorOperationInterceptor.doInAfterTrace(mock(SpanEventRecorder.class),new Object(),args,"aa",null); - } - catch (Exception ignored){ - - } - - } - - - -} diff --git a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/SliceWorkerConstructorInterceptorTest.java b/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/SliceWorkerConstructorInterceptorTest.java deleted file mode 100644 index de6476c7ab6ac..0000000000000 --- a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/SliceWorkerConstructorInterceptorTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss.interceptor; - -import com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScope; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static com.navercorp.pinpoint.plugin.elasticsearchbboss.ElasticsearchConstants.ELASTICSEARCH_Parallel_SCOPE; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class SliceWorkerConstructorInterceptorTest { - - ParallelWorkerConstructorInterceptor sliceWorkerConstructorInterceptor = null; - Object[] args = null; - @Before - public void setUp(){ - InterceptorScope interceptorScopeIT = mock(InterceptorScope.class); - when(interceptorScopeIT.getName()).thenReturn(ELASTICSEARCH_Parallel_SCOPE); - sliceWorkerConstructorInterceptor = new ParallelWorkerConstructorInterceptor(interceptorScopeIT); - args = new Object[]{"1","2","3","4","5","6"}; - } - - @Test - public void testConstruction(){ - InterceptorScope interceptorScopeIT = mock(InterceptorScope.class); - when(interceptorScopeIT.getName()).thenReturn(ELASTICSEARCH_Parallel_SCOPE); - ParallelWorkerConstructorInterceptor sliceWorkerConstructorInterceptor = new ParallelWorkerConstructorInterceptor(interceptorScopeIT); - Assert.assertNotNull(sliceWorkerConstructorInterceptor); - } - @Test - public void beforeTest() { - try { - sliceWorkerConstructorInterceptor.before(new Object(),args); - } - catch (Exception e){ - Assert.assertTrue(e instanceof NullPointerException); - } - } - - @Test - public void afterTest() { - try { - sliceWorkerConstructorInterceptor.after(new Object(),args,null,null); - } - catch (Exception e){ - Assert.assertTrue(e instanceof NullPointerException); - } - } -} diff --git a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/SliceWorkerRunInterceptorTest.java b/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/SliceWorkerRunInterceptorTest.java deleted file mode 100644 index 54070a58d8caf..0000000000000 --- a/plugins/elasticsearch-bboss/src/test/java/com/navercorp/pinpoint/plugin/elasticsearchbboss/interceptor/SliceWorkerRunInterceptorTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2018 NAVER Corp. - * Licensed 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 com.navercorp.pinpoint.plugin.elasticsearchbboss.interceptor; - -import com.navercorp.pinpoint.bootstrap.context.AsyncContext; -import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor; -import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder; -import com.navercorp.pinpoint.bootstrap.context.TraceContext; -import com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScope; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static com.navercorp.pinpoint.plugin.elasticsearchbboss.ElasticsearchConstants.ELASTICSEARCH_Parallel_SCOPE; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * @author yinbp[yin-bp@163.com] - */ -public class SliceWorkerRunInterceptorTest { - - ParallelWorkerRunInterceptor sliceWorkerRunInterceptor = null; - Object[] args = null; - @Before - public void setUp(){ - sliceWorkerRunInterceptor = new ParallelWorkerRunInterceptor(mock(TraceContext.class), mock(MethodDescriptor.class)); - args = new Object[]{"1","2","3","4","5","6"}; - } - - @Test - public void testConstruction(){ - InterceptorScope interceptorScopeIT = mock(InterceptorScope.class); - when(interceptorScopeIT.getName()).thenReturn(ELASTICSEARCH_Parallel_SCOPE ); - ParallelWorkerRunInterceptor sliceWorkerRunInterceptor = new ParallelWorkerRunInterceptor(mock(TraceContext.class), mock(MethodDescriptor.class)); - Assert.assertNotNull(sliceWorkerRunInterceptor); - } - @Test - public void beforeTest() { - try { - sliceWorkerRunInterceptor.before(new Object(),args); - } - catch (Exception e){ - Assert.assertTrue(e instanceof NullPointerException); - } - } - - @Test - public void afterTest() { - try { - sliceWorkerRunInterceptor.after(new Object(),args,null,null); - } - catch (Exception e){ - Assert.assertTrue(e instanceof NullPointerException); - } - } - - @Test - public void doInBeforeTrace() { - try { - sliceWorkerRunInterceptor.doInBeforeTrace(mock( SpanEventRecorder.class), mock(AsyncContext.class), new Object(),args); - } - catch (Exception e){ - - } - } - - @Test - public void doInAfterTrace() { - try { - sliceWorkerRunInterceptor.doInAfterTrace(mock( SpanEventRecorder.class), new Object(),args,null,null); - } - catch (Exception e){ - - } - } -} diff --git a/plugins/pom.xml b/plugins/pom.xml index d94c62722e9d6..5cf72f2af0488 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -97,7 +97,6 @@ log4j2 openwhisk redis-redisson - elasticsearch-bboss apache-dubbo elasticsearch elasticsearch8