This is an automated email from the ASF dual-hosted git repository. crazyhzm pushed a commit to branch 3.3 in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.3 by this push: new 5b0b86b11d Remove dubbo monitor module (#13456) 5b0b86b11d is described below commit 5b0b86b11d2ae10984b01eaeca02b736e7c1dd48 Author: huazhongming <crazy...@gmail.com> AuthorDate: Mon Dec 18 14:11:33 2023 +0800 Remove dubbo monitor module (#13456) Signed-off-by: crazyhzm <crazy...@gmail.com> --- .artifacts | 4 - dubbo-config/dubbo-config-api/pom.xml | 5 - dubbo-config/dubbo-config-spring/pom.xml | 12 - dubbo-dependencies-bom/pom.xml | 23 -- dubbo-distribution/dubbo-all-shaded/pom.xml | 18 - dubbo-distribution/dubbo-all/pom.xml | 26 -- dubbo-distribution/dubbo-bom/pom.xml | 23 -- dubbo-distribution/dubbo-core-spi/pom.xml | 8 - dubbo-metadata/dubbo-metadata-processor/pom.xml | 4 - .../java/org/apache/dubbo/monitor/Constants.java | 1 + .../java/org/apache/dubbo/monitor/Monitor.java | 1 + .../org/apache/dubbo/monitor/MonitorFactory.java | 3 +- .../org/apache/dubbo/monitor/MonitorService.java | 1 + .../monitor/support/MonitorClusterFilter.java | 1 + .../dubbo/monitor/support/MonitorFilter.java | 1 + .../dubbo/internal/org.apache.dubbo.rpc.Filter | 1 + ...g.apache.dubbo.rpc.cluster.filter.ClusterFilter | 1 + .../dubbo/monitor/support/MonitorFilterTest.java | 0 dubbo-monitor/dubbo-monitor-api/pom.xml | 40 -- .../org/apache/dubbo/monitor/MetricsService.java | 26 -- dubbo-monitor/dubbo-monitor-common/pom.xml | 50 --- .../monitor/support/AbstractMonitorFactory.java | 120 ------ .../monitor/support/MetricsServiceDetector.java | 33 -- .../monitor/support/MonitorServiceDetector.java | 28 -- .../dubbo/internal/org.apache.dubbo.rpc.Filter | 1 - ...g.apache.dubbo.rpc.cluster.filter.ClusterFilter | 1 - ...g.apache.dubbo.rpc.model.BuiltinServiceDetector | 2 - .../support/AbstractMonitorFactoryTest.java | 99 ----- .../src/test/resources/log4j2-test.xml | 29 -- dubbo-monitor/dubbo-monitor-default/pom.xml | 86 ----- .../apache/dubbo/monitor/dubbo/DubboMonitor.java | 238 ------------ .../dubbo/monitor/dubbo/DubboMonitorFactory.java | 69 ---- .../apache/dubbo/monitor/dubbo/MetricsFilter.java | 296 --------------- .../org/apache/dubbo/monitor/dubbo/Statistics.java | 216 ----------- .../apache/dubbo/monitor/dubbo/StatisticsItem.java | 140 ------- .../org.apache.dubbo.monitor.MonitorFactory | 1 - .../dubbo/internal/org.apache.dubbo.rpc.Filter | 1 - .../dubbo/monitor/dubbo/AppResponseBuilder.java | 55 --- .../monitor/dubbo/DubboMonitorFactoryTest.java | 70 ---- .../dubbo/monitor/dubbo/DubboMonitorTest.java | 275 -------------- .../dubbo/monitor/dubbo/MetricsFilterTest.java | 421 --------------------- .../dubbo/monitor/dubbo/MockMonitorService.java | 43 --- .../apache/dubbo/monitor/dubbo/StatisticsTest.java | 109 ------ .../dubbo/monitor/dubbo/service/DemoService.java | 28 -- .../src/test/resources/dubbo.properties | 2 - .../src/test/resources/log4j2-test.xml | 29 -- dubbo-monitor/pom.xml | 48 --- dubbo-test/dubbo-dependencies-all/pom.xml | 16 - pom.xml | 1 - 49 files changed, 9 insertions(+), 2697 deletions(-) diff --git a/.artifacts b/.artifacts index d0e292d3a8..ace6eec3e6 100644 --- a/.artifacts +++ b/.artifacts @@ -62,10 +62,6 @@ dubbo-metrics-registry dubbo-metrics-config-center dubbo-metrics-netty dubbo-metrics-event -dubbo-monitor -dubbo-monitor-api -dubbo-monitor-common -dubbo-monitor-default dubbo-native dubbo-parent dubbo-plugin diff --git a/dubbo-config/dubbo-config-api/pom.xml b/dubbo-config/dubbo-config-api/pom.xml index e57e02cbed..5f8c343abd 100644 --- a/dubbo-config/dubbo-config-api/pom.xml +++ b/dubbo-config/dubbo-config-api/pom.xml @@ -78,11 +78,6 @@ <version>${project.parent.version}</version> </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-api</artifactId> - <version>${project.parent.version}</version> - </dependency> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-remoting-api</artifactId> diff --git a/dubbo-config/dubbo-config-spring/pom.xml b/dubbo-config/dubbo-config-spring/pom.xml index 1f201c0b37..983d0b0547 100644 --- a/dubbo-config/dubbo-config-spring/pom.xml +++ b/dubbo-config/dubbo-config-spring/pom.xml @@ -77,12 +77,6 @@ <version>1.9.20.1</version> <scope>test</scope> </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-default</artifactId> - <version>${project.parent.version}</version> - <scope>test</scope> - </dependency> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-rpc-dubbo</artifactId> @@ -149,12 +143,6 @@ <version>${project.parent.version}</version> <scope>test</scope> </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-common</artifactId> - <version>${project.parent.version}</version> - <scope>test</scope> - </dependency> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-plugin-qos-trace</artifactId> diff --git a/dubbo-dependencies-bom/pom.xml b/dubbo-dependencies-bom/pom.xml index 384a14d0f3..9895ab87bc 100644 --- a/dubbo-dependencies-bom/pom.xml +++ b/dubbo-dependencies-bom/pom.xml @@ -193,7 +193,6 @@ <snappy_java_version>1.1.10.5</snappy_java_version> <bouncycastle-bcprov_version>1.70</bouncycastle-bcprov_version> - <metrics_version>2.0.6</metrics_version> <sofa_registry_version>5.4.3</sofa_registry_version> <gson_version>2.10.1</gson_version> <jackson_version>2.16.0</jackson_version> @@ -775,28 +774,6 @@ <version>${swagger_version}</version> </dependency> - <dependency> - <groupId>com.alibaba.middleware</groupId> - <artifactId>metrics-core-api</artifactId> - <version>${metrics_version}</version> - </dependency> - <dependency> - <groupId>com.alibaba.middleware</groupId> - <artifactId>metrics-core-impl</artifactId> - <version>${metrics_version}</version> - </dependency> - <dependency> - <groupId>com.alibaba.middleware</groupId> - <artifactId>metrics-common</artifactId> - <version>${metrics_version}</version> - </dependency> - - <dependency> - <groupId>com.alibaba.middleware</groupId> - <artifactId>metrics-rest</artifactId> - <version>${metrics_version}</version> - </dependency> - <!-- for dubbo-registry-sofa --> <dependency> <groupId>com.alipay.sofa</groupId> diff --git a/dubbo-distribution/dubbo-all-shaded/pom.xml b/dubbo-distribution/dubbo-all-shaded/pom.xml index 54105d5e4f..9221a5c138 100644 --- a/dubbo-distribution/dubbo-all-shaded/pom.xml +++ b/dubbo-distribution/dubbo-all-shaded/pom.xml @@ -203,22 +203,6 @@ <optional>true</optional> </dependency> - <!-- monitor --> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-api</artifactId> - <version>${project.version}</version> - <scope>compile</scope> - <optional>true</optional> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-default</artifactId> - <version>${project.version}</version> - <scope>compile</scope> - <optional>true</optional> - </dependency> - <!-- plugin --> <dependency> <groupId>org.apache.dubbo</groupId> @@ -493,8 +477,6 @@ <include>org.apache.dubbo:dubbo-metrics-metadata</include> <include>org.apache.dubbo:dubbo-metrics-config-center</include> <include>org.apache.dubbo:dubbo-metrics-prometheus</include> - <include>org.apache.dubbo:dubbo-monitor-api</include> - <include>org.apache.dubbo:dubbo-monitor-default</include> <include>org.apache.dubbo:dubbo-qos</include> <include>org.apache.dubbo:dubbo-qos-api</include> <include>org.apache.dubbo:dubbo-security</include> diff --git a/dubbo-distribution/dubbo-all/pom.xml b/dubbo-distribution/dubbo-all/pom.xml index c92611d230..51dd0e7761 100644 --- a/dubbo-distribution/dubbo-all/pom.xml +++ b/dubbo-distribution/dubbo-all/pom.xml @@ -231,29 +231,6 @@ <optional>true</optional> </dependency> - <!-- monitor --> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-api</artifactId> - <version>${project.version}</version> - <scope>compile</scope> - <optional>true</optional> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-common</artifactId> - <version>${project.version}</version> - <scope>compile</scope> - <optional>true</optional> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-default</artifactId> - <version>${project.version}</version> - <scope>compile</scope> - <optional>true</optional> - </dependency> - <!-- plugin --> <dependency> <groupId>org.apache.dubbo</groupId> @@ -655,9 +632,6 @@ <include>org.apache.dubbo:dubbo-metrics-netty</include> <include>org.apache.dubbo:dubbo-metrics-prometheus</include> <include>org.apache.dubbo:dubbo-tracing</include> - <include>org.apache.dubbo:dubbo-monitor-api</include> - <include>org.apache.dubbo:dubbo-monitor-common</include> - <include>org.apache.dubbo:dubbo-monitor-default</include> <include>org.apache.dubbo:dubbo-qos</include> <include>org.apache.dubbo:dubbo-qos-api</include> <include>org.apache.dubbo:dubbo-security</include> diff --git a/dubbo-distribution/dubbo-bom/pom.xml b/dubbo-distribution/dubbo-bom/pom.xml index 0ea7de708f..acc133fe6a 100644 --- a/dubbo-distribution/dubbo-bom/pom.xml +++ b/dubbo-distribution/dubbo-bom/pom.xml @@ -278,29 +278,6 @@ <version>${project.version}</version> </dependency> - <!-- monitor --> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor</artifactId> - <version>${project.version}</version> - <type>pom</type> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-default</artifactId> - <version>${project.version}</version> - </dependency> - <!-- native --> <dependency> <groupId>org.apache.dubbo</groupId> diff --git a/dubbo-distribution/dubbo-core-spi/pom.xml b/dubbo-distribution/dubbo-core-spi/pom.xml index a11d6ee556..67ebbdfab5 100644 --- a/dubbo-distribution/dubbo-core-spi/pom.xml +++ b/dubbo-distribution/dubbo-core-spi/pom.xml @@ -67,13 +67,6 @@ <scope>compile</scope> <optional>true</optional> </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-api</artifactId> - <version>${project.version}</version> - <scope>compile</scope> - <optional>true</optional> - </dependency> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-registry-api</artifactId> @@ -135,7 +128,6 @@ <include>org.apache.dubbo:dubbo-metrics-api</include> <include>org.apache.dubbo:dubbo-metrics-default</include> <include>org.apache.dubbo:dubbo-tracing</include> - <include>org.apache.dubbo:dubbo-monitor-api</include> <include>org.apache.dubbo:dubbo-registry-api</include> <include>org.apache.dubbo:dubbo-remoting-api</include> <include>org.apache.dubbo:dubbo-remoting</include> diff --git a/dubbo-metadata/dubbo-metadata-processor/pom.xml b/dubbo-metadata/dubbo-metadata-processor/pom.xml index 7e1a50d684..33e6d6ea69 100644 --- a/dubbo-metadata/dubbo-metadata-processor/pom.xml +++ b/dubbo-metadata/dubbo-metadata-processor/pom.xml @@ -81,10 +81,6 @@ <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-metadata-api</artifactId> </exclusion> - <exclusion> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-api</artifactId> - </exclusion> <exclusion> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-remoting-api</artifactId> diff --git a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/Constants.java b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/monitor/Constants.java similarity index 99% rename from dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/Constants.java rename to dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/monitor/Constants.java index 38b371bd6c..46d86bd671 100644 --- a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/Constants.java +++ b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/monitor/Constants.java @@ -16,6 +16,7 @@ */ package org.apache.dubbo.monitor; +@Deprecated public interface Constants { String DUBBO_PROVIDER = "dubbo.provider"; diff --git a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/Monitor.java b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/monitor/Monitor.java similarity index 98% rename from dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/Monitor.java rename to dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/monitor/Monitor.java index 85abadd878..127d8b5b7c 100644 --- a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/Monitor.java +++ b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/monitor/Monitor.java @@ -23,4 +23,5 @@ import org.apache.dubbo.common.Node; * * @see org.apache.dubbo.monitor.MonitorFactory#getMonitor(org.apache.dubbo.common.URL) */ +@Deprecated public interface Monitor extends Node, MonitorService {} diff --git a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/MonitorFactory.java b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/monitor/MonitorFactory.java similarity index 98% rename from dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/MonitorFactory.java rename to dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/monitor/MonitorFactory.java index 45403bc3bc..ab97211006 100644 --- a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/MonitorFactory.java +++ b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/monitor/MonitorFactory.java @@ -24,7 +24,8 @@ import org.apache.dubbo.common.extension.SPI; /** * MonitorFactory. (SPI, Singleton, ThreadSafe) */ -@SPI("dubbo") +@Deprecated +@SPI public interface MonitorFactory { /** diff --git a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/MonitorService.java b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/monitor/MonitorService.java similarity index 99% rename from dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/MonitorService.java rename to dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/monitor/MonitorService.java index bc14cb9ebc..cd61bbd031 100644 --- a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/MonitorService.java +++ b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/monitor/MonitorService.java @@ -23,6 +23,7 @@ import java.util.List; /** * MonitorService. (SPI, Prototype, ThreadSafe) */ +@Deprecated public interface MonitorService { /** diff --git a/dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/MonitorClusterFilter.java b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/monitor/support/MonitorClusterFilter.java similarity index 98% rename from dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/MonitorClusterFilter.java rename to dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/monitor/support/MonitorClusterFilter.java index e6e9e3c061..682ae2334d 100644 --- a/dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/MonitorClusterFilter.java +++ b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/monitor/support/MonitorClusterFilter.java @@ -21,5 +21,6 @@ import org.apache.dubbo.rpc.cluster.filter.ClusterFilter; import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER; +@Deprecated @Activate(group = {CONSUMER}) public class MonitorClusterFilter extends MonitorFilter implements ClusterFilter {} diff --git a/dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java similarity index 99% rename from dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java rename to dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java index 08d4d2738c..d3476b48c2 100644 --- a/dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java +++ b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java @@ -61,6 +61,7 @@ import static org.apache.dubbo.rpc.Constants.OUTPUT_KEY; /** * MonitorFilter. (SPI, Singleton, ThreadSafe) */ +@Deprecated @Activate(group = {PROVIDER}) public class MonitorFilter implements Filter, Filter.Listener { diff --git a/dubbo-metrics/dubbo-metrics-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Filter b/dubbo-metrics/dubbo-metrics-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Filter index 08e822be30..ecb9e24f27 100644 --- a/dubbo-metrics/dubbo-metrics-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Filter +++ b/dubbo-metrics/dubbo-metrics-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Filter @@ -1 +1,2 @@ metrics-provider=org.apache.dubbo.metrics.filter.MetricsProviderFilter +monitor=org.apache.dubbo.monitor.support.MonitorFilter diff --git a/dubbo-metrics/dubbo-metrics-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.cluster.filter.ClusterFilter b/dubbo-metrics/dubbo-metrics-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.cluster.filter.ClusterFilter index dec6c0a5f8..b9b03c571e 100644 --- a/dubbo-metrics/dubbo-metrics-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.cluster.filter.ClusterFilter +++ b/dubbo-metrics/dubbo-metrics-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.cluster.filter.ClusterFilter @@ -1,2 +1,3 @@ observationsender=org.apache.dubbo.rpc.cluster.filter.support.ObservationSenderFilter metricsClusterFilter=org.apache.dubbo.rpc.cluster.filter.support.MetricsClusterFilter +monitor=org.apache.dubbo.monitor.support.MonitorClusterFilter diff --git a/dubbo-monitor/dubbo-monitor-common/src/test/java/org/apache/dubbo/monitor/support/MonitorFilterTest.java b/dubbo-metrics/dubbo-metrics-default/src/test/java/org/apache/dubbo/monitor/support/MonitorFilterTest.java similarity index 100% rename from dubbo-monitor/dubbo-monitor-common/src/test/java/org/apache/dubbo/monitor/support/MonitorFilterTest.java rename to dubbo-metrics/dubbo-metrics-default/src/test/java/org/apache/dubbo/monitor/support/MonitorFilterTest.java diff --git a/dubbo-monitor/dubbo-monitor-api/pom.xml b/dubbo-monitor/dubbo-monitor-api/pom.xml deleted file mode 100644 index 60a8ac3c3f..0000000000 --- a/dubbo-monitor/dubbo-monitor-api/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor</artifactId> - <version>${revision}</version> - <relativePath>../pom.xml</relativePath> - </parent> - <artifactId>dubbo-monitor-api</artifactId> - <packaging>jar</packaging> - <name>${project.artifactId}</name> - <description>The monitor module of dubbo project</description> - <properties> - <skip_maven_deploy>false</skip_maven_deploy> - </properties> - <dependencies> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-common</artifactId> - <version>${project.parent.version}</version> - </dependency> - </dependencies> -</project> diff --git a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/MetricsService.java b/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/MetricsService.java deleted file mode 100644 index 94c7f9dc3f..0000000000 --- a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/MetricsService.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor; - -/** - * @deprecated After metrics config is refactored. - * This class should no longer use and will be deleted in the future. - */ -@Deprecated -public interface MetricsService { - String getMetricsByGroup(String group); -} diff --git a/dubbo-monitor/dubbo-monitor-common/pom.xml b/dubbo-monitor/dubbo-monitor-common/pom.xml deleted file mode 100644 index 9d04a09065..0000000000 --- a/dubbo-monitor/dubbo-monitor-common/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor</artifactId> - <version>${revision}</version> - <relativePath>../pom.xml</relativePath> - </parent> - <artifactId>dubbo-monitor-common</artifactId> - <packaging>jar</packaging> - <name>${project.artifactId}</name> - <description>The monitor common module of dubbo project</description> - <properties> - <skip_maven_deploy>false</skip_maven_deploy> - </properties> - <dependencies> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-cluster</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/AbstractMonitorFactory.java b/dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/AbstractMonitorFactory.java deleted file mode 100644 index 0e774cc018..0000000000 --- a/dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/AbstractMonitorFactory.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.support; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.logger.ErrorTypeAwareLogger; -import org.apache.dubbo.common.logger.LoggerFactory; -import org.apache.dubbo.common.utils.NamedThreadFactory; -import org.apache.dubbo.monitor.Monitor; -import org.apache.dubbo.monitor.MonitorFactory; -import org.apache.dubbo.monitor.MonitorService; - -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.ReentrantLock; - -import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY; -import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_MONITOR_EXCEPTION; - -/** - * AbstractMonitorFactory. (SPI, Singleton, ThreadSafe) - */ -public abstract class AbstractMonitorFactory implements MonitorFactory { - private static final ErrorTypeAwareLogger logger = - LoggerFactory.getErrorTypeAwareLogger(AbstractMonitorFactory.class); - - /** - * The lock for getting monitor center - */ - private static final ReentrantLock LOCK = new ReentrantLock(); - - /** - * The monitor centers Map<RegistryAddress, Registry> - */ - private static final Map<String, Monitor> MONITORS = new ConcurrentHashMap<String, Monitor>(); - - private static final Map<String, Future<Monitor>> FUTURES = new ConcurrentHashMap<String, Future<Monitor>>(); - - /** - * The monitor create executor - */ - private static final ExecutorService EXECUTOR = new ThreadPoolExecutor( - 0, - 10, - 60L, - TimeUnit.SECONDS, - new SynchronousQueue<Runnable>(), - new NamedThreadFactory("DubboMonitorCreator", true)); - - public static Collection<Monitor> getMonitors() { - return Collections.unmodifiableCollection(MONITORS.values()); - } - - @Override - public Monitor getMonitor(URL url) { - url = url.setPath(MonitorService.class.getName()).addParameter(INTERFACE_KEY, MonitorService.class.getName()); - String key = url.toServiceStringWithoutResolving(); - Monitor monitor = MONITORS.get(key); - Future<Monitor> future = FUTURES.get(key); - if (monitor != null || future != null) { - return monitor; - } - - LOCK.lock(); - try { - monitor = MONITORS.get(key); - future = FUTURES.get(key); - if (monitor != null || future != null) { - return monitor; - } - - final URL monitorUrl = url; - future = EXECUTOR.submit(() -> { - try { - Monitor m = createMonitor(monitorUrl); - MONITORS.put(key, m); - FUTURES.remove(key); - return m; - } catch (Throwable e) { - logger.warn( - COMMON_MONITOR_EXCEPTION, - "", - "", - "Create monitor failed, monitor data will not be collected until you fix this problem. monitorUrl: " - + monitorUrl, - e); - return null; - } - }); - FUTURES.put(key, future); - return null; - } finally { - // unlock - LOCK.unlock(); - } - } - - protected abstract Monitor createMonitor(URL url); -} diff --git a/dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/MetricsServiceDetector.java b/dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/MetricsServiceDetector.java deleted file mode 100644 index a357b8b344..0000000000 --- a/dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/MetricsServiceDetector.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.support; - -import org.apache.dubbo.monitor.MetricsService; -import org.apache.dubbo.rpc.model.BuiltinServiceDetector; - -/** - * @deprecated After metrics config is refactored. - * This class should no longer use and will be deleted in the future. - */ -@Deprecated -public class MetricsServiceDetector implements BuiltinServiceDetector { - - @Override - public Class<?> getService() { - return MetricsService.class; - } -} diff --git a/dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/MonitorServiceDetector.java b/dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/MonitorServiceDetector.java deleted file mode 100644 index 0b8cd37f63..0000000000 --- a/dubbo-monitor/dubbo-monitor-common/src/main/java/org/apache/dubbo/monitor/support/MonitorServiceDetector.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.support; - -import org.apache.dubbo.monitor.MonitorService; -import org.apache.dubbo.rpc.model.BuiltinServiceDetector; - -public class MonitorServiceDetector implements BuiltinServiceDetector { - - @Override - public Class<?> getService() { - return MonitorService.class; - } -} diff --git a/dubbo-monitor/dubbo-monitor-common/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Filter b/dubbo-monitor/dubbo-monitor-common/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Filter deleted file mode 100644 index fbeff59d1d..0000000000 --- a/dubbo-monitor/dubbo-monitor-common/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Filter +++ /dev/null @@ -1 +0,0 @@ -monitor=org.apache.dubbo.monitor.support.MonitorFilter diff --git a/dubbo-monitor/dubbo-monitor-common/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.cluster.filter.ClusterFilter b/dubbo-monitor/dubbo-monitor-common/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.cluster.filter.ClusterFilter deleted file mode 100644 index c5bf757353..0000000000 --- a/dubbo-monitor/dubbo-monitor-common/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.cluster.filter.ClusterFilter +++ /dev/null @@ -1 +0,0 @@ -monitor=org.apache.dubbo.monitor.support.MonitorClusterFilter \ No newline at end of file diff --git a/dubbo-monitor/dubbo-monitor-common/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.model.BuiltinServiceDetector b/dubbo-monitor/dubbo-monitor-common/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.model.BuiltinServiceDetector deleted file mode 100644 index ed8a80c9b6..0000000000 --- a/dubbo-monitor/dubbo-monitor-common/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.model.BuiltinServiceDetector +++ /dev/null @@ -1,2 +0,0 @@ -monitor=org.apache.dubbo.monitor.support.MonitorServiceDetector -metrics=org.apache.dubbo.monitor.support.MetricsServiceDetector \ No newline at end of file diff --git a/dubbo-monitor/dubbo-monitor-common/src/test/java/org/apache/dubbo/monitor/support/AbstractMonitorFactoryTest.java b/dubbo-monitor/dubbo-monitor-common/src/test/java/org/apache/dubbo/monitor/support/AbstractMonitorFactoryTest.java deleted file mode 100644 index 7b32aef725..0000000000 --- a/dubbo-monitor/dubbo-monitor-common/src/test/java/org/apache/dubbo/monitor/support/AbstractMonitorFactoryTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.support; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.utils.NetUtils; -import org.apache.dubbo.monitor.Monitor; -import org.apache.dubbo.monitor.MonitorFactory; - -import java.util.List; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * AbstractMonitorFactoryTest - */ -class AbstractMonitorFactoryTest { - - private MonitorFactory monitorFactory = new AbstractMonitorFactory() { - - protected Monitor createMonitor(final URL url) { - return new Monitor() { - - public URL getUrl() { - return url; - } - - @Override - public boolean isAvailable() { - return true; - } - - @Override - public void destroy() {} - - public void collect(URL statistics) {} - - public List<URL> lookup(URL query) { - return null; - } - }; - } - }; - - @Test - void testMonitorFactoryCache() throws Exception { - URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostAddress() + ":2233"); - Monitor monitor1 = monitorFactory.getMonitor(url); - Monitor monitor2 = monitorFactory.getMonitor(url); - if (monitor1 == null || monitor2 == null) { - Thread.sleep(2000); - monitor1 = monitorFactory.getMonitor(url); - monitor2 = monitorFactory.getMonitor(url); - } - Assertions.assertEquals(monitor1, monitor2); - } - - @Test - void testMonitorFactoryIpCache() throws Exception { - URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":2233"); - Monitor monitor1 = monitorFactory.getMonitor(url); - Monitor monitor2 = monitorFactory.getMonitor(url); - if (monitor1 == null || monitor2 == null) { - Thread.sleep(2000); - monitor1 = monitorFactory.getMonitor(url); - monitor2 = monitorFactory.getMonitor(url); - } - Assertions.assertEquals(monitor1, monitor2); - } - - @Test - void testMonitorFactoryGroupCache() throws Exception { - URL url1 = URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=aaa"); - URL url2 = URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=bbb"); - Monitor monitor1 = monitorFactory.getMonitor(url1); - Monitor monitor2 = monitorFactory.getMonitor(url2); - if (monitor1 == null || monitor2 == null) { - Thread.sleep(2000); - monitor1 = monitorFactory.getMonitor(url1); - monitor2 = monitorFactory.getMonitor(url2); - } - Assertions.assertNotSame(monitor1, monitor2); - } -} diff --git a/dubbo-monitor/dubbo-monitor-common/src/test/resources/log4j2-test.xml b/dubbo-monitor/dubbo-monitor-common/src/test/resources/log4j2-test.xml deleted file mode 100644 index ba99f52cc2..0000000000 --- a/dubbo-monitor/dubbo-monitor-common/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to You under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> -<Configuration status="WARN"> - <Appenders> - <Console name="Console" target="SYSTEM_OUT" follow="true"> - <PatternLayout pattern="%d{HH:mm:ss.SSS} |-%highlight{%-5p} [%t] %40.40c:%-3L -| %m%n%rEx{filters(jdk.internal.reflect,java.lang.reflect,sun.reflect,org.junit,org.mockito)}" charset="UTF-8"/> - </Console> - </Appenders> - <Loggers> - <Root level="info"> - <AppenderRef ref="Console"/> - </Root> - </Loggers> -</Configuration> diff --git a/dubbo-monitor/dubbo-monitor-default/pom.xml b/dubbo-monitor/dubbo-monitor-default/pom.xml deleted file mode 100644 index 76b9a38191..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/pom.xml +++ /dev/null @@ -1,86 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor</artifactId> - <version>${revision}</version> - <relativePath>../pom.xml</relativePath> - </parent> - <artifactId>dubbo-monitor-default</artifactId> - <packaging>jar</packaging> - <name>${project.artifactId}</name> - <description>The default monitor module of dubbo project</description> - <properties> - <skip_maven_deploy>false</skip_maven_deploy> - </properties> - <dependencies> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-common</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>com.alibaba.middleware</groupId> - <artifactId>metrics-core-api</artifactId> - </dependency> - <dependency> - <groupId>com.alibaba.middleware</groupId> - <artifactId>metrics-core-impl</artifactId> - </dependency> - <dependency> - <groupId>com.alibaba.middleware</groupId> - <artifactId>metrics-common</artifactId> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-rpc-dubbo</artifactId> - <version>${project.parent.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-remoting-netty4</artifactId> - <version>${project.parent.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-serialization-hessian2</artifactId> - <version>${project.parent.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-serialization-fastjson2</artifactId> - <version>${project.parent.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitor.java b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitor.java deleted file mode 100644 index 215ba5daa5..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitor.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.dubbo; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.logger.ErrorTypeAwareLogger; -import org.apache.dubbo.common.logger.LoggerFactory; -import org.apache.dubbo.common.threadpool.manager.FrameworkExecutorRepository; -import org.apache.dubbo.common.utils.ConcurrentHashMapUtils; -import org.apache.dubbo.common.utils.ExecutorUtil; -import org.apache.dubbo.monitor.Monitor; -import org.apache.dubbo.monitor.MonitorService; -import org.apache.dubbo.rpc.Invoker; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_PROTOCOL; -import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY; -import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_MONITOR_EXCEPTION; -import static org.apache.dubbo.monitor.Constants.CONCURRENT_KEY; -import static org.apache.dubbo.monitor.Constants.DEFAULT_MONITOR_SEND_DATA_INTERVAL; -import static org.apache.dubbo.monitor.Constants.ELAPSED_KEY; -import static org.apache.dubbo.monitor.Constants.FAILURE_KEY; -import static org.apache.dubbo.monitor.Constants.INPUT_KEY; -import static org.apache.dubbo.monitor.Constants.MAX_CONCURRENT_KEY; -import static org.apache.dubbo.monitor.Constants.MAX_ELAPSED_KEY; -import static org.apache.dubbo.monitor.Constants.MAX_INPUT_KEY; -import static org.apache.dubbo.monitor.Constants.MAX_OUTPUT_KEY; -import static org.apache.dubbo.monitor.Constants.MONITOR_SEND_DATA_INTERVAL_KEY; -import static org.apache.dubbo.monitor.Constants.OUTPUT_KEY; -import static org.apache.dubbo.monitor.Constants.SUCCESS_KEY; - -/** - * DubboMonitor - */ -public class DubboMonitor implements Monitor { - - private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(DubboMonitor.class); - - /** - * The timer for sending statistics - */ - private final ScheduledExecutorService scheduledExecutorService; - - /** - * The future that can cancel the <b>scheduledExecutorService</b> - */ - private final ScheduledFuture<?> sendFuture; - - private final Invoker<MonitorService> monitorInvoker; - - private final MonitorService monitorService; - - private final ConcurrentMap<Statistics, AtomicReference<StatisticsItem>> statisticsMap = new ConcurrentHashMap<>(); - - public DubboMonitor(Invoker<MonitorService> monitorInvoker, MonitorService monitorService) { - this.monitorInvoker = monitorInvoker; - this.monitorService = monitorService; - scheduledExecutorService = monitorInvoker - .getUrl() - .getOrDefaultFrameworkModel() - .getBeanFactory() - .getBean(FrameworkExecutorRepository.class) - .getSharedScheduledExecutor(); - // The time interval for timer <b>scheduledExecutorService</b> to send data - final long monitorInterval = monitorInvoker - .getUrl() - .getPositiveParameter(MONITOR_SEND_DATA_INTERVAL_KEY, DEFAULT_MONITOR_SEND_DATA_INTERVAL); - // collect timer for collecting statistics data - sendFuture = scheduledExecutorService.scheduleWithFixedDelay( - () -> { - try { - // collect data - send(); - } catch (Throwable t) { - logger.error( - COMMON_MONITOR_EXCEPTION, - "", - "", - "Unexpected error occur at send statistic, cause: " + t.getMessage(), - t); - } - }, - monitorInterval, - monitorInterval, - TimeUnit.MILLISECONDS); - } - - public void send() { - if (logger.isDebugEnabled()) { - logger.debug("Send statistics to monitor " + getUrl()); - } - - String timestamp = String.valueOf(System.currentTimeMillis()); - for (Map.Entry<Statistics, AtomicReference<StatisticsItem>> entry : statisticsMap.entrySet()) { - // get statistics data - Statistics statistics = entry.getKey(); - AtomicReference<StatisticsItem> reference = entry.getValue(); - StatisticsItem statisticsItem = reference.get(); - - // send statistics data - URL url = statistics - .getUrl() - .addParameters( - TIMESTAMP_KEY, - timestamp, - SUCCESS_KEY, - String.valueOf(statisticsItem.getSuccess()), - FAILURE_KEY, - String.valueOf(statisticsItem.getFailure()), - INPUT_KEY, - String.valueOf(statisticsItem.getInput()), - OUTPUT_KEY, - String.valueOf(statisticsItem.getOutput()), - ELAPSED_KEY, - String.valueOf(statisticsItem.getElapsed()), - CONCURRENT_KEY, - String.valueOf(statisticsItem.getConcurrent()), - MAX_INPUT_KEY, - String.valueOf(statisticsItem.getMaxInput()), - MAX_OUTPUT_KEY, - String.valueOf(statisticsItem.getMaxOutput()), - MAX_ELAPSED_KEY, - String.valueOf(statisticsItem.getMaxElapsed()), - MAX_CONCURRENT_KEY, - String.valueOf(statisticsItem.getMaxConcurrent()), - DEFAULT_PROTOCOL, - getUrl().getParameter(DEFAULT_PROTOCOL)); - monitorService.collect(url.toSerializableURL()); - - // reset - StatisticsItem current; - StatisticsItem update = new StatisticsItem(); - do { - current = reference.get(); - if (current == null) { - update.setItems(0, 0, 0, 0, 0, 0); - } else { - update.setItems( - current.getSuccess() - statisticsItem.getSuccess(), - current.getFailure() - statisticsItem.getFailure(), - current.getInput() - statisticsItem.getInput(), - current.getOutput() - statisticsItem.getOutput(), - current.getElapsed() - statisticsItem.getElapsed(), - current.getConcurrent() - statisticsItem.getConcurrent()); - } - } while (!reference.compareAndSet(current, update)); - } - } - - @Override - public void collect(URL url) { - // data to collect from url - int success = url.getParameter(SUCCESS_KEY, 0); - int failure = url.getParameter(FAILURE_KEY, 0); - int input = url.getParameter(INPUT_KEY, 0); - int output = url.getParameter(OUTPUT_KEY, 0); - int elapsed = url.getParameter(ELAPSED_KEY, 0); - int concurrent = url.getParameter(CONCURRENT_KEY, 0); - // init atomic reference - Statistics statistics = new Statistics(url); - AtomicReference<StatisticsItem> reference = - ConcurrentHashMapUtils.computeIfAbsent(statisticsMap, statistics, k -> new AtomicReference<>()); - // use CompareAndSet to sum - StatisticsItem current; - StatisticsItem update = new StatisticsItem(); - do { - current = reference.get(); - if (current == null) { - update.setItems( - success, failure, input, output, elapsed, concurrent, input, output, elapsed, concurrent); - } else { - update.setItems( - current.getSuccess() + success, - current.getFailure() + failure, - current.getInput() + input, - current.getOutput() + output, - current.getElapsed() + elapsed, - (current.getConcurrent() + concurrent) / 2, - current.getMaxInput() > input ? current.getMaxInput() : input, - current.getMaxOutput() > output ? current.getMaxOutput() : output, - current.getMaxElapsed() > elapsed ? current.getMaxElapsed() : elapsed, - current.getMaxConcurrent() > concurrent ? current.getMaxConcurrent() : concurrent); - } - } while (!reference.compareAndSet(current, update)); - } - - @Override - public List<URL> lookup(URL query) { - return monitorService.lookup(query); - } - - @Override - public URL getUrl() { - return monitorInvoker.getUrl(); - } - - @Override - public boolean isAvailable() { - return monitorInvoker.isAvailable(); - } - - @Override - public void destroy() { - try { - ExecutorUtil.cancelScheduledFuture(sendFuture); - } catch (Throwable t) { - logger.error( - COMMON_MONITOR_EXCEPTION, - "", - "", - "Unexpected error occur at cancel sender timer, cause: " + t.getMessage(), - t); - } - monitorInvoker.destroy(); - } -} diff --git a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitorFactory.java b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitorFactory.java deleted file mode 100644 index 1bffa1a200..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitorFactory.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.dubbo; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.URLBuilder; -import org.apache.dubbo.common.utils.StringUtils; -import org.apache.dubbo.monitor.Monitor; -import org.apache.dubbo.monitor.MonitorService; -import org.apache.dubbo.monitor.support.AbstractMonitorFactory; -import org.apache.dubbo.rpc.Invoker; -import org.apache.dubbo.rpc.Protocol; -import org.apache.dubbo.rpc.ProxyFactory; - -import static org.apache.dubbo.common.constants.CommonConstants.DUBBO_PROTOCOL; -import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.REFERENCE_FILTER_KEY; -import static org.apache.dubbo.remoting.Constants.CHECK_KEY; - -/** - * DefaultMonitorFactory - */ -public class DubboMonitorFactory extends AbstractMonitorFactory { - - private Protocol protocol; - - private ProxyFactory proxyFactory; - - public void setProtocol(Protocol protocol) { - this.protocol = protocol; - } - - public void setProxyFactory(ProxyFactory proxyFactory) { - this.proxyFactory = proxyFactory; - } - - @Override - protected Monitor createMonitor(URL url) { - URLBuilder urlBuilder = URLBuilder.from(url); - urlBuilder.setProtocol(url.getParameter(PROTOCOL_KEY, DUBBO_PROTOCOL)); - if (StringUtils.isEmpty(url.getPath())) { - urlBuilder.setPath(MonitorService.class.getName()); - } - String filter = url.getParameter(REFERENCE_FILTER_KEY); - if (StringUtils.isEmpty(filter)) { - filter = ""; - } else { - filter = filter + ","; - } - urlBuilder.addParameters(CHECK_KEY, String.valueOf(false), REFERENCE_FILTER_KEY, filter + "-monitor"); - Invoker<MonitorService> monitorInvoker = protocol.refer(MonitorService.class, urlBuilder.build()); - MonitorService monitorService = proxyFactory.getProxy(monitorInvoker); - return new DubboMonitor(monitorInvoker, monitorService); - } -} diff --git a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/MetricsFilter.java b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/MetricsFilter.java deleted file mode 100644 index 1b45878253..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/MetricsFilter.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.dubbo; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.extension.ExtensionAccessor; -import org.apache.dubbo.common.extension.ExtensionAccessorAware; -import org.apache.dubbo.common.logger.ErrorTypeAwareLogger; -import org.apache.dubbo.common.logger.LoggerFactory; -import org.apache.dubbo.common.store.DataStore; -import org.apache.dubbo.common.utils.JsonUtils; -import org.apache.dubbo.common.utils.NetUtils; -import org.apache.dubbo.monitor.MetricsService; -import org.apache.dubbo.rpc.AsyncRpcResult; -import org.apache.dubbo.rpc.Filter; -import org.apache.dubbo.rpc.Invocation; -import org.apache.dubbo.rpc.Invoker; -import org.apache.dubbo.rpc.Protocol; -import org.apache.dubbo.rpc.Result; -import org.apache.dubbo.rpc.RpcException; -import org.apache.dubbo.rpc.model.ApplicationModel; -import org.apache.dubbo.rpc.model.ScopeModelAware; -import org.apache.dubbo.rpc.support.RpcUtils; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - -import com.alibaba.metrics.FastCompass; -import com.alibaba.metrics.MetricLevel; -import com.alibaba.metrics.MetricManager; -import com.alibaba.metrics.MetricName; -import com.alibaba.metrics.MetricRegistry; -import com.alibaba.metrics.common.CollectLevel; -import com.alibaba.metrics.common.MetricObject; -import com.alibaba.metrics.common.MetricsCollector; -import com.alibaba.metrics.common.MetricsCollectorFactory; - -import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_PROTOCOL; -import static org.apache.dubbo.common.constants.CommonConstants.EXECUTOR_SERVICE_COMPONENT_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.METHOD_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER; -import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_METRICS_COLLECTOR_EXCEPTION; -import static org.apache.dubbo.monitor.Constants.DUBBO_CONSUMER; -import static org.apache.dubbo.monitor.Constants.DUBBO_CONSUMER_METHOD; -import static org.apache.dubbo.monitor.Constants.DUBBO_GROUP; -import static org.apache.dubbo.monitor.Constants.DUBBO_PROVIDER; -import static org.apache.dubbo.monitor.Constants.DUBBO_PROVIDER_METHOD; -import static org.apache.dubbo.monitor.Constants.SERVICE; - -/** - * @deprecated After metrics config is refactored. - * This filter should no longer use and will be deleted in the future. - */ -@Deprecated -public class MetricsFilter implements Filter, ExtensionAccessorAware, ScopeModelAware { - - private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(MetricsFilter.class); - protected static volatile AtomicBoolean exported = new AtomicBoolean(false); - private Integer port; - private String protocolName; - private ExtensionAccessor extensionAccessor; - private ApplicationModel applicationModel; - - private static final String METRICS_PORT = "metrics.port"; - private static final String METRICS_PROTOCOL = "metrics.protocol"; - - @Override - public void setApplicationModel(ApplicationModel applicationModel) { - this.applicationModel = applicationModel; - } - - @Override - public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { - if (exported.compareAndSet(false, true)) { - this.protocolName = invoker.getUrl().getParameter(METRICS_PROTOCOL) == null - ? DEFAULT_PROTOCOL - : invoker.getUrl().getParameter(METRICS_PROTOCOL); - - Protocol protocol = - extensionAccessor.getExtensionLoader(Protocol.class).getExtension(protocolName); - - this.port = invoker.getUrl().getParameter(METRICS_PORT) == null - ? protocol.getDefaultPort() - : Integer.valueOf(invoker.getUrl().getParameter(METRICS_PORT)); - - Invoker<MetricsService> metricsInvoker = initMetricsInvoker(); - - try { - protocol.export(metricsInvoker); - } catch (RuntimeException e) { - logger.error( - COMMON_METRICS_COLLECTOR_EXCEPTION, - "", - "", - "Metrics Service need to be configured" + " when multiple processes are running on a host" - + e.getMessage()); - } - } - - boolean isProvider = invoker.getUrl().getSide(PROVIDER).equalsIgnoreCase(PROVIDER); - long start = System.currentTimeMillis(); - try { - Result result = invoker.invoke(invocation); // proceed invocation chain - long duration = System.currentTimeMillis() - start; - reportMetrics(invoker, invocation, duration, "success", isProvider); - return result; - } catch (RpcException e) { - long duration = System.currentTimeMillis() - start; - String result = "error"; - if (e.isTimeout()) { - result = "timeoutError"; - } - if (e.isBiz()) { - result = "bisError"; - } - if (e.isNetwork()) { - result = "networkError"; - } - if (e.isSerialization()) { - result = "serializationError"; - } - reportMetrics(invoker, invocation, duration, result, isProvider); - throw e; - } - } - - private String buildMethodName(Invocation invocation) { - String methodName = RpcUtils.getMethodName(invocation); - StringBuilder method = new StringBuilder(methodName); - Class<?>[] argTypes = RpcUtils.getParameterTypes(invocation); - - method.append('('); - - for (int i = 0; i < argTypes.length; i++) { - method.append((i == 0 ? "" : ", ") + argTypes[i].getSimpleName()); - } - method.append(')'); - Class<?> returnType = RpcUtils.getReturnType(invocation); - String typeName = null; - if (returnType != null) { - typeName = returnType.getTypeName(); - typeName = typeName.substring(typeName.lastIndexOf(".") + 1); - } - - return (typeName == null ? "void" : typeName) + " " + method; - } - - private void reportMetrics( - Invoker<?> invoker, Invocation invocation, long duration, String result, boolean isProvider) { - String serviceName = invoker.getInterface().getName(); - String methodName = buildMethodName(invocation); - MetricName global; - MetricName method; - if (isProvider) { - global = new MetricName(DUBBO_PROVIDER, MetricLevel.MAJOR); - method = new MetricName( - DUBBO_PROVIDER_METHOD, - new HashMap<String, String>(4) { - { - put(SERVICE, serviceName); - put(METHOD_KEY, methodName); - } - }, - MetricLevel.NORMAL); - } else { - global = new MetricName(DUBBO_CONSUMER, MetricLevel.MAJOR); - method = new MetricName( - DUBBO_CONSUMER_METHOD, - new HashMap<String, String>(4) { - { - put(SERVICE, serviceName); - put(METHOD_KEY, methodName); - } - }, - MetricLevel.NORMAL); - } - setCompassQuantity(DUBBO_GROUP, result, duration, global, method); - } - - private void setCompassQuantity(String groupName, String result, long duration, MetricName... metricNames) { - for (MetricName metricName : metricNames) { - FastCompass compass = MetricManager.getFastCompass(groupName, metricName); - compass.record(duration, result); - } - } - - private List<MetricObject> getThreadPoolMessage() { - DataStore dataStore = - extensionAccessor.getExtensionLoader(DataStore.class).getDefaultExtension(); - Map<String, Object> executors = dataStore.get(EXECUTOR_SERVICE_COMPONENT_KEY); - - List<MetricObject> threadPoolMtricList = new ArrayList<>(); - for (Map.Entry<String, Object> entry : executors.entrySet()) { - String port = entry.getKey(); - ExecutorService executor = (ExecutorService) entry.getValue(); - if (executor instanceof ThreadPoolExecutor) { - ThreadPoolExecutor tp = (ThreadPoolExecutor) executor; - - threadPoolMtricList.add( - value2MetricObject("threadPool.active", tp.getActiveCount(), MetricLevel.MAJOR)); - threadPoolMtricList.add(value2MetricObject("threadPool.core", tp.getCorePoolSize(), MetricLevel.MAJOR)); - threadPoolMtricList.add( - value2MetricObject("threadPool.max", tp.getMaximumPoolSize(), MetricLevel.MAJOR)); - threadPoolMtricList.add(value2MetricObject("threadPool.current", tp.getPoolSize(), MetricLevel.MAJOR)); - } - } - - return threadPoolMtricList; - } - - private MetricObject value2MetricObject(String metric, Integer value, MetricLevel level) { - if (metric == null || value == null || level == null) { - return null; - } - - return new MetricObject.Builder(metric) - .withValue(value) - .withLevel(level) - .build(); - } - - private Invoker<MetricsService> initMetricsInvoker() { - Invoker<MetricsService> metricsInvoker = new Invoker<MetricsService>() { - @Override - public Class<MetricsService> getInterface() { - return MetricsService.class; - } - - @Override - public Result invoke(Invocation invocation) throws RpcException { - String group = invocation.getArguments()[0].toString(); - MetricRegistry registry = MetricManager.getIMetricManager().getMetricRegistryByGroup(group); - - SortedMap<MetricName, FastCompass> fastCompasses = registry.getFastCompasses(); - - long timestamp = System.currentTimeMillis(); - double rateFactor = TimeUnit.SECONDS.toSeconds(1); - double durationFactor = 1.0 / TimeUnit.MILLISECONDS.toNanos(1); - - MetricsCollector collector = MetricsCollectorFactory.createNew( - CollectLevel.NORMAL, Collections.EMPTY_MAP, rateFactor, durationFactor, null); - - for (Map.Entry<MetricName, FastCompass> entry : fastCompasses.entrySet()) { - collector.collect(entry.getKey(), entry.getValue(), timestamp); - } - - List res = collector.build(); - res.addAll(getThreadPoolMessage()); - return AsyncRpcResult.newDefaultAsyncResult(JsonUtils.toJson(res), invocation); - } - - @Override - public URL getUrl() { - return URL.valueOf(protocolName + "://" + NetUtils.getIpByConfig(applicationModel) + ":" + port + "/" - + MetricsService.class.getName()); - } - - @Override - public boolean isAvailable() { - return false; - } - - @Override - public void destroy() {} - }; - - return metricsInvoker; - } - - @Override - public void setExtensionAccessor(ExtensionAccessor extensionAccessor) { - this.extensionAccessor = extensionAccessor; - } -} diff --git a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/Statistics.java b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/Statistics.java deleted file mode 100644 index 7c859aeb8d..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/Statistics.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.dubbo; - -import org.apache.dubbo.common.URL; - -import java.io.Serializable; - -import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER; -import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.METHOD_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER; -import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY; - -/** - * Statistics. (SPI, Prototype, ThreadSafe) - */ -public class Statistics implements Serializable { - - private static final long serialVersionUID = -6921183057683641441L; - - private URL url; - - private String application; - - private String service; - - private String method; - - private String group; - - private String version; - - private String client; - - private String server; - - public Statistics(URL url) { - this.url = url; - this.application = url.getParameter(APPLICATION_KEY); - this.service = url.getParameter(INTERFACE_KEY); - this.method = url.getParameter(METHOD_KEY); - this.group = url.getParameter(GROUP_KEY); - this.version = url.getParameter(VERSION_KEY); - this.client = url.getParameter(CONSUMER, url.getAddress()); - this.server = url.getParameter(PROVIDER, url.getAddress()); - } - - public URL getUrl() { - return url; - } - - public void setUrl(URL url) { - this.url = url; - } - - public String getApplication() { - return application; - } - - public Statistics setApplication(String application) { - this.application = application; - return this; - } - - public String getService() { - return service; - } - - public Statistics setService(String service) { - this.service = service; - return this; - } - - public String getGroup() { - return group; - } - - public void setGroup(String group) { - this.group = group; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getMethod() { - return method; - } - - public Statistics setMethod(String method) { - this.method = method; - return this; - } - - public String getClient() { - return client; - } - - public Statistics setClient(String client) { - this.client = client; - return this; - } - - public String getServer() { - return server; - } - - public Statistics setServer(String server) { - this.server = server; - return this; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((application == null) ? 0 : application.hashCode()); - result = prime * result + ((client == null) ? 0 : client.hashCode()); - result = prime * result + ((group == null) ? 0 : group.hashCode()); - result = prime * result + ((method == null) ? 0 : method.hashCode()); - result = prime * result + ((server == null) ? 0 : server.hashCode()); - result = prime * result + ((service == null) ? 0 : service.hashCode()); - result = prime * result + ((version == null) ? 0 : version.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Statistics other = (Statistics) obj; - if (application == null) { - if (other.application != null) { - return false; - } - } else if (!application.equals(other.application)) { - return false; - } - if (client == null) { - if (other.client != null) { - return false; - } - } else if (!client.equals(other.client)) { - return false; - } - if (group == null) { - if (other.group != null) { - return false; - } - } else if (!group.equals(other.group)) { - return false; - } - if (method == null) { - if (other.method != null) { - return false; - } - } else if (!method.equals(other.method)) { - return false; - } - if (server == null) { - if (other.server != null) { - return false; - } - } else if (!server.equals(other.server)) { - return false; - } - if (service == null) { - if (other.service != null) { - return false; - } - } else if (!service.equals(other.service)) { - return false; - } - if (version == null) { - if (other.version != null) { - return false; - } - } else if (!version.equals(other.version)) { - return false; - } - return true; - } - - @Override - public String toString() { - return url.toString(); - } -} diff --git a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/StatisticsItem.java b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/StatisticsItem.java deleted file mode 100644 index c33d003580..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/StatisticsItem.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.dubbo; - -public class StatisticsItem { - - private long success; - private long failure; - private long input; - private long output; - private long elapsed; - private long concurrent; - private long maxInput; - private long maxOutput; - private long maxElapsed; - private long maxConcurrent; - - public StatisticsItem() {} - - public void setItems(long success, long failure, long input, long output, long elapsed, long concurrent) { - this.setItems(success, failure, input, output, elapsed, concurrent, 0, 0, 0, 0); - } - - public void setItems( - long success, - long failure, - long input, - long output, - long elapsed, - long concurrent, - long maxInput, - long maxOutput, - long maxElapsed, - long maxConcurrent) { - this.success = success; - this.failure = failure; - this.input = input; - this.output = output; - this.elapsed = elapsed; - this.concurrent = concurrent; - this.maxInput = maxInput; - this.maxOutput = maxOutput; - this.maxElapsed = maxElapsed; - this.maxConcurrent = maxConcurrent; - } - - public long getSuccess() { - return success; - } - - public void setSuccess(long success) { - this.success = success; - } - - public long getFailure() { - return failure; - } - - public void setFailure(long failure) { - this.failure = failure; - } - - public long getInput() { - return input; - } - - public void setInput(long input) { - this.input = input; - } - - public long getOutput() { - return output; - } - - public void setOutput(long output) { - this.output = output; - } - - public long getElapsed() { - return elapsed; - } - - public void setElapsed(long elapsed) { - this.elapsed = elapsed; - } - - public long getConcurrent() { - return concurrent; - } - - public void setConcurrent(long concurrent) { - this.concurrent = concurrent; - } - - public long getMaxInput() { - return maxInput; - } - - public void setMaxInput(long maxInput) { - this.maxInput = maxInput; - } - - public long getMaxOutput() { - return maxOutput; - } - - public void setMaxOutput(long maxOutput) { - this.maxOutput = maxOutput; - } - - public long getMaxElapsed() { - return maxElapsed; - } - - public void setMaxElapsed(long maxElapsed) { - this.maxElapsed = maxElapsed; - } - - public long getMaxConcurrent() { - return maxConcurrent; - } - - public void setMaxConcurrent(long maxConcurrent) { - this.maxConcurrent = maxConcurrent; - } -} diff --git a/dubbo-monitor/dubbo-monitor-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.monitor.MonitorFactory b/dubbo-monitor/dubbo-monitor-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.monitor.MonitorFactory deleted file mode 100644 index 62701cc4c5..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.monitor.MonitorFactory +++ /dev/null @@ -1 +0,0 @@ -dubbo=org.apache.dubbo.monitor.dubbo.DubboMonitorFactory \ No newline at end of file diff --git a/dubbo-monitor/dubbo-monitor-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Filter b/dubbo-monitor/dubbo-monitor-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Filter deleted file mode 100644 index 8441a9c63e..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Filter +++ /dev/null @@ -1 +0,0 @@ -metrics=org.apache.dubbo.monitor.dubbo.MetricsFilter diff --git a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/AppResponseBuilder.java b/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/AppResponseBuilder.java deleted file mode 100644 index 737572ae32..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/AppResponseBuilder.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.dubbo; - -import org.apache.dubbo.rpc.AppResponse; - -import java.util.Map; - -public class AppResponseBuilder { - private Object result; - private Throwable exception; - private Map<String, String> attachments; - private AppResponse appResponse; - - private AppResponseBuilder() { - this.appResponse = new AppResponse(); - } - - public static AppResponseBuilder create() { - return new AppResponseBuilder(); - } - - public AppResponse build() { - return new AppResponse(this); - } - - public AppResponseBuilder withResult(Object result) { - this.result = result; - return this; - } - - public AppResponseBuilder withException(Throwable exception) { - this.exception = exception; - return this; - } - - public AppResponseBuilder withAttachments(Map<String, String> attachments) { - this.attachments = attachments; - return this; - } -} diff --git a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/DubboMonitorFactoryTest.java b/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/DubboMonitorFactoryTest.java deleted file mode 100644 index c676528cc3..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/DubboMonitorFactoryTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.dubbo; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.monitor.Monitor; -import org.apache.dubbo.rpc.Invoker; -import org.apache.dubbo.rpc.ProxyFactory; -import org.apache.dubbo.rpc.model.FrameworkModel; -import org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; - -import static org.apache.dubbo.common.constants.CommonConstants.REFERENCE_FILTER_KEY; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.not; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; - -class DubboMonitorFactoryTest { - private DubboMonitorFactory dubboMonitorFactory; - - @Mock - private ProxyFactory proxyFactory; - - @BeforeEach - public void setUp() throws Exception { - initMocks(this); - this.dubboMonitorFactory = new DubboMonitorFactory(); - this.dubboMonitorFactory.setProtocol(new DubboProtocol(FrameworkModel.defaultModel())); - this.dubboMonitorFactory.setProxyFactory(proxyFactory); - } - - @Test - void testCreateMonitor() { - URL urlWithoutPath = URL.valueOf("http://10.10.10.11"); - Monitor monitor = dubboMonitorFactory.createMonitor(urlWithoutPath); - assertThat(monitor, not(nullValue())); - - URL urlWithFilterKey = URL.valueOf("http://10.10.10.11/").addParameter(REFERENCE_FILTER_KEY, "testFilter"); - monitor = dubboMonitorFactory.createMonitor(urlWithFilterKey); - - assertThat(monitor, not(nullValue())); - ArgumentCaptor<Invoker> invokerArgumentCaptor = ArgumentCaptor.forClass(Invoker.class); - verify(proxyFactory, atLeastOnce()).getProxy(invokerArgumentCaptor.capture()); - - Invoker invoker = invokerArgumentCaptor.getValue(); - assertThat(invoker.getUrl().getParameter(REFERENCE_FILTER_KEY), containsString("testFilter")); - } -} diff --git a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/DubboMonitorTest.java b/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/DubboMonitorTest.java deleted file mode 100644 index 891a45e107..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/DubboMonitorTest.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.dubbo; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.URLBuilder; -import org.apache.dubbo.common.extension.ExtensionLoader; -import org.apache.dubbo.monitor.Monitor; -import org.apache.dubbo.monitor.MonitorFactory; -import org.apache.dubbo.monitor.MonitorService; -import org.apache.dubbo.rpc.Exporter; -import org.apache.dubbo.rpc.Invocation; -import org.apache.dubbo.rpc.Invoker; -import org.apache.dubbo.rpc.Protocol; -import org.apache.dubbo.rpc.ProxyFactory; -import org.apache.dubbo.rpc.Result; -import org.apache.dubbo.rpc.RpcException; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; - -import org.hamcrest.CustomMatcher; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; - -import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER; -import static org.apache.dubbo.common.constants.CommonConstants.DUBBO_PROTOCOL; -import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.METHOD_KEY; -import static org.apache.dubbo.monitor.Constants.CONCURRENT_KEY; -import static org.apache.dubbo.monitor.Constants.ELAPSED_KEY; -import static org.apache.dubbo.monitor.Constants.FAILURE_KEY; -import static org.apache.dubbo.monitor.Constants.INPUT_KEY; -import static org.apache.dubbo.monitor.Constants.MAX_CONCURRENT_KEY; -import static org.apache.dubbo.monitor.Constants.MAX_ELAPSED_KEY; -import static org.apache.dubbo.monitor.Constants.OUTPUT_KEY; -import static org.apache.dubbo.monitor.Constants.SUCCESS_KEY; -import static org.awaitility.Awaitility.await; -import static org.hamcrest.CoreMatchers.hasItem; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.not; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -/** - * DubboMonitorTest - */ -class DubboMonitorTest { - - private final Invoker<MonitorService> monitorInvoker = new Invoker<MonitorService>() { - @Override - public Class<MonitorService> getInterface() { - return MonitorService.class; - } - - public URL getUrl() { - return URL.valueOf("dubbo://127.0.0.1:7070?interval=1000"); - } - - @Override - public boolean isAvailable() { - return false; - } - - @Override - public Result invoke(Invocation invocation) throws RpcException { - return null; - } - - @Override - public void destroy() {} - }; - private volatile URL lastStatistics; - private final MonitorService monitorService = new MonitorService() { - - public void collect(URL statistics) { - DubboMonitorTest.this.lastStatistics = statistics; - } - - public List<URL> lookup(URL query) { - return Arrays.asList(DubboMonitorTest.this.lastStatistics); - } - }; - - @Test - void testCount() { - DubboMonitor monitor = new DubboMonitor(monitorInvoker, monitorService); - URL statistics = new URLBuilder(DUBBO_PROTOCOL, "10.20.153.10", 0) - .addParameter(APPLICATION_KEY, "morgan") - .addParameter(INTERFACE_KEY, "MemberService") - .addParameter(METHOD_KEY, "findPerson") - .addParameter(CONSUMER, "10.20.153.11") - .addParameter(SUCCESS_KEY, 1) - .addParameter(FAILURE_KEY, 0) - .addParameter(ELAPSED_KEY, 3) - .addParameter(MAX_ELAPSED_KEY, 3) - .addParameter(CONCURRENT_KEY, 1) - .addParameter(MAX_CONCURRENT_KEY, 1) - .build(); - monitor.collect(statistics.toSerializableURL()); - monitor.send(); - await().atMost(60, TimeUnit.SECONDS).until(() -> lastStatistics != null); - Assertions.assertEquals("morgan", lastStatistics.getParameter(APPLICATION_KEY)); - Assertions.assertEquals("dubbo", lastStatistics.getProtocol()); - Assertions.assertEquals("10.20.153.10", lastStatistics.getHost()); - Assertions.assertEquals("morgan", lastStatistics.getParameter(APPLICATION_KEY)); - Assertions.assertEquals("MemberService", lastStatistics.getParameter(INTERFACE_KEY)); - Assertions.assertEquals("findPerson", lastStatistics.getParameter(METHOD_KEY)); - Assertions.assertEquals("10.20.153.11", lastStatistics.getParameter(CONSUMER)); - Assertions.assertEquals("1", lastStatistics.getParameter(SUCCESS_KEY)); - Assertions.assertEquals("0", lastStatistics.getParameter(FAILURE_KEY)); - Assertions.assertEquals("3", lastStatistics.getParameter(ELAPSED_KEY)); - Assertions.assertEquals("3", lastStatistics.getParameter(MAX_ELAPSED_KEY)); - Assertions.assertEquals("1", lastStatistics.getParameter(CONCURRENT_KEY)); - Assertions.assertEquals("1", lastStatistics.getParameter(MAX_CONCURRENT_KEY)); - monitor.destroy(); - } - - @Test - void testMonitorFactory() { - MockMonitorService monitorService = new MockMonitorService(); - URL statistics = new URLBuilder(DUBBO_PROTOCOL, "10.20.153.10", 0) - .addParameter(APPLICATION_KEY, "morgan") - .addParameter(INTERFACE_KEY, "MemberService") - .addParameter(METHOD_KEY, "findPerson") - .addParameter(CONSUMER, "10.20.153.11") - .addParameter(SUCCESS_KEY, 1) - .addParameter(FAILURE_KEY, 0) - .addParameter(ELAPSED_KEY, 3) - .addParameter(MAX_ELAPSED_KEY, 3) - .addParameter(CONCURRENT_KEY, 1) - .addParameter(MAX_CONCURRENT_KEY, 1) - .build(); - - Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension(); - ProxyFactory proxyFactory = - ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension(); - MonitorFactory monitorFactory = - ExtensionLoader.getExtensionLoader(MonitorFactory.class).getAdaptiveExtension(); - - Exporter<MonitorService> exporter = protocol.export(proxyFactory.getInvoker( - monitorService, - MonitorService.class, - URL.valueOf("dubbo://127.0.0.1:17979/" + MonitorService.class.getName()))); - try { - Monitor monitor = null; - long start = System.currentTimeMillis(); - while (System.currentTimeMillis() - start < 60000) { - monitor = monitorFactory.getMonitor(URL.valueOf("dubbo://127.0.0.1:17979?interval=10")); - if (monitor == null) { - continue; - } - try { - monitor.collect(statistics.toSerializableURL()); - await().atLeast(10, TimeUnit.MILLISECONDS) - .atMost(60, TimeUnit.SECONDS) - .until(() -> monitorService.getStatistics().stream() - .anyMatch(s -> s.getParameter(SUCCESS_KEY, 0) == 1)); - - List<URL> statisticsUrls = monitorService.getStatistics(); - Optional<URL> url = statisticsUrls.stream() - .filter(s -> s.getParameter(SUCCESS_KEY, 0) == 1) - .findFirst(); - Assertions.assertTrue(url.isPresent()); - Assertions.assertEquals(1, url.get().getParameter(SUCCESS_KEY, 0)); - Assertions.assertEquals(3, url.get().getParameter(ELAPSED_KEY, 0)); - } finally { - monitor.destroy(); - } - break; - } - Assertions.assertNotNull(monitor); - } finally { - exporter.unexport(); - } - } - - @Test - void testAvailable() { - Invoker invoker = mock(Invoker.class); - MonitorService monitorService = mock(MonitorService.class); - - given(invoker.isAvailable()).willReturn(true); - given(invoker.getUrl()).willReturn(URL.valueOf("dubbo://127.0.0.1:7070?interval=20")); - DubboMonitor dubboMonitor = new DubboMonitor(invoker, monitorService); - - assertThat(dubboMonitor.isAvailable(), is(true)); - verify(invoker).isAvailable(); - } - - @Test - void testSum() { - URL statistics = new URLBuilder(DUBBO_PROTOCOL, "10.20.153.11", 0) - .addParameter(APPLICATION_KEY, "morgan") - .addParameter(INTERFACE_KEY, "MemberService") - .addParameter(METHOD_KEY, "findPerson") - .addParameter(CONSUMER, "10.20.153.11") - .addParameter(SUCCESS_KEY, 1) - .addParameter(FAILURE_KEY, 0) - .addParameter(ELAPSED_KEY, 3) - .addParameter(MAX_ELAPSED_KEY, 3) - .addParameter(CONCURRENT_KEY, 1) - .addParameter(MAX_CONCURRENT_KEY, 1) - .build(); - Invoker invoker = mock(Invoker.class); - MonitorService monitorService = mock(MonitorService.class); - - given(invoker.getUrl()).willReturn(URL.valueOf("dubbo://127.0.0.1:7070?interval=20")); - DubboMonitor dubboMonitor = new DubboMonitor(invoker, monitorService); - - dubboMonitor.collect(statistics.toSerializableURL()); - dubboMonitor.collect(statistics - .addParameter(SUCCESS_KEY, 3) - .addParameter(CONCURRENT_KEY, 2) - .addParameter(INPUT_KEY, 1) - .addParameter(OUTPUT_KEY, 2) - .toSerializableURL()); - dubboMonitor.collect(statistics - .addParameter(SUCCESS_KEY, 6) - .addParameter(ELAPSED_KEY, 2) - .toSerializableURL()); - - dubboMonitor.send(); - - ArgumentCaptor<URL> summaryCaptor = ArgumentCaptor.forClass(URL.class); - verify(monitorService, atLeastOnce()).collect(summaryCaptor.capture()); - - List<URL> allValues = summaryCaptor.getAllValues(); - - assertThat(allValues, not(nullValue())); - assertThat(allValues, hasItem(new CustomMatcher<URL>("Monitor count should greater than 1") { - @Override - public boolean matches(Object item) { - URL url = (URL) item; - return Integer.valueOf(url.getParameter(SUCCESS_KEY)) > 1; - } - })); - } - - @Test - void testLookUp() { - Invoker invoker = mock(Invoker.class); - MonitorService monitorService = mock(MonitorService.class); - - URL queryUrl = URL.valueOf("dubbo://127.0.0.1:7070?interval=20"); - given(invoker.getUrl()).willReturn(queryUrl); - DubboMonitor dubboMonitor = new DubboMonitor(invoker, monitorService); - - dubboMonitor.lookup(queryUrl); - - verify(monitorService).lookup(queryUrl); - } -} diff --git a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/MetricsFilterTest.java b/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/MetricsFilterTest.java deleted file mode 100644 index 864d52fe23..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/MetricsFilterTest.java +++ /dev/null @@ -1,421 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.dubbo; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.utils.NetUtils; -import org.apache.dubbo.monitor.MetricsService; -import org.apache.dubbo.monitor.dubbo.service.DemoService; -import org.apache.dubbo.rpc.AppResponse; -import org.apache.dubbo.rpc.Invocation; -import org.apache.dubbo.rpc.Invoker; -import org.apache.dubbo.rpc.Protocol; -import org.apache.dubbo.rpc.RpcContext; -import org.apache.dubbo.rpc.RpcException; -import org.apache.dubbo.rpc.RpcInvocation; -import org.apache.dubbo.rpc.model.ApplicationModel; -import org.apache.dubbo.rpc.model.FrameworkModel; -import org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.concurrent.Callable; -import java.util.function.Function; - -import com.alibaba.metrics.FastCompass; -import com.alibaba.metrics.IMetricManager; -import com.alibaba.metrics.MetricLevel; -import com.alibaba.metrics.MetricManager; -import com.alibaba.metrics.MetricName; -import com.alibaba.metrics.common.MetricObject; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; - -import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER_SIDE; -import static org.apache.dubbo.common.constants.CommonConstants.METHOD_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER; -import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY; -import static org.apache.dubbo.monitor.Constants.DUBBO_CONSUMER; -import static org.apache.dubbo.monitor.Constants.DUBBO_CONSUMER_METHOD; -import static org.apache.dubbo.monitor.Constants.DUBBO_GROUP; -import static org.apache.dubbo.monitor.Constants.DUBBO_PROVIDER; -import static org.apache.dubbo.monitor.Constants.DUBBO_PROVIDER_METHOD; -import static org.apache.dubbo.monitor.Constants.SERVICE; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.mock; - -class MetricsFilterTest { - private int port = NetUtils.getAvailablePort(20880 + new Random().nextInt(10000)); - - private final Function<URL, Invoker<DemoService>> invokerFunction = (url) -> { - Invoker<DemoService> serviceInvoker = mock(Invoker.class); - - given(serviceInvoker.isAvailable()).willReturn(false); - given(serviceInvoker.getInterface()).willReturn(DemoService.class); - given(serviceInvoker.getUrl()).willReturn(url); - given(serviceInvoker.invoke(Mockito.any(Invocation.class))).willReturn(null); - doNothing().when(serviceInvoker).destroy(); - return serviceInvoker; - }; - - private URL getUrl() { - return URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":" + port - + "/org.apache.dubbo.monitor.dubbo.service.DemoService?" + "metrics.port" + "=" + port); - } - - private void onInvokeReturns(Invoker<DemoService> invoker, AppResponse response) { - given(invoker.invoke(Mockito.any(Invocation.class))).willReturn(response); - } - - public void onInvokerThrows(Invoker<DemoService> invoker) { - given(invoker.invoke(Mockito.any(Invocation.class))) - .willThrow(new RpcException(RpcException.TIMEOUT_EXCEPTION)); - } - - @Test - void testAll() { - List<Callable<Void>> testcases = new LinkedList<>(); - testcases.add(() -> { - testConsumerSuccess(); - return null; - }); - testcases.add(() -> { - testConsumerTimeout(); - return null; - }); - testcases.add(() -> { - testProviderSuccess(); - return null; - }); - testcases.add(() -> { - testInvokeMetricsService(); - return null; - }); - testcases.add(() -> { - testInvokeMetricsMethodService(); - return null; - }); - - for (Callable<Void> testcase : testcases) { - Throwable throwable = null; - for (int i = 0; i < 10; i++) { - try { - port = NetUtils.getAvailablePort(20880 + new Random().nextInt(10000)); - testcase.call(); - throwable = null; - break; - } catch (Throwable t) { - t.printStackTrace(); - throwable = t; - } finally { - MetricsFilter.exported.set(false); - } - } - Assertions.assertNull(throwable); - } - } - - private void testConsumerSuccess() { - IMetricManager metricManager = MetricManager.getIMetricManager(); - metricManager.clear(); - MetricsFilter metricsFilter = new MetricsFilter(); - metricsFilter.setExtensionAccessor(ApplicationModel.defaultModel()); - Invocation invocation = new RpcInvocation( - "sayName", DemoService.class.getName(), "", new Class<?>[] {Integer.class}, new Object[0]); - RpcContext.getServiceContext() - .setRemoteAddress(NetUtils.getLocalHost(), port) - .setLocalAddress(NetUtils.getLocalHost(), 2345); - URL url = getUrl().addParameter(SIDE_KEY, CONSUMER_SIDE); - Invoker<DemoService> invoker = invokerFunction.apply(url); - AppResponse response = AppResponseBuilder.create().build(); - onInvokeReturns(invoker, response); - for (int i = 0; i < 100; i++) { - metricsFilter.invoke(invoker, invocation); - } - FastCompass dubboClient = - metricManager.getFastCompass(DUBBO_GROUP, new MetricName(DUBBO_CONSUMER, MetricLevel.MAJOR)); - FastCompass dubboMethod = metricManager.getFastCompass( - DUBBO_GROUP, - new MetricName( - DUBBO_CONSUMER_METHOD, - new HashMap<String, String>(4) { - { - put(SERVICE, "org.apache.dubbo.monitor.dubbo.service.DemoService"); - put(METHOD_KEY, "void sayName(Integer)"); - } - }, - MetricLevel.NORMAL)); - long timestamp = System.currentTimeMillis() / 5000 * 5000; - Assertions.assertEquals( - 100, dubboClient.getMethodCountPerCategory(0).get("success").get(timestamp)); - timestamp = timestamp / 15000 * 15000; - Assertions.assertEquals( - 100, dubboMethod.getMethodCountPerCategory(0).get("success").get(timestamp)); - } - - private void testConsumerTimeout() { - IMetricManager metricManager = MetricManager.getIMetricManager(); - metricManager.clear(); - MetricsFilter metricsFilter = new MetricsFilter(); - metricsFilter.setExtensionAccessor(ApplicationModel.defaultModel()); - Invocation invocation = new RpcInvocation("timeoutException", DemoService.class.getName(), "", null, null); - RpcContext.getServiceContext() - .setRemoteAddress(NetUtils.getLocalHost(), port) - .setLocalAddress(NetUtils.getLocalHost(), 2345); - URL url = getUrl().addParameter(SIDE_KEY, CONSUMER_SIDE).addParameter(TIMEOUT_KEY, 300); - Invoker<DemoService> invoker = invokerFunction.apply(url); - onInvokerThrows(invoker); - for (int i = 0; i < 10; i++) { - try { - metricsFilter.invoke(invoker, invocation); - } catch (RpcException e) { - // ignore - } - } - FastCompass dubboClient = - metricManager.getFastCompass(DUBBO_GROUP, new MetricName(DUBBO_CONSUMER, MetricLevel.MAJOR)); - FastCompass dubboMethod = metricManager.getFastCompass( - DUBBO_GROUP, - new MetricName( - DUBBO_CONSUMER_METHOD, - new HashMap<String, String>(4) { - { - put(SERVICE, "org.apache.dubbo.monitor.dubbo.service.DemoService"); - put(METHOD_KEY, "void timeoutException()"); - } - }, - MetricLevel.NORMAL)); - long timestamp = System.currentTimeMillis() / 5000 * 5000; - Assertions.assertEquals( - 10, dubboClient.getMethodCountPerCategory(0).get("timeoutError").get(timestamp)); - timestamp = timestamp / 15000 * 15000; - Assertions.assertEquals( - 10, dubboMethod.getMethodCountPerCategory(0).get("timeoutError").get(timestamp)); - } - - private void testProviderSuccess() { - IMetricManager metricManager = MetricManager.getIMetricManager(); - metricManager.clear(); - MetricsFilter metricsFilter = new MetricsFilter(); - metricsFilter.setExtensionAccessor(ApplicationModel.defaultModel()); - Invocation invocation = - new RpcInvocation("sayName", DemoService.class.getName(), "", new Class<?>[0], new Object[0]); - RpcContext.getServiceContext() - .setRemoteAddress(NetUtils.getLocalHost(), port) - .setLocalAddress(NetUtils.getLocalHost(), 2345); - URL url = getUrl().addParameter(SIDE_KEY, PROVIDER).addParameter(TIMEOUT_KEY, 300); - Invoker<DemoService> invoker = invokerFunction.apply(url); - AppResponse response = AppResponseBuilder.create().build(); - onInvokeReturns(invoker, response); - for (int i = 0; i < 100; i++) { - metricsFilter.invoke(invoker, invocation); - } - FastCompass dubboClient = - metricManager.getFastCompass(DUBBO_GROUP, new MetricName(DUBBO_PROVIDER, MetricLevel.MAJOR)); - FastCompass dubboMethod = metricManager.getFastCompass( - DUBBO_GROUP, - new MetricName( - DUBBO_PROVIDER_METHOD, - new HashMap<String, String>(4) { - { - put(SERVICE, "org.apache.dubbo.monitor.dubbo.service.DemoService"); - put(METHOD_KEY, "void sayName()"); - } - }, - MetricLevel.NORMAL)); - long timestamp = System.currentTimeMillis() / 5000 * 5000; - Assertions.assertEquals( - 100, dubboClient.getMethodCountPerCategory(0).get("success").get(timestamp)); - timestamp = timestamp / 15000 * 15000; - Assertions.assertEquals( - 100, dubboMethod.getMethodCountPerCategory(0).get("success").get(timestamp)); - } - - private void testInvokeMetricsService() { - IMetricManager metricManager = MetricManager.getIMetricManager(); - metricManager.clear(); - MetricsFilter metricsFilter = new MetricsFilter(); - metricsFilter.setExtensionAccessor(ApplicationModel.defaultModel()); - Invocation invocation = - new RpcInvocation("sayName", DemoService.class.getName(), "", new Class<?>[0], new Object[0]); - RpcContext.getServiceContext() - .setRemoteAddress(NetUtils.getLocalHost(), port) - .setLocalAddress(NetUtils.getLocalHost(), 2345); - URL url = getUrl().addParameter(SIDE_KEY, PROVIDER).addParameter(TIMEOUT_KEY, 300); - Invoker<DemoService> serviceInvoker = invokerFunction.apply(url); - Invoker<DemoService> timeoutInvoker = invokerFunction.apply(url); - AppResponse response = AppResponseBuilder.create().build(); - onInvokeReturns(serviceInvoker, response); - onInvokerThrows(timeoutInvoker); - for (int i = 0; i < 50; i++) { - try { - metricsFilter.invoke(serviceInvoker, invocation); - metricsFilter.invoke(timeoutInvoker, invocation); - } catch (RpcException e) { - // ignore - } - } - Protocol protocol = new DubboProtocol(FrameworkModel.defaultModel()); - // using host name might cause connection failure because multiple addresses might be configured to the same - // name! - url = URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":" + port + "/" + MetricsService.class.getName()); - Invoker<MetricsService> invoker = protocol.refer(MetricsService.class, url); - invocation = new RpcInvocation( - "getMetricsByGroup", DemoService.class.getName(), "", new Class<?>[] {String.class}, new Object[] { - DUBBO_GROUP - }); - try { - Thread.sleep(5000); - } catch (Exception e) { - // ignore - } - String resStr = invoker.invoke(invocation).getValue().toString(); - // MetricObject do not have setter, should use gson to parse - List<MetricObject> metricObjectList = - new Gson().fromJson(resStr, new TypeToken<List<MetricObject>>() {}.getType()); - Map<String, Object> metricMap = new HashMap<>(); - for (int i = 0; i < metricObjectList.size(); i++) { - MetricObject object = metricObjectList.get(i); - String metric = object.getMetric().substring(object.getMetric().lastIndexOf(".") + 1); - if ((double) object.getValue() > 0.0 && object.getMetricLevel().equals(MetricLevel.MAJOR)) - metricMap.put(metric, object.getValue()); - } - - Assertions.assertEquals(50.0, metricMap.get("success_bucket_count")); - Assertions.assertEquals(50.0, metricMap.get("timeoutError_bucket_count")); - Assertions.assertEquals(100.0, metricMap.get("bucket_count")); - Assertions.assertEquals(100.0 / 5, metricMap.get("qps")); - Assertions.assertEquals(50.0 / 100.0, metricMap.get("success_rate")); - } - - private void testInvokeMetricsMethodService() { - IMetricManager metricManager = MetricManager.getIMetricManager(); - metricManager.clear(); - MetricsFilter metricsFilter = new MetricsFilter(); - metricsFilter.setExtensionAccessor(ApplicationModel.defaultModel()); - Invocation sayNameInvocation = - new RpcInvocation("sayName", DemoService.class.getName(), "", new Class<?>[0], new Object[0]); - Invocation echoInvocation = new RpcInvocation( - "echo", DemoService.class.getName(), "", new Class<?>[] {Integer.class}, new Integer[] {1}); - RpcContext.getServiceContext() - .setRemoteAddress(NetUtils.getLocalHost(), port) - .setLocalAddress(NetUtils.getLocalHost(), 2345); - URL url = getUrl().addParameter(SIDE_KEY, PROVIDER).addParameter(TIMEOUT_KEY, 300); - Invoker<DemoService> serviceInvoker = invokerFunction.apply(url); - Invoker<DemoService> timeoutInvoker = invokerFunction.apply(url); - AppResponse response = AppResponseBuilder.create().build(); - onInvokeReturns(serviceInvoker, response); - onInvokerThrows(timeoutInvoker); - for (int i = 0; i < 50; i++) { - metricsFilter.invoke(serviceInvoker, sayNameInvocation); - metricsFilter.invoke(serviceInvoker, echoInvocation); - try { - metricsFilter.invoke(timeoutInvoker, sayNameInvocation); - } catch (RpcException e) { - // ignore - } - try { - metricsFilter.invoke(timeoutInvoker, echoInvocation); - } catch (RpcException e) { - // ignore - } - } - - Protocol protocol = new DubboProtocol(FrameworkModel.defaultModel()); - // using host name might cause connection failure because multiple addresses might be configured to the same - // name! - url = URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":" + port + "/" + MetricsService.class.getName()); - Invoker<MetricsService> invoker = protocol.refer(MetricsService.class, url); - Invocation invocation = new RpcInvocation( - "getMetricsByGroup", DemoService.class.getName(), "", new Class<?>[] {String.class}, new Object[] { - DUBBO_GROUP - }); - try { - Thread.sleep(15000); - } catch (Exception e) { - // ignore - } - String resStr = invoker.invoke(invocation).getValue().toString(); - List<MetricObject> metricObjectList = - new Gson().fromJson(resStr, new TypeToken<List<MetricObject>>() {}.getType()); - Map<String, Map<String, Object>> methodMetricMap = new HashMap<>(); - for (int i = 0; i < metricObjectList.size(); i++) { - MetricObject object = metricObjectList.get(i); - String service = object.getTags().get("service"); - String method = service + "." + object.getTags().get("method"); - String metric = object.getMetric().substring(object.getMetric().lastIndexOf(".") + 1); - Map map = methodMetricMap.get(method); - if (map == null) { - map = new HashMap(); - methodMetricMap.put(method, map); - } - map.put(metric, object.getValue()); - } - - Assertions.assertEquals( - 50.0, - methodMetricMap - .get("org.apache.dubbo.monitor.dubbo.service.DemoService.void sayName()") - .get("success_bucket_count")); - Assertions.assertEquals( - 50.0, - methodMetricMap - .get("org.apache.dubbo.monitor.dubbo.service.DemoService.void echo(Integer)") - .get("success_bucket_count")); - - Assertions.assertEquals( - 50.0, - methodMetricMap - .get("org.apache.dubbo.monitor.dubbo.service.DemoService.void sayName()") - .get("timeoutError_bucket_count")); - Assertions.assertEquals( - 50.0, - methodMetricMap - .get("org.apache.dubbo.monitor.dubbo.service.DemoService.void echo(Integer)") - .get("timeoutError_bucket_count")); - - Assertions.assertEquals( - 100.0 / 15, - methodMetricMap - .get("org.apache.dubbo.monitor.dubbo.service.DemoService.void sayName()") - .get("qps")); - Assertions.assertEquals( - 100.0 / 15, - methodMetricMap - .get("org.apache.dubbo.monitor.dubbo.service.DemoService.void echo(Integer)") - .get("qps")); - - Assertions.assertEquals( - 50.0 / 100.0, - methodMetricMap - .get("org.apache.dubbo.monitor.dubbo.service.DemoService.void sayName()") - .get("success_rate")); - Assertions.assertEquals( - 50.0 / 100.0, - methodMetricMap - .get("org.apache.dubbo.monitor.dubbo.service.DemoService.void echo(Integer)") - .get("success_rate")); - } -} diff --git a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/MockMonitorService.java b/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/MockMonitorService.java deleted file mode 100644 index ba435e70d1..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/MockMonitorService.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.dubbo; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.monitor.MonitorService; - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -/** - * MockMonitorService - */ -public class MockMonitorService implements MonitorService { - - private List<URL> statistics = new CopyOnWriteArrayList<>(); - - public void collect(URL statistics) { - this.statistics.add(statistics); - } - - public List<URL> getStatistics() { - return statistics; - } - - public List<URL> lookup(URL query) { - return statistics; - } -} diff --git a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/StatisticsTest.java b/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/StatisticsTest.java deleted file mode 100644 index ac41877382..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/StatisticsTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.dubbo; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.URLBuilder; -import org.apache.dubbo.common.url.component.ServiceConfigURL; - -import org.hamcrest.MatcherAssert; -import org.junit.jupiter.api.Test; - -import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER; -import static org.apache.dubbo.common.constants.CommonConstants.DUBBO_PROTOCOL; -import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.METHOD_KEY; -import static org.apache.dubbo.monitor.Constants.CONCURRENT_KEY; -import static org.apache.dubbo.monitor.Constants.ELAPSED_KEY; -import static org.apache.dubbo.monitor.Constants.FAILURE_KEY; -import static org.apache.dubbo.monitor.Constants.MAX_CONCURRENT_KEY; -import static org.apache.dubbo.monitor.Constants.MAX_ELAPSED_KEY; -import static org.apache.dubbo.monitor.Constants.SUCCESS_KEY; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; - -class StatisticsTest { - @Test - void testEquals() { - URL statistics = new URLBuilder(DUBBO_PROTOCOL, "10.20.153.10", 0) - .addParameter(APPLICATION_KEY, "morgan") - .addParameter(INTERFACE_KEY, "MemberService") - .addParameter(METHOD_KEY, "findPerson") - .addParameter(CONSUMER, "10.20.153.11") - .addParameter(SUCCESS_KEY, 1) - .addParameter(FAILURE_KEY, 0) - .addParameter(ELAPSED_KEY, 3) - .addParameter(MAX_ELAPSED_KEY, 3) - .addParameter(CONCURRENT_KEY, 1) - .addParameter(MAX_CONCURRENT_KEY, 1) - .build(); - - Statistics statistics1 = new Statistics(statistics); - Statistics statistics2 = new Statistics(statistics); - - MatcherAssert.assertThat(statistics1, equalTo(statistics1)); - MatcherAssert.assertThat(statistics1, equalTo(statistics2)); - - statistics1.setVersion("2"); - MatcherAssert.assertThat(statistics1, not(equalTo(statistics2))); - MatcherAssert.assertThat(statistics1.hashCode(), not(equalTo(statistics2.hashCode()))); - - statistics1.setMethod("anotherMethod"); - MatcherAssert.assertThat(statistics1, not(equalTo(statistics2))); - MatcherAssert.assertThat(statistics1.hashCode(), not(equalTo(statistics2.hashCode()))); - - statistics1.setClient("anotherClient"); - MatcherAssert.assertThat(statistics1, not(equalTo(statistics2))); - MatcherAssert.assertThat(statistics1.hashCode(), not(equalTo(statistics2.hashCode()))); - } - - @Test - void testToString() { - Statistics statistics = new Statistics(new ServiceConfigURL("dubbo", "10.20.153.10", 0)); - statistics.setApplication("demo"); - statistics.setMethod("findPerson"); - statistics.setServer("10.20.153.10"); - statistics.setGroup("unit-test"); - statistics.setService("MemberService"); - assertThat(statistics.toString(), is("dubbo://10.20.153.10")); - - Statistics statisticsWithDetailInfo = new Statistics(new URLBuilder(DUBBO_PROTOCOL, "10.20.153.10", 0) - .addParameter(APPLICATION_KEY, "morgan") - .addParameter(INTERFACE_KEY, "MemberService") - .addParameter(METHOD_KEY, "findPerson") - .addParameter(CONSUMER, "10.20.153.11") - .addParameter(GROUP_KEY, "unit-test") - .addParameter(SUCCESS_KEY, 1) - .addParameter(FAILURE_KEY, 0) - .addParameter(ELAPSED_KEY, 3) - .addParameter(MAX_ELAPSED_KEY, 3) - .addParameter(CONCURRENT_KEY, 1) - .addParameter(MAX_CONCURRENT_KEY, 1) - .build()); - - MatcherAssert.assertThat(statisticsWithDetailInfo.getServer(), equalTo(statistics.getServer())); - MatcherAssert.assertThat(statisticsWithDetailInfo.getService(), equalTo(statistics.getService())); - MatcherAssert.assertThat(statisticsWithDetailInfo.getMethod(), equalTo(statistics.getMethod())); - - MatcherAssert.assertThat(statisticsWithDetailInfo.getGroup(), equalTo(statistics.getGroup())); - MatcherAssert.assertThat(statisticsWithDetailInfo, not(equalTo(statistics))); - } -} diff --git a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/service/DemoService.java b/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/service/DemoService.java deleted file mode 100644 index ac0e13c81d..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/test/java/org/apache/dubbo/monitor/dubbo/service/DemoService.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.monitor.dubbo.service; - -public interface DemoService { - - String sayName(String name); - - void timeoutException(); - - void throwDemoException() throws Exception; - - int echo(int i); -} diff --git a/dubbo-monitor/dubbo-monitor-default/src/test/resources/dubbo.properties b/dubbo-monitor/dubbo-monitor-default/src/test/resources/dubbo.properties deleted file mode 100644 index 1aade88a56..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/test/resources/dubbo.properties +++ /dev/null @@ -1,2 +0,0 @@ -dubbo.application.enable-file-cache=false -dubbo.service.shutdown.wait=200 diff --git a/dubbo-monitor/dubbo-monitor-default/src/test/resources/log4j2-test.xml b/dubbo-monitor/dubbo-monitor-default/src/test/resources/log4j2-test.xml deleted file mode 100644 index ba99f52cc2..0000000000 --- a/dubbo-monitor/dubbo-monitor-default/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to You under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> -<Configuration status="WARN"> - <Appenders> - <Console name="Console" target="SYSTEM_OUT" follow="true"> - <PatternLayout pattern="%d{HH:mm:ss.SSS} |-%highlight{%-5p} [%t] %40.40c:%-3L -| %m%n%rEx{filters(jdk.internal.reflect,java.lang.reflect,sun.reflect,org.junit,org.mockito)}" charset="UTF-8"/> - </Console> - </Appenders> - <Loggers> - <Root level="info"> - <AppenderRef ref="Console"/> - </Root> - </Loggers> -</Configuration> diff --git a/dubbo-monitor/pom.xml b/dubbo-monitor/pom.xml deleted file mode 100644 index e859ef6bad..0000000000 --- a/dubbo-monitor/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-parent</artifactId> - <version>${revision}</version> - <relativePath>../pom.xml</relativePath> - </parent> - <artifactId>dubbo-monitor</artifactId> - <packaging>pom</packaging> - <name>${project.artifactId}</name> - <description>The monitor module of dubbo project</description> - <modules> - <module>dubbo-monitor-api</module> - <module>dubbo-monitor-common</module> - <module>dubbo-monitor-default</module> - </modules> - <properties> - <skip_maven_deploy>false</skip_maven_deploy> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-test-check</artifactId> - <version>${project.parent.version}</version> - <scope>test</scope> - </dependency> - </dependencies> - -</project> diff --git a/dubbo-test/dubbo-dependencies-all/pom.xml b/dubbo-test/dubbo-dependencies-all/pom.xml index 5e67cf6fce..fc6d76eed8 100644 --- a/dubbo-test/dubbo-dependencies-all/pom.xml +++ b/dubbo-test/dubbo-dependencies-all/pom.xml @@ -206,22 +206,6 @@ <version>${project.version}</version> </dependency> - <!-- monitor --> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-monitor-default</artifactId> - <version>${project.version}</version> - </dependency> <!-- native --> <dependency> <groupId>org.apache.dubbo</groupId> diff --git a/pom.xml b/pom.xml index c188ff099f..34412d960a 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,6 @@ <module>dubbo-rpc</module> <module>dubbo-cluster</module> <module>dubbo-registry</module> - <module>dubbo-monitor</module> <module>dubbo-config</module> <module>dubbo-demo</module> <module>dubbo-plugin</module>