This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git
The following commit(s) were added to refs/heads/master by this push:
new c9d20e0d3 :fire: remove unused samples metrics (#1037)
c9d20e0d3 is described below
commit c9d20e0d3deeb1f4771c6c2b93041045ab37566b
Author: xiaosheng <[email protected]>
AuthorDate: Thu Dec 21 10:21:41 2023 +0800
:fire: remove unused samples metrics (#1037)
* :fire: remove unused samples metrics
* :fire: remove unused samples metrics
---
4-governance/dubbo-samples-metrics/README.md | 26 --
4-governance/dubbo-samples-metrics/pom.xml | 173 ------------
.../dubbo/samples/metrics/EmbeddedZooKeeper.java | 309 ---------------------
.../dubbo/samples/metrics/MetricsConsumer.java | 59 ----
.../dubbo/samples/metrics/MetricsProvider.java | 51 ----
.../dubbo/samples/metrics/api/DemoService.java | 51 ----
.../samples/metrics/impl/DemoServiceImpl.java | 88 ------
.../apache/dubbo/samples/metrics/model/Result.java | 69 -----
.../apache/dubbo/samples/metrics/model/User.java | 66 -----
.../src/main/resources/log4j2.xml | 29 --
.../main/resources/spring/dubbo-demo-consumer.xml | 32 ---
.../main/resources/spring/dubbo-demo-provider.xml | 38 ---
.../dubbo/samples/metrics/MetricsServiceIT.java | 63 -----
4-governance/pom.xml | 1 -
14 files changed, 1055 deletions(-)
diff --git a/4-governance/dubbo-samples-metrics/README.md
b/4-governance/dubbo-samples-metrics/README.md
deleted file mode 100644
index 433a7fd68..000000000
--- a/4-governance/dubbo-samples-metrics/README.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# 使用Metrics模块进行数据采集
-Dubbo使用开源的[Dubbo
Metrics](https://github.com/alibaba/metrics)进行数据埋点,并且通过服务暴露,使用的时候,首先需要进行配置:
-
-* 依赖(其中dubbo版本在2.7.2及以后)
-```xml
-<dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-monitor-default</artifactId>
- <version>${dubbo.version}</version>
-</dependency>
-```
-* 服务端
-```xml
-<dubbo:metrics port="20880" protocol="dubbo"/>
-<dubbo:provider filter="metrics" />
-```
-
-* 客户端
-```xml
-<dubbo:metrics port="20880" protocol="dubbo"/>
-<dubbo:consumer filter="metrics" />
-```
-其中,`<dubbo:metrics />`的配置指定了metrics暴露的协议和端口,这些信息会被放在元数据里面,而`<dubbo:provider
/>`和`<dubbo: consuer
/>`则在服务端和客户端分别激活了metrics的filter,如果你的服务分别含有服务端和客户端,选择在一端激活就可以。
-
-* dubbo admin
-完成这些配置后,获取[dubbo
admin](https://github.com/apache/dubbo-admin)在`develop`分支的最新代码,启动后,在左侧Metrics(统计)标签输入目标机器的IP,可以看到调用,线程池等Metrics信息
diff --git a/4-governance/dubbo-samples-metrics/pom.xml
b/4-governance/dubbo-samples-metrics/pom.xml
deleted file mode 100644
index 06277e60f..000000000
--- a/4-governance/dubbo-samples-metrics/pom.xml
+++ /dev/null
@@ -1,173 +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/xsd/maven-4.0.0.xsd">
- <parent>
- <groupId>org.apache</groupId>
- <artifactId>apache</artifactId>
- <version>23</version>
- <relativePath/>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-samples-metrics</artifactId>
- <version>1.0-SNAPSHOT</version>
-
- <name>Dubbo Samples Metrics</name>
- <description>Dubbo Samples Metrics</description>
-
- <properties>
- <maven.compiler.source>1.8</maven.compiler.source>
- <maven.compiler.target>1.8</maven.compiler.target>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-
- <dubbo.version>3.2.6</dubbo.version>
- <spring.version>4.3.30.RELEASE</spring.version>
- <log4j2.version>2.20.0</log4j2.version>
- <junit.version>4.13.1</junit.version>
-
- <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
- </properties>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-framework-bom</artifactId>
- <version>${spring.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-bom</artifactId>
- <version>${dubbo.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-dependencies-zookeeper-curator5</artifactId>
- <version>${dubbo.version}</version>
- <type>pom</type>
- <exclusions>
- <exclusion>
- <artifactId>logback-classic</artifactId>
- <groupId>ch.qos.logback</groupId>
- </exclusion>
- <exclusion>
- <artifactId>logback-core</artifactId>
- <groupId>ch.qos.logback</groupId>
- </exclusion>
- <exclusion>
- <artifactId>log4j</artifactId>
- <groupId>log4j</groupId>
- </exclusion>
- <exclusion>
- <artifactId>slf4j-log4j12</artifactId>
- <groupId>org.slf4j</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metrics-default</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-dependencies-zookeeper-curator5</artifactId>
- <type>pom</type>
- </dependency>
-
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- <version>${log4j2.version}</version>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>fastjson</artifactId>
- <version>1.2.83</version>
- </dependency>
-
- <!-- Embedded Zookeeper Server Dependencies -->
- <dependency>
- <groupId>io.dropwizard.metrics</groupId>
- <artifactId>metrics-core</artifactId>
- <version>4.1.12.1</version>
- </dependency>
- <dependency>
- <groupId>org.xerial.snappy</groupId>
- <artifactId>snappy-java</artifactId>
- <version>1.1.10.5</version>
- </dependency>
- </dependencies>
-
- <profiles>
- <!-- For jdk 11 above JavaEE annotation -->
- <profile>
- <id>javax.annotation</id>
- <activation>
- <jdk>[1.11,)</jdk>
- </activation>
- <dependencies>
- <dependency>
- <groupId>javax.annotation</groupId>
- <artifactId>javax.annotation-api</artifactId>
- <version>1.3.2</version>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>${maven-compiler-plugin.version}</version>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/EmbeddedZooKeeper.java
b/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/EmbeddedZooKeeper.java
deleted file mode 100644
index c6b3fd4ad..000000000
---
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/EmbeddedZooKeeper.java
+++ /dev/null
@@ -1,309 +0,0 @@
-
-/*
- * Copyright 2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dubbo.samples.metrics;
-
-import org.apache.zookeeper.server.ServerConfig;
-import org.apache.zookeeper.server.ZooKeeperServerMain;
-import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.SmartLifecycle;
-import org.springframework.util.ErrorHandler;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.ServerSocket;
-import java.util.List;
-import java.util.Properties;
-import java.util.Random;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-/**
- * from:
https://github.com/spring-projects/spring-xd/blob/v1.3.1.RELEASE/spring-xd-dirt/src/main/java/org/springframework/xd/dirt/zookeeper/ZooKeeperUtils.java
- * <p>
- * Helper class to start an embedded instance of standalone (non clustered)
ZooKeeper.
- * <p>
- * NOTE: at least an external standalone server (if not an ensemble) are
recommended, even for
- * {@link org.springframework.xd.dirt.server.singlenode.SingleNodeApplication}
- *
- * @author Patrick Peralta
- * @author Mark Fisher
- * @author David Turanski
- */
-public class EmbeddedZooKeeper implements SmartLifecycle {
-
- private static final Random RANDOM = new Random();
-
- /**
- * Logger.
- */
- private static final Logger logger =
LoggerFactory.getLogger(EmbeddedZooKeeper.class);
-
- /**
- * ZooKeeper client port. This will be determined dynamically upon startup.
- */
- private final int clientPort;
-
- /**
- * Whether to auto-start. Default is true.
- */
- private boolean autoStartup = true;
-
- /**
- * Lifecycle phase. Default is 0.
- */
- private int phase = 0;
-
- /**
- * Thread for running the ZooKeeper server.
- */
- private volatile Thread zkServerThread;
-
- /**
- * ZooKeeper server.
- */
- private volatile ZooKeeperServerMain zkServer;
-
- /**
- * {@link ErrorHandler} to be invoked if an Exception is thrown from the
ZooKeeper server thread.
- */
- private ErrorHandler errorHandler;
-
- private boolean daemon = true;
-
- /**
- * Construct an EmbeddedZooKeeper with a random port.
- */
- public EmbeddedZooKeeper() {
- clientPort = findRandomPort(30000, 65535);
- }
-
- /**
- * Construct an EmbeddedZooKeeper with the provided port.
- *
- * @param clientPort port for ZooKeeper server to bind to
- */
- public EmbeddedZooKeeper(int clientPort, boolean daemon) {
- this.clientPort = clientPort;
- this.daemon = daemon;
- }
-
- /**
- * Returns the port that clients should use to connect to this embedded
server.
- *
- * @return dynamically determined client port
- */
- public int getClientPort() {
- return this.clientPort;
- }
-
- /**
- * Specify whether to start automatically. Default is true.
- *
- * @param autoStartup whether to start automatically
- */
- public void setAutoStartup(boolean autoStartup) {
- this.autoStartup = autoStartup;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isAutoStartup() {
- return this.autoStartup;
- }
-
- /**
- * Specify the lifecycle phase for the embedded server.
- *
- * @param phase the lifecycle phase
- */
- public void setPhase(int phase) {
- this.phase = phase;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getPhase() {
- return this.phase;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isRunning() {
- return (zkServerThread != null);
- }
-
- /**
- * Start the ZooKeeper server in a background thread.
- * <p>
- * Register an error handler via {@link #setErrorHandler} in order to
handle
- * any exceptions thrown during startup or execution.
- */
- @Override
- public synchronized void start() {
- if (zkServerThread == null) {
- zkServerThread = new Thread(new ServerRunnable(), "ZooKeeper
Server Starter");
- zkServerThread.setDaemon(daemon);
- zkServerThread.start();
- }
- }
-
- /**
- * Shutdown the ZooKeeper server.
- */
- @Override
- public synchronized void stop() {
- if (zkServerThread != null) {
- // The shutdown method is protected...thus this hack to invoke it.
- // This will log an exception on shutdown; see
- // https://issues.apache.org/jira/browse/ZOOKEEPER-1873 for
details.
- try {
- Method shutdown =
ZooKeeperServerMain.class.getDeclaredMethod("shutdown");
- shutdown.setAccessible(true);
- shutdown.invoke(zkServer);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- // It is expected that the thread will exit after
- // the server is shutdown; this will block until
- // the shutdown is complete.
- try {
- zkServerThread.join(5000);
- zkServerThread = null;
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- logger.warn("Interrupted while waiting for embedded ZooKeeper
to exit");
- // abandoning zk thread
- zkServerThread = null;
- }
- }
- }
-
- /**
- * Stop the server if running and invoke the callback when complete.
- */
- @Override
- public void stop(Runnable callback) {
- stop();
- callback.run();
- }
-
- /**
- * Provide an {@link ErrorHandler} to be invoked if an Exception is thrown
from the ZooKeeper server thread. If none
- * is provided, only error-level logging will occur.
- *
- * @param errorHandler the {@link ErrorHandler} to be invoked
- */
- public void setErrorHandler(ErrorHandler errorHandler) {
- this.errorHandler = errorHandler;
- }
-
- /**
- * Runnable implementation that starts the ZooKeeper server.
- */
- private class ServerRunnable implements Runnable {
-
- @Override
- public void run() {
- try {
- Properties properties = new Properties();
- File file = new File(System.getProperty("java.io.tmpdir")
- + File.separator + UUID.randomUUID());
- file.deleteOnExit();
- properties.setProperty("dataDir", file.getAbsolutePath());
- properties.setProperty("clientPort",
String.valueOf(clientPort));
-
- QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
- quorumPeerConfig.parseProperties(properties);
-
- zkServer = new ZooKeeperServerMain();
- ServerConfig configuration = new ServerConfig();
- configuration.readFrom(quorumPeerConfig);
-
- System.setProperty("zookeeper.admin.enableServer", "false");
-
- zkServer.runFromConfig(configuration);
- } catch (Exception e) {
- if (errorHandler != null) {
- errorHandler.handleError(e);
- } else {
- logger.error("Exception running embedded ZooKeeper", e);
- }
- }
- }
- }
-
- /**
- * Workaround for SocketUtils.findRandomPort() deprecation.
- *
- * @param min min port
- * @param max max port
- * @return a random generated available port
- */
- private static int findRandomPort(int min, int max) {
- if (min < 1024) {
- throw new IllegalArgumentException("Max port shouldn't be less
than 1024.");
- }
-
- if (max > 65535) {
- throw new IllegalArgumentException("Max port shouldn't be greater
than 65535.");
- }
-
- if (min > max) {
- throw new IllegalArgumentException("Min port shouldn't be greater
than max port.");
- }
-
- int port = 0;
- int counter = 0;
-
- // Workaround for legacy JDK doesn't support Random.nextInt(min, max).
- List<Integer> randomInts = RANDOM.ints(min, max + 1)
- .limit(max - min)
- .mapToObj(Integer::valueOf)
- .collect(Collectors.toList());
-
- do {
- if (counter > max - min) {
- throw new IllegalStateException("Unable to find a port between
" + min + "-" + max);
- }
-
- port = randomInts.get(counter);
- counter++;
- } while (isPortInUse(port));
-
- return port;
- }
-
- private static boolean isPortInUse(int port) {
- try (ServerSocket ignored = new ServerSocket(port)) {
- return false;
- } catch (IOException e) {
- // continue
- }
- return true;
- }
-}
diff --git
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/MetricsConsumer.java
b/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/MetricsConsumer.java
deleted file mode 100644
index 54d2caceb..000000000
---
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/MetricsConsumer.java
+++ /dev/null
@@ -1,59 +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.
- */
-
-/*
- * Copyright 2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dubbo.samples.metrics;
-
-import org.apache.dubbo.samples.metrics.api.DemoService;
-import org.apache.dubbo.samples.metrics.model.Result;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class MetricsConsumer {
-
- public static void main(String[] args) {
- ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext("spring/dubbo-demo-consumer.xml");
- context.start();
-
- DemoService demoService = context.getBean("demoService",
DemoService.class);
-
- while (true) {
- try {
- Thread.sleep(3000);
- Result hello = demoService.sayHello("world");
- System.out.println(hello.getMsg());
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
-}
diff --git
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/MetricsProvider.java
b/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/MetricsProvider.java
deleted file mode 100644
index 350c5fa55..000000000
---
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/MetricsProvider.java
+++ /dev/null
@@ -1,51 +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.
- */
-
-/*
- * Copyright 2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dubbo.samples.metrics;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import java.util.concurrent.CountDownLatch;
-
-public class MetricsProvider {
-
- public static void main(String[] args) throws Exception {
- new EmbeddedZooKeeper(2181, false).start();
-
- ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext("spring/dubbo-demo-provider.xml");
- context.start();
-
- System.out.println("dubbo service started");
- new CountDownLatch(1).await();
- }
-}
diff --git
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/api/DemoService.java
b/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/api/DemoService.java
deleted file mode 100644
index 3394fe55b..000000000
---
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/api/DemoService.java
+++ /dev/null
@@ -1,51 +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.
- */
-
-/*
- * Copyright 2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dubbo.samples.metrics.api;
-
-import org.apache.dubbo.samples.metrics.model.Result;
-import org.apache.dubbo.samples.metrics.model.User;
-
-import java.util.concurrent.CompletableFuture;
-
-public interface DemoService {
- CompletableFuture<Integer> sayHello();
-
- Result sayHello(String name);
-
- Result sayHello(Long id, String name);
-
- Result sayHello(User user);
-
- String stringArray(String[] bytes);
-}
diff --git
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/impl/DemoServiceImpl.java
b/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/impl/DemoServiceImpl.java
deleted file mode 100644
index 23d0b1c11..000000000
---
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/impl/DemoServiceImpl.java
+++ /dev/null
@@ -1,88 +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.
- */
-
-/*
- * Copyright 2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dubbo.samples.metrics.impl;
-
-import org.apache.dubbo.common.logger.Logger;
-import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.samples.metrics.api.DemoService;
-import org.apache.dubbo.samples.metrics.model.Result;
-import org.apache.dubbo.samples.metrics.model.User;
-
-import org.apache.dubbo.rpc.RpcContext;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.concurrent.CompletableFuture;
-
-public class DemoServiceImpl implements DemoService {
-
- public static final Logger logger =
LoggerFactory.getLogger(DemoServiceImpl.class);
-
- private String name = "Han MeiMei";
-
- @Override
- public CompletableFuture<Integer> sayHello() {
- return CompletableFuture.completedFuture(2122);
- }
-
-
-
- @Override
- public Result sayHello(String localName) {
- logger.info("[" + new SimpleDateFormat("HH:mm:ss").format(new Date())
+ "] Hello " + name + ", request from consumer: " + RpcContext
- .getContext().getRemoteAddress());
- return new Result(name, "Hello " + localName + ", response from
provider: " + RpcContext.getContext().getLocalAddress());
- }
-
- @Override
- public Result sayHello(final Long id, final String name) {
- return sayHello(new User(id, name));
- }
-
- @Override
- public Result sayHello(final User user) {
- String localName = user.getUsername();
- Long id = user.getId();
- logger.info("[" + new SimpleDateFormat("HH:mm:ss").format(new Date())
+ "] Hello " + name + ", request from consumer: " + RpcContext
- .getContext().getRemoteAddress());
- return new Result(name, "Hello " + id + " " + localName +
-// " " + "bytes: " + user.getBytes().toString() +
- ", response from provider: " +
RpcContext.getContext().getLocalAddress());
- }
-
- @Override
- public String stringArray(String[] bytes) {
- return bytes.toString();
- }
-}
diff --git
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/model/Result.java
b/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/model/Result.java
deleted file mode 100644
index 0805ed1f8..000000000
---
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/model/Result.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.
- */
-
-/*
- * Copyright 2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dubbo.samples.metrics.model;
-
-import java.io.Serializable;
-
-/**
- * @author zmx ON 2019-07-03
- */
-public class Result implements Serializable {
- public Result(){
-
- }
-
- public Result(String userName, String msg){
- this.msg = msg;
- this.userName = userName;
- }
-
- private String userName;
- private String msg;
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getMsg() {
- return msg;
- }
-
- public void setMsg(String msg) {
- this.msg = msg;
- }
-}
diff --git
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/model/User.java
b/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/model/User.java
deleted file mode 100644
index e7d044403..000000000
---
a/4-governance/dubbo-samples-metrics/src/main/java/org/apache/dubbo/samples/metrics/model/User.java
+++ /dev/null
@@ -1,66 +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.
- */
-
-/*
- * Copyright 2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dubbo.samples.metrics.model;
-
-import java.io.Serializable;
-
-public class User implements Serializable {
- private Long id;
- private String username;
-
- public User() {
- }
-
- public User(final Long id, final String username) {
- this.id = id;
- this.username = username;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(final Long id) {
- this.id = id;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(final String username) {
- this.username = username;
- }
-
-}
diff --git a/4-governance/dubbo-samples-metrics/src/main/resources/log4j2.xml
b/4-governance/dubbo-samples-metrics/src/main/resources/log4j2.xml
deleted file mode 100644
index 69e1321d2..000000000
--- a/4-governance/dubbo-samples-metrics/src/main/resources/log4j2.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="%style{%d{HH:mm:ss.SSS}}{Magenta}
%style{|-}{White}%highlight{%-5p} [%t] %style{%40.40c}{Cyan}:%style{%-3L}{Blue}
%style{-|}{White}
%m%n%rEx{filters(jdk.internal.reflect,java.lang.reflect,sun.reflect)}"
disableAnsi="false" charset="UTF-8"/>
- </Console>
- </Appenders>
- <Loggers>
- <Root level="info">
- <AppenderRef ref="Console"/>
- </Root>
- </Loggers>
-</Configuration>
diff --git
a/4-governance/dubbo-samples-metrics/src/main/resources/spring/dubbo-demo-consumer.xml
b/4-governance/dubbo-samples-metrics/src/main/resources/spring/dubbo-demo-consumer.xml
deleted file mode 100644
index ada8fe530..000000000
---
a/4-governance/dubbo-samples-metrics/src/main/resources/spring/dubbo-demo-consumer.xml
+++ /dev/null
@@ -1,32 +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.
- -->
-
-<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
- xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
- http://dubbo.apache.org/schema/dubbo
http://dubbo.apache.org/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
- <context:property-placeholder/>
-
- <dubbo:application name="metrics-demo-consumer"/>
-
- <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
-
- <dubbo:reference id="demoService" check="true"
interface="org.apache.dubbo.samples.metrics.api.DemoService"/>
-
-</beans>
diff --git
a/4-governance/dubbo-samples-metrics/src/main/resources/spring/dubbo-demo-provider.xml
b/4-governance/dubbo-samples-metrics/src/main/resources/spring/dubbo-demo-provider.xml
deleted file mode 100644
index 501f3af67..000000000
---
a/4-governance/dubbo-samples-metrics/src/main/resources/spring/dubbo-demo-provider.xml
+++ /dev/null
@@ -1,38 +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.
- -->
-
-<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
- xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
- http://dubbo.apache.org/schema/dubbo
http://dubbo.apache.org/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
- <context:property-placeholder/>
-
- <dubbo:application name="metrics-provider"/>
-
- <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
- <dubbo:config-center
address="zookeeper://${zookeepr.address:127.0.0.1}:2181" />
- <dubbo:metadata-report
address="zookeeper://${zookeeper.address:127.0.0.1}:2181" />
-
- <dubbo:metrics port="20880" protocol="dubbo"/>
- <dubbo:provider filter="metrics" />
-
- <bean id="demoService"
class="org.apache.dubbo.samples.metrics.impl.DemoServiceImpl"/>
-
- <dubbo:service
interface="org.apache.dubbo.samples.metrics.api.DemoService" ref="demoService"/>
-</beans>
diff --git
a/4-governance/dubbo-samples-metrics/src/test/java/org/apache/dubbo/samples/metrics/MetricsServiceIT.java
b/4-governance/dubbo-samples-metrics/src/test/java/org/apache/dubbo/samples/metrics/MetricsServiceIT.java
deleted file mode 100644
index 71fb2f8de..000000000
---
a/4-governance/dubbo-samples-metrics/src/test/java/org/apache/dubbo/samples/metrics/MetricsServiceIT.java
+++ /dev/null
@@ -1,63 +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.samples.metrics;
-
-import org.apache.dubbo.config.ApplicationConfig;
-import org.apache.dubbo.config.ReferenceConfig;
-import org.apache.dubbo.monitor.MetricsService;
-import org.apache.dubbo.samples.metrics.api.DemoService;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations =
{"classpath:/spring/dubbo-demo-consumer.xml"})
-public class MetricsServiceIT {
- private static String providerHost = System.getProperty("dubbo.address",
"127.0.0.1");
- private static int providerPort = Integer.getInteger("dubbo.port", 20880);
-
- @Autowired
- private DemoService demoService;
-
- @Test
- public void test() throws Exception {
- for (int i = 0; i < 10; i++) {
- System.out.println("result: " + demoService.sayHello("dubbo"));
- }
-
- ReferenceConfig<MetricsService> reference = new ReferenceConfig<>();
- reference.setApplication(new
ApplicationConfig("metrics-demo-consumer"));
- reference.setUrl("dubbo://" + providerHost + ":" + providerPort + "/"
+ MetricsService.class.getName());
- reference.setInterface(MetricsService.class);
- MetricsService service = reference.get();
- String result = service.getMetricsByGroup("dubbo");
- JSONArray metrics = (JSONArray) JSON.parse(result);
- Assert.assertFalse(metrics.isEmpty());
- for (int i = 0; i < metrics.size(); i++) {
- String metric = (String) ((JSONObject)
metrics.get(1)).get("metric");
- Assert.assertTrue(metric.startsWith("dubbo.provider") ||
metric.startsWith("threadPool"));
- }
- }
-}
diff --git a/4-governance/pom.xml b/4-governance/pom.xml
index 2934f0056..4b8192baf 100644
--- a/4-governance/pom.xml
+++ b/4-governance/pom.xml
@@ -30,7 +30,6 @@
<module>dubbo-samples-applevel-override</module>
<module>dubbo-samples-configconditionrouter</module>
<module>dubbo-samples-meshrule-router</module>
- <module>dubbo-samples-metrics</module>
<module>dubbo-samples-metrics-prometheus</module>
<module>dubbo-samples-metrics-spring-boot</module>
<module>dubbo-samples-sentinel</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]