From dcf5720dfb02f4ff5e05c76e8cc89ab9334c1e8f Mon Sep 17 00:00:00 2001 From: JinQian <1184773579@qq.com> Date: Tue, 27 Aug 2024 10:17:10 +0800 Subject: [PATCH 1/9] feat(dubbo-actuator):add actuator --- .../dubbo/qos/QosScopeModelInitializer.java | 6 +- .../qos/command/ActuatorCommandExecutor.java | 62 +++++ .../dubbo/qos/command/ActuatorExecutor.java | 22 ++ .../dubbo-spring-boot-actuator/README.md | 256 +++++++++++++++++- .../dubbo-spring-boot-actuator/pom.xml | 7 + ...boEndpointAnnotationAutoConfiguration.java | 6 +- ...tadataEndpoint.java => DubboEndpoint.java} | 25 +- .../dubbo-endpoints-default.properties | 37 +++ ...dpointAnnotationAutoConfigurationTest.java | 4 +- .../actuate/endpoint/DubboEndpointTest.java | 8 +- .../actuator/pom.xml | 7 + ...bboExtensionEndpointAutoConfiguration.java | 39 +++ .../DubboActuatorProperties.java | 45 +++ .../service/DubboActuatorService.java | 35 +++ ...ot.autoconfigure.AutoConfiguration.imports | 1 + 15 files changed, 546 insertions(+), 14 deletions(-) create mode 100644 dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorCommandExecutor.java create mode 100644 dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorExecutor.java rename dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/{DubboMetadataEndpoint.java => DubboEndpoint.java} (62%) create mode 100644 dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboExtensionEndpointAutoConfiguration.java create mode 100644 dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboActuatorProperties.java create mode 100644 dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/service/DubboActuatorService.java diff --git a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/QosScopeModelInitializer.java b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/QosScopeModelInitializer.java index 58125556bae..cf2679c36a1 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/QosScopeModelInitializer.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/QosScopeModelInitializer.java @@ -17,6 +17,7 @@ package org.apache.dubbo.qos; import org.apache.dubbo.common.beans.factory.ScopeBeanFactory; +import org.apache.dubbo.qos.command.ActuatorCommandExecutor; import org.apache.dubbo.qos.command.util.SerializeCheckUtils; import org.apache.dubbo.qos.server.Server; import org.apache.dubbo.rpc.model.ApplicationModel; @@ -33,7 +34,10 @@ public void initializeFrameworkModel(FrameworkModel frameworkModel) { } @Override - public void initializeApplicationModel(ApplicationModel applicationModel) {} + public void initializeApplicationModel(ApplicationModel applicationModel) { + ScopeBeanFactory beanFactory = applicationModel.getBeanFactory(); + beanFactory.registerBean(ActuatorCommandExecutor.class); + } @Override public void initializeModuleModel(ModuleModel moduleModel) {} diff --git a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorCommandExecutor.java b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorCommandExecutor.java new file mode 100644 index 00000000000..41be22d4b29 --- /dev/null +++ b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorCommandExecutor.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.qos.command; + +import org.apache.dubbo.common.logger.Logger; +import org.apache.dubbo.common.logger.LoggerFactory; +import org.apache.dubbo.qos.api.BaseCommand; +import org.apache.dubbo.qos.api.CommandContext; +import org.apache.dubbo.rpc.model.ApplicationModel; + +import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_UNEXPECTED_EXCEPTION; + +public class ActuatorCommandExecutor implements ActuatorExecutor { + private static final Logger log = LoggerFactory.getLogger(DefaultCommandExecutor.class); + private final ApplicationModel applicationModel; + + public ActuatorCommandExecutor(ApplicationModel applicationModel) { + this.applicationModel = applicationModel; + } + + @Override + public String execute(String commandName, String[] parameters) { + CommandContext commandContext; + + if (parameters == null || parameters.length == 0) { + commandContext = CommandContextFactory.newInstance(commandName); + commandContext.setHttp(true); + } else { + commandContext = CommandContextFactory.newInstance(commandName, parameters, true); + } + + BaseCommand command; + try { + command = applicationModel + .getExtensionLoader(BaseCommand.class) + .getExtension(commandContext.getCommandName()); + return command.execute(commandContext, commandContext.getArgs()); + } catch (Exception qosEx) { + log.error( + QOS_UNEXPECTED_EXCEPTION, + "", + "", + "execute commandContext: " + commandContext + " got exception", + qosEx); + return qosEx.getMessage(); + } + } +} diff --git a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorExecutor.java b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorExecutor.java new file mode 100644 index 00000000000..f63abf07e87 --- /dev/null +++ b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorExecutor.java @@ -0,0 +1,22 @@ +/* + * 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.qos.command; + +public interface ActuatorExecutor { + + String execute(String command, String[] args); +} diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/README.md b/dubbo-spring-boot/dubbo-spring-boot-actuator/README.md index b0f22c027ca..989c2aef3fb 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/README.md +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/README.md @@ -153,7 +153,39 @@ Actuator endpoint `dubbo` supports Actuator Endpoints : | `dubboservices` | `false` | `/actuator/dubbo/services` | `GET` | Exposes all Dubbo's `ServiceBean` | `application/json` | | `dubboreferences` | `false` | `/actuator/dubbo/references` | `GET` | Exposes all Dubbo's `ReferenceBean` | `application/json` | | `dubboconfigs` | `true` | `/actuator/dubbo/configs` | `GET` | Exposes all Dubbo's `*Config` | `application/json` | -| `dubboshutdown` | `false` | `/actuator/dubbo/shutdown` | `POST` | Shutdown Dubbo services | `application/json` | +| `dubboshutdown` | `false` | `/actuator/dubbo/shutdown` | `GET` | Shutdown Dubbo services | `application/json` | +| `dubbohelp` | `true` | `/actuator/dubbo/help` | `GET` | List all commands | | +| `dubboready` | `true` | `/actuator/dubbo/ready` | `GET` | Check whether the current process/service is ready for external service | `application/json` | +| `dubbols` | `true` | `/actuator/dubbo/ls` | `GET` | List consumers and providers | `application/json` | +| `dubbostartup` | `true` | `/actuator/dubbo/startup` | `GET` | Check if the current framework has been started | `application/json` | +| `dubbops` | `true` | `/actuator/dubbo/ps` | `GET` | View information about the current process, including `listenable` ports | `application/json` | +| `dubboversion` | `true` | `/actuator/dubbo/version` | `GET` | Display the version number of the currently running `Dubbo` | `application/json` | +| `dubbogetaddress` | `true` | `/actuator/dubbo/getaddress?args=xxx.*` | `GET` | View the list of valid `IP` addresses for a service | `application/json` | +| `dubbogetconfig` | `true` | `/actuator/dubbo/getconfig` | `GET` | View the valid `configuration` of the current application | `application/json` | +| `dubbometrics` | `true` | `/actuator/dubbo/metrics` | `GET` | View `metrics`(Need to enable metrics statistics) | `application/json` | +| `dubbometrics_default` | `true` | `/actuator/dubbo/metrics_default` | `GET` | View the default `metrics`(Need to enable metrics statistics) | `application/json` | +| `dubbopublishmetadata` | `true` | `/actuator/dubbo/publishmetadata` or `/actuator/dubbo/publishmetadata?args=10` | `GET` | Publishes or updates the current application `Metadata` (Delay can be set) | `application/json` | +| `dubboonline` | `true` | `/actuator/dubbo/online` or `/actuator/dubbo/online?args=xxx.*` | `GET` | Register one or more services to the registry (including application and interface addresses) | `application/json` | +| `dubboonlineapp` | `true` | `/actuator/dubbo/onlineApp` or `/actuator/dubbo/onlineApp?args=xxx.xxx.*` | `GET` | Register one or more services to the registry (only application addresses) | `application/json` | +| `dubboonlineinterface` | `true` | `/actuator/dubbo/onlineInterface` or `/actuator/dubbo/onlineInterface?args=xxx.*` | `GET` | Register one or more services to the registry (only interface addresses) | `application/json` | +| `dubbooffline` | `true` | `/actuator/dubbo/offline` or `/actuator/dubbo/offline?args=xxx.*` | `GET` | Unregister one or more services from the registry (including application and interface addresses) | `application/json` | +| `dubboofflineapp` | `true` | `/actuator/dubbo/offlineApp` or `/actuator/dubbo/offlineApp?args=xxx.*` | `GET` | Unregister one or more services from the registry (only application addresses) | `application/json` | +| `dubboofflineinterface` | `true` | `/actuator/dubbo/offlineInterface` or `/actuator/dubbo/offlineInterface?args=xxx.*` | `GET` | Unregister one or more services from the registry (only interface addresses) | `application/json` | +| `dubbologgerinfo` | `true` | `/actuator/dubbo/loggerInfo` | `GET` | Query log configuration | `application/json` | +| `dubboswitchlogger` | `true` | `/actuator/dubbo/switchLogger?args={loggerAdapterName}` | `GET` | Modify the log output framework,`loggerAdapterName`: `slf4j`, `jcl`, `log4j`, `jdk`, `log4j2` | `application/json` | +| `dubboswitchloglevel` | `true` | `/actuator/dubbo/switchLogLevel?args={level}` | `GET` | Modify log level,level: `ALL`, `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `OFF` | `application/json` | +| `dubbodisabledetailprofiler` | `true` | `/actuator/dubbo/disableDetailProfiler` | `GET` | Turn off `detail profiler` mode, it will not affect `simple profiler` | `application/json` | +| `dubboenabledetailprofiler` | `true` | `/actuator/dubbo/enableDetailProfiler` | `GET` | Enable the `detail profiler` mode, which is disabled by default, you need to enable the `simple profiler` mode to actually enable it | `application/json` | +| `dubbodisablesimpleprofiler` | `false` | `/actuator/dubbo/disableSimpleProfiler` | `GET` | Turn off the `simple profiler` mode, and the `detail profiler` will not be enabled after it is turned off | `application/json` | +| `dubboenablesimpleprofiler` | `true` | `/actuator/dubbo/enableSimpleProfiler` | `GET` | Enable `simple profiler` mode, enabled by default | `application/json` | +| `dubbosetprofilerwarnpercent` | `true` | `/actuator/dubbo/setProfilerWarnPercent?args={percent}` | `GET` | Control `serialization` alarm frequency (only for classes in the warning list) | `application/json` | +| `dubboserializecheckstatus` | `true` | `/actuator/dubbo/dubboserializecheckstatus` | `GET` | View the current configuration information | `application/json` | +| `dubboserializewarnedclasses` | `true` | `/actuator/dubbo/dubboserializewarnedclasses` | `GET` | View the real-time alarm list | `application/json` | +| `dubbodisableroutersnapshot` | `true` | `/actuator/dubbo/disableRouterSnapshot` or `/actuator/dubbo/disableRouterSnapshot?args=xxx.*` | `GET` | Disable routing result collection mode | `application/json` | +| `dubboenableroutersnapshot` | `true` | `/actuator/dubbo/enableRouterSnapshot` or `/actuator/dubbo/enableRouterSnapshot?args=xxx.*` | `GET` | Enable routing result collection mode | `application/json` | +| `dubbogetrecentroutersnapshot` | `true` | `/actuator/dubbo/getRecentRouterSnapshot` | `GET` | Obtain the historical routing status (up to 32 results stored) | `application/json` | +| `dubbogetenabledroutersnapshot` | `true` | `/actuator/dubbo/getEnabledRouterSnapshot` | `GET` | Get the services that are currently collecting | `application/json` | +| `dubbogracefulshutdown` | `false` | `/actuator/dubbo/gracefulShutdown` | `GET` | Unregister all services registered by the current IP instance from the registry | `application/json` | @@ -429,6 +461,191 @@ The key is the simple name of Dubbo `*Config` Class , the value is`*Config` Bea +`/actuator/dubbo/online` + +```json +{ + "org.apache.dubbo.springboot.demo.DemoService:null": "online" +} +``` + + + +`/actuator/dubbo/offline` + +```json +{ + "org.apache.dubbo.springboot.demo.DemoService:null": "offline" +} +``` + + + +`/actuator/dubbo/ready` + +`/actuator/dubbo/ready` Detect whether the current framework can provide services normally (may be temporarily offline) : + +```json +{ + "dubbo-springboot-demo-provider": "true" +} +``` + + + +`/actuator/dubbo/ls` + +`/actuator/dubbo/ls `List consumers and providers : + +```json +{ + "Providers": { + "DubboInternal - dubbo-springboot-demo-provider/org.apache.dubbo.metadata.MetadataService:1.0.0": "", + "DubboInternal - dubbo-springboot-demo-provider/org.apache.dubbo.metadata.MetadataServiceV2:2.0.0": "", + "DubboInternal - dubbo-springboot-demo-provider/org.apache.dubbo.metrics.service.MetricsService:1.0.0": "", + "org.apache.dubbo.springboot.demo.DemoService": "zookeeper-A(Y)/zookeeper-I(Y)" + }, + "Consumers": {} +} +``` + +- Services prefixed with `DubboInternal` are built-in services of Dubbo, and are not registered with the registry by default. + +- The first part of `zookeeper-A(Y)` in the service publishing status is the corresponding registry name, and the second part is the registration mode (`A` stands for application-level address registration, `I` stands for interface-level address registration), The third part represents whether the corresponding mode has been registered + +- The first part of `zookeeper-AF(I-2,A-2)` in the service subscription status is the corresponding registration center name, and the second part is the subscription mode (`AF` stands for dual subscription mode, `FA` stands for only Application-level subscription, `FI` stands for interface-level subscription only), the first half of the third part represents the source of the address mode (`A` stands for application-level address, `I` stands for interface-level address), and the second half represents the corresponding number of addresses + + + +`/actuator/dubbo/loggerInfo` + +`/actuator/dubbo/loggerInfo` show available logging framework, the logging framework and log level : + +```json +{ + "Available logger adapters": [ + "log4j2", + "slf4j", + "jcl", + "jdk" + ], + "Current Adapter": "slf4j", + "Log level": "INFO" +} +``` + + + +`/actuator/dubbo/switchLogger?logger={loggerAdapterName}` + +`/actuator/dubbo/switchLogger?logger={loggerAdapterName}` allows switching between available logger adapters, and the parameter cannot be empty : + +```json +{ + "Current Adapter": "log4j2" +} +``` + + + +`/actuator/dubbo/switchLogLevel?level={level}` + +`/actuator/dubbo/loggerInfo` allows switching between permitted log levels, and the parameter cannot be empty : + +```json +{ + "Current Log Level": "WARN" +} +``` + +The log configuration modified by `switchLogger`/`switchLogLevel` is not stored persistently and will become invalid after the application is restarted. + + + +`/actuator/dubbo/disableSimpleProfiler` + +`/actuator/dubbo/disableSimpleProfiler` turn off the `simple profiler` mode, and the `detail profiler` will not be enabled after it is turned off : + +```json +{ + "WARN": "Dubbo Invocation Profiler has been disabled" +} +``` + +The performance sampling function can detect the time consumption of various parts of the Dubbo processing link,where `simple profiler` mode is enabled by default. + + + +`/actuator/dubbo/enableDetailProfiler` + +`/actuator/dubbo/enableDetailProfiler` enable the `detail profiler` mode, which is disabled by default, you need to enable the `simple profiler` mode to actually enable it : + +```json +{ + "WARN": "Dubbo Invocation Profiler has been enabled, This will cause performance degradation" +} +``` + +Compared with the `simple profiler` mode, the `detail profiler` collects more time-consuming processing of each filter, specific time-consuming protocols, etc. In the `simple profiler` mode, if you find that there is a long time-consuming situation inside the Dubbo framework, you can enable the `detail profiler` mode to better troubleshoot the problem. + +`/actuator/dubbo/setProfilerPercent?p={precent}` + +`/actuator/dubbo/setProfilerPercent?p={precent}` Control serialization alarm frequency (only for classes in the warning list) : +```json +{ + "Current Dubbo Invocation Profiler warn percent": 0.4 +} +``` + + + +`/actuator/dubbo/disableRouterSnapshot{?service={servicePatern}}` + +`/actuator/dubbo/disableRouterSnapshot?service={servicePatern}` disable routing result collection mode, `servicePatern` is the name of the service to be collected, which supports matching : + +```json +{ + "org.apache.dubbo.springboot.demo.DemoService": "Router snapshot disabled" +} +``` + + + +`/actuator/dubbo/enableRouterSnapshot` + +`/actuator/dubbo/enableRouterSnapshot?service={servicePatern}` enable routing result collection mode, `servicePatern` is the name of the service to be collected, which supports matching : + +```json +{ + "WARN": "Enable router snapshot will cause performance degradation, please be careful!", + "org.apache.dubbo.springboot.demo.DemoService": "Router snapshot enabled" +} +``` + + + +`/actuator/dubbo/getEnabledRouterSnapshot` + +`/actuator/dubbo/getEnabledRouterSnapshot` get the services that are currently collecting + +```json +{ + "Enabled router snapshot": [ + "org.apache.dubbo.springboot.demo.DemoService" + ] +} +``` + +`/actuator/dubbo/gracefulShutdown` unregister all services registered by the current IP instance from the registry. The difference from 'offline' is that this command will also notify all consumers via TCP connection to stop calling this instance : +```json +{ + "org.apache.dubbo.springboot.demo.DemoService:null": "offline" +} +``` +To restore, please execute 'online' to bring all services back online. + + + ## Externalized Configuration @@ -495,5 +712,42 @@ management.endpoint.dubboconfigs.enabled = true management.endpoint.dubboservices.enabled = true management.endpoint.dubboreferences.enabled = true management.endpoint.dubboproperties.enabled = true +management.endpoint.dubbohelp.enabled = true +management.endpoint.dubbocd.enabled = true +management.endpoint.dubbocount.enabled = true +management.endpoint.dubbopwd.enabled = true +management.endpoint.dubboinvoke.enabled = true +management.endpoint.dubboselect.enabled = true +management.endpoint.dubboready.enabled = true +management.endpoint.dubbols.enabled = true +management.endpoint.dubbostartup.enabled = true +management.endpoint.dubbops.enabled = true +management.endpoint.dubboversion.enabled = true +management.endpoint.dubbogetaddress.enabled = true +management.endpoint.dubbogetconfig.enabled = true +management.endpoint.dubbometrics.enabled = true +management.endpoint.dubbometrics_default.enabled = true +management.endpoint.dubbopublishMetadata.enabled = true +management.endpoint.dubboonline.enabled = true +management.endpoint.dubboonlineapp.enabled = true +management.endpoint.dubboonlineinterface.enabled = true +management.endpoint.dubbooffline.enabled = true +management.endpoint.dubboofflineapp.enabled = true +management.endpoint.dubboofflineinterface.enabled = true +management.endpoint.dubbologgerinfo.enabled = true +management.endpoint.dubboswitchlogger.enabled = true +management.endpoint.dubboswitchloglevel.enabled = true +management.endpoint.dubbodisabledetailprofiler.enabled = true +management.endpoint.dubbodisablesimpleprofiler.enabled = true +management.endpoint.dubboenabledetailprofiler.enabled = true +management.endpoint.dubboenablesimpleprofiler.enabled = true +management.endpoint.dubbosetprofilerwarnpercent.enabled = true +management.endpoint.dubboserializecheckstatus.enabled = true +management.endpoint.dubboserializewarnedclasses.enabled = true +management.endpoint.dubbodisableroutersnapshot.enabled = true +management.endpoint.dubboenableroutersnapshot.enabled = true +management.endpoint.dubbogetrecentroutersnapshot.enabled = true +management.endpoint.dubbogetenabledroutersnapshot.enabled = true +management.endpoint.dubbogracefulshutdown.enabled = true ``` diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/pom.xml b/dubbo-spring-boot/dubbo-spring-boot-actuator/pom.xml index b91b00c5256..15d4bf13f93 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/pom.xml +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/pom.xml @@ -111,6 +111,13 @@ true + + org.apache.dubbo + dubbo-qos + ${project.version} + true + + org.springframework.boot diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfiguration.java b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfiguration.java index 93ff379073c..946ba64e401 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfiguration.java +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfiguration.java @@ -17,7 +17,7 @@ package org.apache.dubbo.spring.boot.actuate.autoconfigure; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboConfigsMetadataEndpoint; -import org.apache.dubbo.spring.boot.actuate.endpoint.DubboMetadataEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboPropertiesMetadataEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboReferencesMetadataEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboServicesMetadataEndpoint; @@ -52,8 +52,8 @@ public class DubboEndpointAnnotationAutoConfiguration { @ConditionalOnMissingBean @ConditionalOnAvailableEndpoint @CompatibleConditionalOnEnabledEndpoint - public DubboMetadataEndpoint dubboEndpoint() { - return new DubboMetadataEndpoint(); + public DubboEndpoint dubboEndpoint() { + return new DubboEndpoint(); } @Bean diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboMetadataEndpoint.java b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpoint.java similarity index 62% rename from dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboMetadataEndpoint.java rename to dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpoint.java index 3eb816d17af..1206ccf574d 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboMetadataEndpoint.java +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpoint.java @@ -16,28 +16,47 @@ */ package org.apache.dubbo.spring.boot.actuate.endpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.configuration.DubboActuatorProperties; import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboMetadata; +import org.apache.dubbo.spring.boot.actuate.endpoint.service.DubboActuatorService; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; +import org.springframework.boot.actuate.endpoint.annotation.Selector; +import org.springframework.lang.Nullable; /** - * Actuator {@link Endpoint} to expose Dubbo Meta Data + * Dubbo Actuator {@link Endpoint} * * @see Endpoint - * @since 2.7.0 + * @since 3.3.0 */ @Endpoint(id = "dubbo") -public class DubboMetadataEndpoint { +public class DubboEndpoint { + + @Autowired + private DubboActuatorService dubboActuatorService; @Autowired private DubboMetadata dubboMetadata; + @Autowired + private DubboActuatorProperties dubboActuatorProperties; + @ReadOperation public Map invoke() { return dubboMetadata.invoke(); } + + @ReadOperation + public String handleCommand(@Selector String command, @Nullable String[] args) { + if (dubboActuatorProperties.isEnabled(command.toLowerCase())) { + return dubboActuatorService.invoke(command, args); + } else { + return ("Invalid command or not enabled"); + } + } } diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties index 2eef0739c0e..e4bca33279e 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties @@ -9,6 +9,43 @@ management.endpoint.dubboconfigs.enabled = true management.endpoint.dubboservices.enabled = false management.endpoint.dubboreferences.enabled = false management.endpoint.dubboproperties.enabled = true +management.endpoint.dubbohelp.enabled = true +management.endpoint.dubbocd.enabled = false +management.endpoint.dubbocount.enabled = false +management.endpoint.dubbopwd.enabled = false +management.endpoint.dubboinvoke.enabled = false +management.endpoint.dubboselect.enabled = false +management.endpoint.dubboready.enabled = true +management.endpoint.dubbols.enabled = true +management.endpoint.dubbostartup.enabled = true +management.endpoint.dubbops.enabled = true +management.endpoint.dubboversion.enabled = true +management.endpoint.dubbogetaddress.enabled = true +management.endpoint.dubbogetconfig.enabled = true +management.endpoint.dubbometrics.enabled = true +management.endpoint.dubbometrics_default.enabled = true +management.endpoint.dubbopublishMetadata.enabled = true +management.endpoint.dubboonline.enabled = true +management.endpoint.dubboonlineapp.enabled = true +management.endpoint.dubboonlineinterface.enabled = true +management.endpoint.dubbooffline.enabled = true +management.endpoint.dubboofflineapp.enabled = true +management.endpoint.dubboofflineinterface.enabled = true +management.endpoint.dubbologgerinfo.enabled = true +management.endpoint.dubboswitchlogger.enabled = true +management.endpoint.dubboswitchloglevel.enabled = true +management.endpoint.dubbodisabledetailprofiler.enabled = true +management.endpoint.dubbodisablesimpleprofiler.enabled = false +management.endpoint.dubboenabledetailprofiler.enabled = true +management.endpoint.dubboenablesimpleprofiler.enabled = true +management.endpoint.dubbosetprofilerwarnpercent.enabled = true +management.endpoint.dubboserializecheckstatus.enabled = true +management.endpoint.dubboserializewarnedclasses.enabled = true +management.endpoint.dubbodisableroutersnapshot.enabled = true +management.endpoint.dubboenableroutersnapshot.enabled = true +management.endpoint.dubbogetrecentroutersnapshot.enabled = true +management.endpoint.dubbogetenabledroutersnapshot.enabled = true +management.endpoint.dubbogracefulshutdown.enabled = false # "management.endpoints.web.base-path" should not be configured in this file diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java index 1999808e7b9..65a57377110 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java @@ -21,7 +21,7 @@ import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.bootstrap.DubboBootstrap; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboConfigsMetadataEndpoint; -import org.apache.dubbo.spring.boot.actuate.endpoint.DubboMetadataEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboPropertiesMetadataEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboReferencesMetadataEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboServicesMetadataEndpoint; @@ -86,7 +86,7 @@ class DubboEndpointAnnotationAutoConfigurationTest { @Autowired - private DubboMetadataEndpoint dubboEndpoint; + private DubboEndpoint dubboEndpoint; @Autowired private DubboConfigsMetadataEndpoint dubboConfigsMetadataEndpoint; diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointTest.java b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointTest.java index 0aea4fc7a80..2bae2aace6c 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointTest.java +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointTest.java @@ -34,20 +34,20 @@ import static org.apache.dubbo.common.Version.getVersion; /** - * {@link DubboMetadataEndpoint} Test + * {@link DubboEndpoint} Test * - * @see DubboMetadataEndpoint + * @see DubboEndpoint * @since 2.7.0 */ @ExtendWith(SpringExtension.class) @SpringBootTest( - classes = {DubboMetadataEndpoint.class}, + classes = {DubboEndpoint.class}, properties = {"dubbo.application.name = dubbo-demo-application"}) @EnableAutoConfiguration class DubboEndpointTest { @Autowired - private DubboMetadataEndpoint dubboEndpoint; + private DubboEndpoint dubboEndpoint; @BeforeEach public void init() { diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/pom.xml b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/pom.xml index a185cbb07c9..c25c1f3309c 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/pom.xml +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/pom.xml @@ -94,6 +94,13 @@ test + + org.apache.dubbo + dubbo-qos + ${project.version} + true + + org.springframework.boot diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboExtensionEndpointAutoConfiguration.java b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboExtensionEndpointAutoConfiguration.java new file mode 100644 index 00000000000..fd200f1f790 --- /dev/null +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboExtensionEndpointAutoConfiguration.java @@ -0,0 +1,39 @@ +/* + * 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.spring.boot.actuate.autoconfigure; + +import org.apache.dubbo.spring.boot.actuate.endpoint.configuration.DubboActuatorProperties; +import org.apache.dubbo.spring.boot.actuate.endpoint.service.DubboActuatorService; + +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +import static org.apache.dubbo.spring.boot.util.DubboUtils.DUBBO_PREFIX; + +/** + * Dubbo Extension Endpoints Auto-{@link Configuration} + */ +@ConditionalOnProperty(prefix = DUBBO_PREFIX, name = "enabled", matchIfMissing = true) +@ConditionalOnClass(name = {"org.springframework.boot.actuate.health.Health"}) +@Configuration +@AutoConfigureAfter( + name = {"org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboEndpointMetadataAutoConfiguration"}) +@ComponentScan(basePackageClasses = {DubboActuatorService.class, DubboActuatorProperties.class}) +public class DubboExtensionEndpointAutoConfiguration {} diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboActuatorProperties.java b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboActuatorProperties.java new file mode 100644 index 00000000000..c85608c19b1 --- /dev/null +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboActuatorProperties.java @@ -0,0 +1,45 @@ +/* + * 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.spring.boot.actuate.endpoint.configuration; + +import java.util.Map; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +@Component +@ConfigurationProperties(prefix = "management") +public class DubboActuatorProperties { + + private Map endpoint; + + public Map getEndpoint() { + return endpoint; + } + + public void setEndpoint(Map endpoint) { + this.endpoint = endpoint; + } + + public boolean isEnabled(String command) { + if (StringUtils.hasText(command)) { + Boolean enabled = endpoint.get("dubbo" + command + ".enabled"); + return enabled == null || enabled; + } else return false; + } +} diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/service/DubboActuatorService.java b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/service/DubboActuatorService.java new file mode 100644 index 00000000000..954d771c2d4 --- /dev/null +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/service/DubboActuatorService.java @@ -0,0 +1,35 @@ +/* + * 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.spring.boot.actuate.endpoint.service; + +import org.apache.dubbo.qos.command.ActuatorExecutor; +import org.apache.dubbo.rpc.model.ApplicationModel; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class DubboActuatorService { + + @Autowired + private ApplicationModel applicationModel; + + public String invoke(String command, String[] args) { + ActuatorExecutor actuatorExecutor = applicationModel.getBeanFactory().getBean(ActuatorExecutor.class); + return actuatorExecutor.execute(command, args); + } +} diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index adb80652d81..7d91fbe55bd 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,3 +1,4 @@ org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboEndpointAutoConfiguration org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboHealthIndicatorAutoConfiguration org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboEndpointMetadataAutoConfiguration +org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboExtensionEndpointAutoConfiguration From 0ec4b17df70771b57be235992cb541a187237b1c Mon Sep 17 00:00:00 2001 From: JinQian <1184773579@qq.com> Date: Tue, 27 Aug 2024 14:47:50 +0800 Subject: [PATCH 2/9] fix:Illegal logger method invocations --- .../org/apache/dubbo/qos/command/ActuatorCommandExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorCommandExecutor.java b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorCommandExecutor.java index 41be22d4b29..22991d1e433 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorCommandExecutor.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorCommandExecutor.java @@ -25,7 +25,7 @@ import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_UNEXPECTED_EXCEPTION; public class ActuatorCommandExecutor implements ActuatorExecutor { - private static final Logger log = LoggerFactory.getLogger(DefaultCommandExecutor.class); + private static final Logger log = LoggerFactory.getLogger(ActuatorCommandExecutor.class); private final ApplicationModel applicationModel; public ActuatorCommandExecutor(ApplicationModel applicationModel) { From e1750a126de6b486f75ac2e3b7055e8a1701eb95 Mon Sep 17 00:00:00 2001 From: JinQian <1184773579@qq.com> Date: Thu, 12 Sep 2024 02:30:29 +0800 Subject: [PATCH 3/9] fix:add automatically generate properties,simplify the invoke process,fixed an error where Class name duplicate DubboEndpoint in dubbo-spring-boot-compatible --- .../qos/command/ActuatorCommandExecutor.java | 21 ++-- ...boEndpointAnnotationAutoConfiguration.java | 6 +- ...boEndpoint.java => DubboQosEndpoints.java} | 11 +- .../dubbo-endpoints-default.properties | 27 ++--- ...dpointAnnotationAutoConfigurationTest.java | 6 +- .../actuate/endpoint/DubboEndpointTest.java | 10 +- .../actuator/pom.xml | 24 ++++ ...bboExtensionEndpointAutoConfiguration.java | 3 +- .../DubboEndpointPropertiesGenerator.java | 109 ++++++++++++++++++ .../service/DubboActuatorService.java | 35 ------ pom.xml | 1 + 11 files changed, 178 insertions(+), 75 deletions(-) rename dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/{DubboEndpoint.java => DubboQosEndpoints.java} (83%) create mode 100644 dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboEndpointPropertiesGenerator.java delete mode 100644 dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/service/DubboActuatorService.java diff --git a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorCommandExecutor.java b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorCommandExecutor.java index 22991d1e433..7073eea1245 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorCommandExecutor.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/ActuatorCommandExecutor.java @@ -22,10 +22,10 @@ import org.apache.dubbo.qos.api.CommandContext; import org.apache.dubbo.rpc.model.ApplicationModel; -import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_UNEXPECTED_EXCEPTION; +import java.util.Arrays; public class ActuatorCommandExecutor implements ActuatorExecutor { - private static final Logger log = LoggerFactory.getLogger(ActuatorCommandExecutor.class); + private static final Logger logger = LoggerFactory.getLogger(ActuatorCommandExecutor.class); private final ApplicationModel applicationModel; public ActuatorCommandExecutor(ApplicationModel applicationModel) { @@ -43,20 +43,21 @@ public String execute(String commandName, String[] parameters) { commandContext = CommandContextFactory.newInstance(commandName, parameters, true); } + logger.info("[Dubbo Actuator QoS] Command Process start. Command: " + commandContext.getCommandName() + + ", Args: " + Arrays.toString(commandContext.getArgs())); + BaseCommand command; try { command = applicationModel .getExtensionLoader(BaseCommand.class) .getExtension(commandContext.getCommandName()); return command.execute(commandContext, commandContext.getArgs()); - } catch (Exception qosEx) { - log.error( - QOS_UNEXPECTED_EXCEPTION, - "", - "", - "execute commandContext: " + commandContext + " got exception", - qosEx); - return qosEx.getMessage(); + } catch (Throwable t) { + logger.info( + "[Dubbo Actuator QoS] Command Process Failed. Command: " + commandContext.getCommandName() + + ", Args: " + Arrays.toString(commandContext.getArgs()), + t); + throw t; } } } diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfiguration.java b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfiguration.java index 946ba64e401..e132ace7523 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfiguration.java +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfiguration.java @@ -17,8 +17,8 @@ package org.apache.dubbo.spring.boot.actuate.autoconfigure; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboConfigsMetadataEndpoint; -import org.apache.dubbo.spring.boot.actuate.endpoint.DubboEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboPropertiesMetadataEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboQosEndpoints; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboReferencesMetadataEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboServicesMetadataEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboShutdownEndpoint; @@ -52,8 +52,8 @@ public class DubboEndpointAnnotationAutoConfiguration { @ConditionalOnMissingBean @ConditionalOnAvailableEndpoint @CompatibleConditionalOnEnabledEndpoint - public DubboEndpoint dubboEndpoint() { - return new DubboEndpoint(); + public DubboQosEndpoints dubboQosEndpoints() { + return new DubboQosEndpoints(); } @Bean diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpoint.java b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboQosEndpoints.java similarity index 83% rename from dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpoint.java rename to dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboQosEndpoints.java index 1206ccf574d..4abe1989c6e 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpoint.java +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboQosEndpoints.java @@ -16,9 +16,10 @@ */ package org.apache.dubbo.spring.boot.actuate.endpoint; +import org.apache.dubbo.qos.command.ActuatorExecutor; +import org.apache.dubbo.rpc.model.ApplicationModel; import org.apache.dubbo.spring.boot.actuate.endpoint.configuration.DubboActuatorProperties; import org.apache.dubbo.spring.boot.actuate.endpoint.metadata.DubboMetadata; -import org.apache.dubbo.spring.boot.actuate.endpoint.service.DubboActuatorService; import java.util.Map; @@ -35,10 +36,10 @@ * @since 3.3.0 */ @Endpoint(id = "dubbo") -public class DubboEndpoint { +public class DubboQosEndpoints { @Autowired - private DubboActuatorService dubboActuatorService; + private ApplicationModel applicationModel; @Autowired private DubboMetadata dubboMetadata; @@ -54,7 +55,9 @@ public Map invoke() { @ReadOperation public String handleCommand(@Selector String command, @Nullable String[] args) { if (dubboActuatorProperties.isEnabled(command.toLowerCase())) { - return dubboActuatorService.invoke(command, args); + ActuatorExecutor actuatorExecutor = + applicationModel.getBeanFactory().getBean(ActuatorExecutor.class); + return actuatorExecutor.execute(command, args); } else { return ("Invalid command or not enabled"); } diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties index e4bca33279e..1bf578e3d87 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties @@ -2,6 +2,13 @@ # those values of properties can be override by higher PropertySource # @see DubboEndpointsAutoConfiguration +# "management.endpoints.web.base-path" should not be configured in this file +# Re-defines path-mapping of Dubbo Web Endpoints +management.endpoints.web.path-mapping.dubboshutdown = dubbo/shutdown +management.endpoints.web.path-mapping.dubboconfigs = dubbo/configs +management.endpoints.web.path-mapping.dubboservices = dubbo/services +management.endpoints.web.path-mapping.dubboreferences = dubbo/references +management.endpoints.web.path-mapping.dubboproperties = dubbo/properties # Set enabled for Dubbo Endpoints management.endpoint.dubbo.enabled = true management.endpoint.dubboshutdown.enabled = false @@ -9,15 +16,17 @@ management.endpoint.dubboconfigs.enabled = true management.endpoint.dubboservices.enabled = false management.endpoint.dubboreferences.enabled = false management.endpoint.dubboproperties.enabled = true -management.endpoint.dubbohelp.enabled = true management.endpoint.dubbocd.enabled = false management.endpoint.dubbocount.enabled = false management.endpoint.dubbopwd.enabled = false management.endpoint.dubboinvoke.enabled = false management.endpoint.dubboselect.enabled = false +management.endpoint.dubboquit.enabled = false +management.endpoint.dubbohelp.enabled = true management.endpoint.dubboready.enabled = true management.endpoint.dubbols.enabled = true management.endpoint.dubbostartup.enabled = true +management.endpoint.dubbolive.enabled = true management.endpoint.dubbops.enabled = true management.endpoint.dubboversion.enabled = true management.endpoint.dubbogetaddress.enabled = true @@ -35,7 +44,7 @@ management.endpoint.dubbologgerinfo.enabled = true management.endpoint.dubboswitchlogger.enabled = true management.endpoint.dubboswitchloglevel.enabled = true management.endpoint.dubbodisabledetailprofiler.enabled = true -management.endpoint.dubbodisablesimpleprofiler.enabled = false +management.endpoint.dubbodisablesimpleprofiler.enabled = true management.endpoint.dubboenabledetailprofiler.enabled = true management.endpoint.dubboenablesimpleprofiler.enabled = true management.endpoint.dubbosetprofilerwarnpercent.enabled = true @@ -43,16 +52,8 @@ management.endpoint.dubboserializecheckstatus.enabled = true management.endpoint.dubboserializewarnedclasses.enabled = true management.endpoint.dubbodisableroutersnapshot.enabled = true management.endpoint.dubboenableroutersnapshot.enabled = true +management.endpoint.dubbogetroutersnapshot.enabled = true management.endpoint.dubbogetrecentroutersnapshot.enabled = true +management.endpoint.dubbopublishmetadata.enabled = true +management.endpoint.dubbogracefulshutdown.enabled = true management.endpoint.dubbogetenabledroutersnapshot.enabled = true -management.endpoint.dubbogracefulshutdown.enabled = false - -# "management.endpoints.web.base-path" should not be configured in this file - -# Re-defines path-mapping of Dubbo Web Endpoints - -management.endpoints.web.path-mapping.dubboshutdown = dubbo/shutdown -management.endpoints.web.path-mapping.dubboconfigs = dubbo/configs -management.endpoints.web.path-mapping.dubboservices = dubbo/services -management.endpoints.web.path-mapping.dubboreferences = dubbo/references -management.endpoints.web.path-mapping.dubboproperties = dubbo/properties diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java index 65a57377110..03504a09d1f 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java @@ -21,8 +21,8 @@ import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.bootstrap.DubboBootstrap; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboConfigsMetadataEndpoint; -import org.apache.dubbo.spring.boot.actuate.endpoint.DubboEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboPropertiesMetadataEndpoint; +import org.apache.dubbo.spring.boot.actuate.endpoint.DubboQosEndpoints; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboReferencesMetadataEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboServicesMetadataEndpoint; import org.apache.dubbo.spring.boot.actuate.endpoint.DubboShutdownEndpoint; @@ -86,7 +86,7 @@ class DubboEndpointAnnotationAutoConfigurationTest { @Autowired - private DubboEndpoint dubboEndpoint; + private DubboQosEndpoints dubboQosEndpoints; @Autowired private DubboConfigsMetadataEndpoint dubboConfigsMetadataEndpoint; @@ -225,7 +225,7 @@ void testProperties() { @Test void testHttpEndpoints() throws JsonProcessingException { - // testHttpEndpoint("/dubbo", dubboEndpoint::invoke); + // testHttpEndpoint("/dubbo", dubboQosEndpoints::invoke); testHttpEndpoint("/dubbo/configs", dubboConfigsMetadataEndpoint::configs); testHttpEndpoint("/dubbo/services", dubboServicesMetadataEndpoint::services); testHttpEndpoint("/dubbo/references", dubboReferencesMetadataEndpoint::references); diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointTest.java b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointTest.java index 2bae2aace6c..4af6ffd4672 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointTest.java +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/test/java/org/apache/dubbo/spring/boot/actuate/endpoint/DubboEndpointTest.java @@ -34,20 +34,20 @@ import static org.apache.dubbo.common.Version.getVersion; /** - * {@link DubboEndpoint} Test + * {@link DubboQosEndpoints} Test * - * @see DubboEndpoint + * @see DubboQosEndpoints * @since 2.7.0 */ @ExtendWith(SpringExtension.class) @SpringBootTest( - classes = {DubboEndpoint.class}, + classes = {DubboQosEndpoints.class}, properties = {"dubbo.application.name = dubbo-demo-application"}) @EnableAutoConfiguration class DubboEndpointTest { @Autowired - private DubboEndpoint dubboEndpoint; + private DubboQosEndpoints dubboQosEndpoints; @BeforeEach public void init() { @@ -62,7 +62,7 @@ public void destroy() { @Test void testInvoke() { - Map metadata = dubboEndpoint.invoke(); + Map metadata = dubboQosEndpoints.invoke(); Assert.assertNotNull(metadata.get("timestamp")); diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/pom.xml b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/pom.xml index c25c1f3309c..1cd6ddd9b82 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/pom.xml +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/pom.xml @@ -113,4 +113,28 @@ test + + + + + org.codehaus.mojo + exec-maven-plugin + ${maven_exec_version} + + org.apache.dubbo.spring.boot.actuate.endpoint.configuration.DubboEndpointPropertiesGenerator + compile + + + + generate-actuator-properties + + java + + compile + + + + + + diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboExtensionEndpointAutoConfiguration.java b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboExtensionEndpointAutoConfiguration.java index fd200f1f790..871497fc91f 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboExtensionEndpointAutoConfiguration.java +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboExtensionEndpointAutoConfiguration.java @@ -17,7 +17,6 @@ package org.apache.dubbo.spring.boot.actuate.autoconfigure; import org.apache.dubbo.spring.boot.actuate.endpoint.configuration.DubboActuatorProperties; -import org.apache.dubbo.spring.boot.actuate.endpoint.service.DubboActuatorService; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -35,5 +34,5 @@ @Configuration @AutoConfigureAfter( name = {"org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboEndpointMetadataAutoConfiguration"}) -@ComponentScan(basePackageClasses = {DubboActuatorService.class, DubboActuatorProperties.class}) +@ComponentScan(basePackageClasses = DubboActuatorProperties.class) public class DubboExtensionEndpointAutoConfiguration {} diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboEndpointPropertiesGenerator.java b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboEndpointPropertiesGenerator.java new file mode 100644 index 00000000000..4cea5ce5c11 --- /dev/null +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboEndpointPropertiesGenerator.java @@ -0,0 +1,109 @@ +/* + * 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.spring.boot.actuate.endpoint.configuration; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +public class DubboEndpointPropertiesGenerator { + + public static void main(String[] args) { + String QOS_API_BASE_COMMAND = + "dubbo-plugin/dubbo-qos/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.qos.api.BaseCommand"; + String ENDPOINTS_DEFAULT_PROPERTIES = + "dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties"; + Set newKeywords = DubboEndpointPropertiesGenerator.parseBaseCommandFile(QOS_API_BASE_COMMAND); + DubboEndpointPropertiesGenerator.updatePropertiesFile(ENDPOINTS_DEFAULT_PROPERTIES, newKeywords); + } + + public static Set parseBaseCommandFile(String inputFilePath) { + Set keywords = new HashSet<>(); + + try (BufferedReader reader = new BufferedReader(new FileReader(inputFilePath))) { + String line; + while ((line = reader.readLine()) != null) { + if (!line.trim().isEmpty() && !line.trim().startsWith("#")) { + String[] parts = line.split("="); + if (parts.length > 0) { + String keyword = parts[0].trim().toLowerCase(); + keywords.add(keyword); + } + } + } + } catch (IOException e) { + e.printStackTrace(); + } + return keywords; + } + + public static void updatePropertiesFile(String propertiesFilePath, Set newKeywords) { + HashMap fileContents = new LinkedHashMap<>(); + + try (BufferedReader reader = new BufferedReader(new FileReader(propertiesFilePath))) { + String line; + while ((line = reader.readLine()) != null) { + if (!line.trim().isEmpty() + && !line.trim().startsWith("#") + && line.trim().matches(".*enabled\\s*=\\s*.*")) { + fileContents.put(line.split("=")[0].trim(), Boolean.valueOf(line.split("=")[1].trim())); + } else { + fileContents.put(line.trim(), null); + } + } + Set newProperties = generateDubboProperties(newKeywords); + + for (String element : newProperties) { + if (!fileContents.containsKey(element)) { + fileContents.put(element, true); + } + } + + try (BufferedWriter writer = new BufferedWriter(new FileWriter(propertiesFilePath))) { + for (Map.Entry entry : fileContents.entrySet()) { + String key = entry.getKey(); + Boolean value = entry.getValue(); + if (value == null) { + writer.write(key); + } else { + writer.write(key + " = " + value); + } + writer.newLine(); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + // 根据提取的关键字生成新的配置 + private static Set generateDubboProperties(Set keywords) { + Set properties = new LinkedHashSet<>(); + for (String keyword : keywords) { + properties.add("management.endpoint.dubbo" + keyword + ".enabled"); + } + return properties; + } +} diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/service/DubboActuatorService.java b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/service/DubboActuatorService.java deleted file mode 100644 index 954d771c2d4..00000000000 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/service/DubboActuatorService.java +++ /dev/null @@ -1,35 +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.spring.boot.actuate.endpoint.service; - -import org.apache.dubbo.qos.command.ActuatorExecutor; -import org.apache.dubbo.rpc.model.ApplicationModel; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class DubboActuatorService { - - @Autowired - private ApplicationModel applicationModel; - - public String invoke(String command, String[] args) { - ActuatorExecutor actuatorExecutor = applicationModel.getBeanFactory().getBean(ActuatorExecutor.class); - return actuatorExecutor.execute(command, args); - } -} diff --git a/pom.xml b/pom.xml index 34beaba7b84..39424fa8aad 100644 --- a/pom.xml +++ b/pom.xml @@ -143,6 +143,7 @@ 1.7.1 0.6.1 3.0.2 + 3.4.1 3.22.3 1.54.0 From 20f77438dd93c4f2f618f52f5d9f9541c09edcc8 Mon Sep 17 00:00:00 2001 From: JinQian <1184773579@qq.com> Date: Sat, 28 Sep 2024 00:06:10 +0800 Subject: [PATCH 4/9] fix:Actuator offline and gracefulshutdown operations are disabled by default --- .../META-INF/dubbo-endpoints-default.properties | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties index 1bf578e3d87..a06eb7b6586 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties @@ -33,13 +33,12 @@ management.endpoint.dubbogetaddress.enabled = true management.endpoint.dubbogetconfig.enabled = true management.endpoint.dubbometrics.enabled = true management.endpoint.dubbometrics_default.enabled = true -management.endpoint.dubbopublishMetadata.enabled = true management.endpoint.dubboonline.enabled = true management.endpoint.dubboonlineapp.enabled = true management.endpoint.dubboonlineinterface.enabled = true -management.endpoint.dubbooffline.enabled = true -management.endpoint.dubboofflineapp.enabled = true -management.endpoint.dubboofflineinterface.enabled = true +management.endpoint.dubbooffline.enabled = false +management.endpoint.dubboofflineapp.enabled = false +management.endpoint.dubboofflineinterface.enabled = false management.endpoint.dubbologgerinfo.enabled = true management.endpoint.dubboswitchlogger.enabled = true management.endpoint.dubboswitchloglevel.enabled = true @@ -55,5 +54,5 @@ management.endpoint.dubboenableroutersnapshot.enabled = true management.endpoint.dubbogetroutersnapshot.enabled = true management.endpoint.dubbogetrecentroutersnapshot.enabled = true management.endpoint.dubbopublishmetadata.enabled = true -management.endpoint.dubbogracefulshutdown.enabled = true +management.endpoint.dubbogracefulshutdown.enabled = false management.endpoint.dubbogetenabledroutersnapshot.enabled = true From a3662326ab5097884524ec46c9036025af1ed95f Mon Sep 17 00:00:00 2001 From: JinQian <1184773579@qq.com> Date: Sun, 29 Sep 2024 10:40:01 +0800 Subject: [PATCH 5/9] fix:Only enable live, ready and startup by default --- .../dubbo-endpoints-default.properties | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties index a06eb7b6586..ea4621f624a 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties @@ -12,47 +12,47 @@ management.endpoints.web.path-mapping.dubboproperties = dubbo/properties # Set enabled for Dubbo Endpoints management.endpoint.dubbo.enabled = true management.endpoint.dubboshutdown.enabled = false -management.endpoint.dubboconfigs.enabled = true +management.endpoint.dubboconfigs.enabled = false management.endpoint.dubboservices.enabled = false management.endpoint.dubboreferences.enabled = false -management.endpoint.dubboproperties.enabled = true +management.endpoint.dubboproperties.enabled = false management.endpoint.dubbocd.enabled = false management.endpoint.dubbocount.enabled = false management.endpoint.dubbopwd.enabled = false management.endpoint.dubboinvoke.enabled = false management.endpoint.dubboselect.enabled = false management.endpoint.dubboquit.enabled = false -management.endpoint.dubbohelp.enabled = true +management.endpoint.dubbohelp.enabled = false management.endpoint.dubboready.enabled = true -management.endpoint.dubbols.enabled = true +management.endpoint.dubbols.enabled = false management.endpoint.dubbostartup.enabled = true management.endpoint.dubbolive.enabled = true -management.endpoint.dubbops.enabled = true -management.endpoint.dubboversion.enabled = true -management.endpoint.dubbogetaddress.enabled = true -management.endpoint.dubbogetconfig.enabled = true -management.endpoint.dubbometrics.enabled = true -management.endpoint.dubbometrics_default.enabled = true -management.endpoint.dubboonline.enabled = true -management.endpoint.dubboonlineapp.enabled = true -management.endpoint.dubboonlineinterface.enabled = true +management.endpoint.dubbops.enabled = false +management.endpoint.dubboversion.enabled = false +management.endpoint.dubbogetaddress.enabled = false +management.endpoint.dubbogetconfig.enabled = false +management.endpoint.dubbometrics.enabled = false +management.endpoint.dubbometrics_default.enabled = false +management.endpoint.dubboonline.enabled = false +management.endpoint.dubboonlineapp.enabled = false +management.endpoint.dubboonlineinterface.enabled = false management.endpoint.dubbooffline.enabled = false management.endpoint.dubboofflineapp.enabled = false management.endpoint.dubboofflineinterface.enabled = false -management.endpoint.dubbologgerinfo.enabled = true -management.endpoint.dubboswitchlogger.enabled = true -management.endpoint.dubboswitchloglevel.enabled = true -management.endpoint.dubbodisabledetailprofiler.enabled = true -management.endpoint.dubbodisablesimpleprofiler.enabled = true -management.endpoint.dubboenabledetailprofiler.enabled = true -management.endpoint.dubboenablesimpleprofiler.enabled = true -management.endpoint.dubbosetprofilerwarnpercent.enabled = true -management.endpoint.dubboserializecheckstatus.enabled = true -management.endpoint.dubboserializewarnedclasses.enabled = true -management.endpoint.dubbodisableroutersnapshot.enabled = true -management.endpoint.dubboenableroutersnapshot.enabled = true -management.endpoint.dubbogetroutersnapshot.enabled = true -management.endpoint.dubbogetrecentroutersnapshot.enabled = true -management.endpoint.dubbopublishmetadata.enabled = true +management.endpoint.dubbologgerinfo.enabled = false +management.endpoint.dubboswitchlogger.enabled = false +management.endpoint.dubboswitchloglevel.enabled = false +management.endpoint.dubbodisabledetailprofiler.enabled = false +management.endpoint.dubbodisablesimpleprofiler.enabled = false +management.endpoint.dubboenabledetailprofiler.enabled = false +management.endpoint.dubboenablesimpleprofiler.enabled = false +management.endpoint.dubbosetprofilerwarnpercent.enabled = false +management.endpoint.dubboserializecheckstatus.enabled = false +management.endpoint.dubboserializewarnedclasses.enabled = false +management.endpoint.dubbodisableroutersnapshot.enabled = false +management.endpoint.dubboenableroutersnapshot.enabled = false +management.endpoint.dubbogetroutersnapshot.enabled = false +management.endpoint.dubbogetrecentroutersnapshot.enabled = false +management.endpoint.dubbopublishmetadata.enabled = false management.endpoint.dubbogracefulshutdown.enabled = false -management.endpoint.dubbogetenabledroutersnapshot.enabled = true +management.endpoint.dubbogetenabledroutersnapshot.enabled = false From 064861f61e623756a9a47de7bf8e1f5654e89510 Mon Sep 17 00:00:00 2001 From: JinQian <1184773579@qq.com> Date: Sun, 29 Sep 2024 14:28:55 +0800 Subject: [PATCH 6/9] fix:Remove development comments --- .../endpoint/configuration/DubboEndpointPropertiesGenerator.java | 1 - 1 file changed, 1 deletion(-) diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboEndpointPropertiesGenerator.java b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboEndpointPropertiesGenerator.java index 4cea5ce5c11..e5414aa6ed9 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboEndpointPropertiesGenerator.java +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboEndpointPropertiesGenerator.java @@ -98,7 +98,6 @@ public static void updatePropertiesFile(String propertiesFilePath, Set n } } - // 根据提取的关键字生成新的配置 private static Set generateDubboProperties(Set keywords) { Set properties = new LinkedHashSet<>(); for (String keyword : keywords) { From 4efd175e23a7f12083010f4efb43b14b956f4b76 Mon Sep 17 00:00:00 2001 From: JinQian <1184773579@qq.com> Date: Sun, 29 Sep 2024 18:21:29 +0800 Subject: [PATCH 7/9] fix:Remove automatically generate properties feature --- .../dubbo-endpoints-default.properties | 42 ------- .../actuator/pom.xml | 24 ---- .../DubboActuatorProperties.java | 6 +- .../DubboEndpointPropertiesGenerator.java | 108 ------------------ pom.xml | 1 - 5 files changed, 4 insertions(+), 177 deletions(-) delete mode 100644 dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboEndpointPropertiesGenerator.java diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties index ea4621f624a..39ca0d284dd 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties @@ -11,48 +11,6 @@ management.endpoints.web.path-mapping.dubboreferences = dubbo/references management.endpoints.web.path-mapping.dubboproperties = dubbo/properties # Set enabled for Dubbo Endpoints management.endpoint.dubbo.enabled = true -management.endpoint.dubboshutdown.enabled = false -management.endpoint.dubboconfigs.enabled = false -management.endpoint.dubboservices.enabled = false -management.endpoint.dubboreferences.enabled = false -management.endpoint.dubboproperties.enabled = false -management.endpoint.dubbocd.enabled = false -management.endpoint.dubbocount.enabled = false -management.endpoint.dubbopwd.enabled = false -management.endpoint.dubboinvoke.enabled = false -management.endpoint.dubboselect.enabled = false -management.endpoint.dubboquit.enabled = false -management.endpoint.dubbohelp.enabled = false management.endpoint.dubboready.enabled = true -management.endpoint.dubbols.enabled = false management.endpoint.dubbostartup.enabled = true management.endpoint.dubbolive.enabled = true -management.endpoint.dubbops.enabled = false -management.endpoint.dubboversion.enabled = false -management.endpoint.dubbogetaddress.enabled = false -management.endpoint.dubbogetconfig.enabled = false -management.endpoint.dubbometrics.enabled = false -management.endpoint.dubbometrics_default.enabled = false -management.endpoint.dubboonline.enabled = false -management.endpoint.dubboonlineapp.enabled = false -management.endpoint.dubboonlineinterface.enabled = false -management.endpoint.dubbooffline.enabled = false -management.endpoint.dubboofflineapp.enabled = false -management.endpoint.dubboofflineinterface.enabled = false -management.endpoint.dubbologgerinfo.enabled = false -management.endpoint.dubboswitchlogger.enabled = false -management.endpoint.dubboswitchloglevel.enabled = false -management.endpoint.dubbodisabledetailprofiler.enabled = false -management.endpoint.dubbodisablesimpleprofiler.enabled = false -management.endpoint.dubboenabledetailprofiler.enabled = false -management.endpoint.dubboenablesimpleprofiler.enabled = false -management.endpoint.dubbosetprofilerwarnpercent.enabled = false -management.endpoint.dubboserializecheckstatus.enabled = false -management.endpoint.dubboserializewarnedclasses.enabled = false -management.endpoint.dubbodisableroutersnapshot.enabled = false -management.endpoint.dubboenableroutersnapshot.enabled = false -management.endpoint.dubbogetroutersnapshot.enabled = false -management.endpoint.dubbogetrecentroutersnapshot.enabled = false -management.endpoint.dubbopublishmetadata.enabled = false -management.endpoint.dubbogracefulshutdown.enabled = false -management.endpoint.dubbogetenabledroutersnapshot.enabled = false diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/pom.xml b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/pom.xml index 1cd6ddd9b82..c25c1f3309c 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/pom.xml +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/pom.xml @@ -113,28 +113,4 @@ test - - - - - org.codehaus.mojo - exec-maven-plugin - ${maven_exec_version} - - org.apache.dubbo.spring.boot.actuate.endpoint.configuration.DubboEndpointPropertiesGenerator - compile - - - - generate-actuator-properties - - java - - compile - - - - - - diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboActuatorProperties.java b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboActuatorProperties.java index c85608c19b1..60c27c3be1b 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboActuatorProperties.java +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboActuatorProperties.java @@ -39,7 +39,9 @@ public void setEndpoint(Map endpoint) { public boolean isEnabled(String command) { if (StringUtils.hasText(command)) { Boolean enabled = endpoint.get("dubbo" + command + ".enabled"); - return enabled == null || enabled; - } else return false; + return enabled != null && enabled; + } else { + return false; + } } } diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboEndpointPropertiesGenerator.java b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboEndpointPropertiesGenerator.java deleted file mode 100644 index e5414aa6ed9..00000000000 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboEndpointPropertiesGenerator.java +++ /dev/null @@ -1,108 +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.spring.boot.actuate.endpoint.configuration; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -public class DubboEndpointPropertiesGenerator { - - public static void main(String[] args) { - String QOS_API_BASE_COMMAND = - "dubbo-plugin/dubbo-qos/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.qos.api.BaseCommand"; - String ENDPOINTS_DEFAULT_PROPERTIES = - "dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties"; - Set newKeywords = DubboEndpointPropertiesGenerator.parseBaseCommandFile(QOS_API_BASE_COMMAND); - DubboEndpointPropertiesGenerator.updatePropertiesFile(ENDPOINTS_DEFAULT_PROPERTIES, newKeywords); - } - - public static Set parseBaseCommandFile(String inputFilePath) { - Set keywords = new HashSet<>(); - - try (BufferedReader reader = new BufferedReader(new FileReader(inputFilePath))) { - String line; - while ((line = reader.readLine()) != null) { - if (!line.trim().isEmpty() && !line.trim().startsWith("#")) { - String[] parts = line.split("="); - if (parts.length > 0) { - String keyword = parts[0].trim().toLowerCase(); - keywords.add(keyword); - } - } - } - } catch (IOException e) { - e.printStackTrace(); - } - return keywords; - } - - public static void updatePropertiesFile(String propertiesFilePath, Set newKeywords) { - HashMap fileContents = new LinkedHashMap<>(); - - try (BufferedReader reader = new BufferedReader(new FileReader(propertiesFilePath))) { - String line; - while ((line = reader.readLine()) != null) { - if (!line.trim().isEmpty() - && !line.trim().startsWith("#") - && line.trim().matches(".*enabled\\s*=\\s*.*")) { - fileContents.put(line.split("=")[0].trim(), Boolean.valueOf(line.split("=")[1].trim())); - } else { - fileContents.put(line.trim(), null); - } - } - Set newProperties = generateDubboProperties(newKeywords); - - for (String element : newProperties) { - if (!fileContents.containsKey(element)) { - fileContents.put(element, true); - } - } - - try (BufferedWriter writer = new BufferedWriter(new FileWriter(propertiesFilePath))) { - for (Map.Entry entry : fileContents.entrySet()) { - String key = entry.getKey(); - Boolean value = entry.getValue(); - if (value == null) { - writer.write(key); - } else { - writer.write(key + " = " + value); - } - writer.newLine(); - } - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static Set generateDubboProperties(Set keywords) { - Set properties = new LinkedHashSet<>(); - for (String keyword : keywords) { - properties.add("management.endpoint.dubbo" + keyword + ".enabled"); - } - return properties; - } -} diff --git a/pom.xml b/pom.xml index 39424fa8aad..34beaba7b84 100644 --- a/pom.xml +++ b/pom.xml @@ -143,7 +143,6 @@ 1.7.1 0.6.1 3.0.2 - 3.4.1 3.22.3 1.54.0 From 8a264d94e5beade72b48085deb2c87809f3422b3 Mon Sep 17 00:00:00 2001 From: JinQian <1184773579@qq.com> Date: Mon, 30 Sep 2024 11:06:39 +0800 Subject: [PATCH 8/9] fix:Change the configuration format --- .../META-INF/dubbo-endpoints-default.properties | 6 +++--- .../configuration/DubboActuatorProperties.java | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties index 39ca0d284dd..a42bba69a5a 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties @@ -11,6 +11,6 @@ management.endpoints.web.path-mapping.dubboreferences = dubbo/references management.endpoints.web.path-mapping.dubboproperties = dubbo/properties # Set enabled for Dubbo Endpoints management.endpoint.dubbo.enabled = true -management.endpoint.dubboready.enabled = true -management.endpoint.dubbostartup.enabled = true -management.endpoint.dubbolive.enabled = true +management.endpoint.dubbo.ready.enabled = true +management.endpoint.dubbo.startup.enabled = true +management.endpoint.dubbo.live.enabled = true diff --git a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboActuatorProperties.java b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboActuatorProperties.java index 60c27c3be1b..238c9527cca 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboActuatorProperties.java +++ b/dubbo-spring-boot/dubbo-spring-boot-compatible/actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/configuration/DubboActuatorProperties.java @@ -23,22 +23,22 @@ import org.springframework.util.StringUtils; @Component -@ConfigurationProperties(prefix = "management") +@ConfigurationProperties(prefix = "management.endpoint") public class DubboActuatorProperties { - private Map endpoint; + private Map dubbo; - public Map getEndpoint() { - return endpoint; + public Map getDubbo() { + return dubbo; } - public void setEndpoint(Map endpoint) { - this.endpoint = endpoint; + public void setDubbo(Map dubbo) { + this.dubbo = dubbo; } public boolean isEnabled(String command) { if (StringUtils.hasText(command)) { - Boolean enabled = endpoint.get("dubbo" + command + ".enabled"); + Boolean enabled = dubbo.get(command + ".enabled"); return enabled != null && enabled; } else { return false; From 420130c9af2b82689069c73e89900c0801701ff9 Mon Sep 17 00:00:00 2001 From: JinQian <1184773579@qq.com> Date: Wed, 2 Oct 2024 02:03:13 +0800 Subject: [PATCH 9/9] fix:Set endpoint enablement to be opt-in rather than opt-out, modify README.md --- .../dubbo-spring-boot-actuator/README.md | 307 +++++------------- .../dubbo-endpoints-default.properties | 4 + 2 files changed, 89 insertions(+), 222 deletions(-) diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/README.md b/dubbo-spring-boot/dubbo-spring-boot-actuator/README.md index 989c2aef3fb..a753c9ef36b 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/README.md +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/README.md @@ -154,38 +154,39 @@ Actuator endpoint `dubbo` supports Actuator Endpoints : | `dubboreferences` | `false` | `/actuator/dubbo/references` | `GET` | Exposes all Dubbo's `ReferenceBean` | `application/json` | | `dubboconfigs` | `true` | `/actuator/dubbo/configs` | `GET` | Exposes all Dubbo's `*Config` | `application/json` | | `dubboshutdown` | `false` | `/actuator/dubbo/shutdown` | `GET` | Shutdown Dubbo services | `application/json` | -| `dubbohelp` | `true` | `/actuator/dubbo/help` | `GET` | List all commands | | -| `dubboready` | `true` | `/actuator/dubbo/ready` | `GET` | Check whether the current process/service is ready for external service | `application/json` | -| `dubbols` | `true` | `/actuator/dubbo/ls` | `GET` | List consumers and providers | `application/json` | -| `dubbostartup` | `true` | `/actuator/dubbo/startup` | `GET` | Check if the current framework has been started | `application/json` | -| `dubbops` | `true` | `/actuator/dubbo/ps` | `GET` | View information about the current process, including `listenable` ports | `application/json` | -| `dubboversion` | `true` | `/actuator/dubbo/version` | `GET` | Display the version number of the currently running `Dubbo` | `application/json` | -| `dubbogetaddress` | `true` | `/actuator/dubbo/getaddress?args=xxx.*` | `GET` | View the list of valid `IP` addresses for a service | `application/json` | -| `dubbogetconfig` | `true` | `/actuator/dubbo/getconfig` | `GET` | View the valid `configuration` of the current application | `application/json` | -| `dubbometrics` | `true` | `/actuator/dubbo/metrics` | `GET` | View `metrics`(Need to enable metrics statistics) | `application/json` | -| `dubbometrics_default` | `true` | `/actuator/dubbo/metrics_default` | `GET` | View the default `metrics`(Need to enable metrics statistics) | `application/json` | -| `dubbopublishmetadata` | `true` | `/actuator/dubbo/publishmetadata` or `/actuator/dubbo/publishmetadata?args=10` | `GET` | Publishes or updates the current application `Metadata` (Delay can be set) | `application/json` | -| `dubboonline` | `true` | `/actuator/dubbo/online` or `/actuator/dubbo/online?args=xxx.*` | `GET` | Register one or more services to the registry (including application and interface addresses) | `application/json` | -| `dubboonlineapp` | `true` | `/actuator/dubbo/onlineApp` or `/actuator/dubbo/onlineApp?args=xxx.xxx.*` | `GET` | Register one or more services to the registry (only application addresses) | `application/json` | -| `dubboonlineinterface` | `true` | `/actuator/dubbo/onlineInterface` or `/actuator/dubbo/onlineInterface?args=xxx.*` | `GET` | Register one or more services to the registry (only interface addresses) | `application/json` | -| `dubbooffline` | `true` | `/actuator/dubbo/offline` or `/actuator/dubbo/offline?args=xxx.*` | `GET` | Unregister one or more services from the registry (including application and interface addresses) | `application/json` | -| `dubboofflineapp` | `true` | `/actuator/dubbo/offlineApp` or `/actuator/dubbo/offlineApp?args=xxx.*` | `GET` | Unregister one or more services from the registry (only application addresses) | `application/json` | -| `dubboofflineinterface` | `true` | `/actuator/dubbo/offlineInterface` or `/actuator/dubbo/offlineInterface?args=xxx.*` | `GET` | Unregister one or more services from the registry (only interface addresses) | `application/json` | -| `dubbologgerinfo` | `true` | `/actuator/dubbo/loggerInfo` | `GET` | Query log configuration | `application/json` | -| `dubboswitchlogger` | `true` | `/actuator/dubbo/switchLogger?args={loggerAdapterName}` | `GET` | Modify the log output framework,`loggerAdapterName`: `slf4j`, `jcl`, `log4j`, `jdk`, `log4j2` | `application/json` | -| `dubboswitchloglevel` | `true` | `/actuator/dubbo/switchLogLevel?args={level}` | `GET` | Modify log level,level: `ALL`, `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `OFF` | `application/json` | -| `dubbodisabledetailprofiler` | `true` | `/actuator/dubbo/disableDetailProfiler` | `GET` | Turn off `detail profiler` mode, it will not affect `simple profiler` | `application/json` | -| `dubboenabledetailprofiler` | `true` | `/actuator/dubbo/enableDetailProfiler` | `GET` | Enable the `detail profiler` mode, which is disabled by default, you need to enable the `simple profiler` mode to actually enable it | `application/json` | -| `dubbodisablesimpleprofiler` | `false` | `/actuator/dubbo/disableSimpleProfiler` | `GET` | Turn off the `simple profiler` mode, and the `detail profiler` will not be enabled after it is turned off | `application/json` | -| `dubboenablesimpleprofiler` | `true` | `/actuator/dubbo/enableSimpleProfiler` | `GET` | Enable `simple profiler` mode, enabled by default | `application/json` | -| `dubbosetprofilerwarnpercent` | `true` | `/actuator/dubbo/setProfilerWarnPercent?args={percent}` | `GET` | Control `serialization` alarm frequency (only for classes in the warning list) | `application/json` | -| `dubboserializecheckstatus` | `true` | `/actuator/dubbo/dubboserializecheckstatus` | `GET` | View the current configuration information | `application/json` | -| `dubboserializewarnedclasses` | `true` | `/actuator/dubbo/dubboserializewarnedclasses` | `GET` | View the real-time alarm list | `application/json` | -| `dubbodisableroutersnapshot` | `true` | `/actuator/dubbo/disableRouterSnapshot` or `/actuator/dubbo/disableRouterSnapshot?args=xxx.*` | `GET` | Disable routing result collection mode | `application/json` | -| `dubboenableroutersnapshot` | `true` | `/actuator/dubbo/enableRouterSnapshot` or `/actuator/dubbo/enableRouterSnapshot?args=xxx.*` | `GET` | Enable routing result collection mode | `application/json` | -| `dubbogetrecentroutersnapshot` | `true` | `/actuator/dubbo/getRecentRouterSnapshot` | `GET` | Obtain the historical routing status (up to 32 results stored) | `application/json` | -| `dubbogetenabledroutersnapshot` | `true` | `/actuator/dubbo/getEnabledRouterSnapshot` | `GET` | Get the services that are currently collecting | `application/json` | -| `dubbogracefulshutdown` | `false` | `/actuator/dubbo/gracefulShutdown` | `GET` | Unregister all services registered by the current IP instance from the registry | `application/json` | +| `help` | `false` | `/actuator/dubbo/help` | `GET` | List all commands | | +| `ready` | `true` | `/actuator/dubbo/ready` | `GET` | Check whether the current process/service is ready for external service | `application/json` | +| `live` | `true` | `/actuator/dubbo/live` | `GET` | Check whether the current process/service is alive | `application/json` | +| `ls` | `false` | `/actuator/dubbo/ls` | `GET` | List consumers and providers | `application/json` | +| `startup` | `true` | `/actuator/dubbo/startup` | `GET` | Check if the current framework has been started | `application/json` | +| `ps` | `false` | `/actuator/dubbo/ps` | `GET` | View information about the current process, including `listenable` ports | `application/json` | +| `version` | `false` | `/actuator/dubbo/version` | `GET` | Display the version number of the currently running `Dubbo` | `application/json` | +| `getaddress` | `false` | `/actuator/dubbo/getaddress?args=xxx.*` | `GET` | View the list of valid `IP` addresses for a service | `application/json` | +| `getconfig` | `false` | `/actuator/dubbo/getconfig` | `GET` | View the valid `configuration` of the current application | `application/json` | +| `metrics` | `false` | `/actuator/dubbo/metrics` | `GET` | View `metrics`(Need to enable metrics statistics) | `application/json` | +| `metrics_default` | `false` | `/actuator/dubbo/metrics_default` | `GET` | View the default `metrics`(Need to enable metrics statistics) | `application/json` | +| `publishmetadata` | `false` | `/actuator/dubbo/publishmetadata` or `/actuator/dubbo/publishmetadata?args=10` | `GET` | Publishes or updates the current application `Metadata` (Delay can be set) | `application/json` | +| `online` | `false` | `/actuator/dubbo/online` or `/actuator/dubbo/online?args=xxx.*` | `GET` | Register one or more services to the registry (including application and interface addresses) | `application/json` | +| `onlineapp` | `false` | `/actuator/dubbo/onlineApp` or `/actuator/dubbo/onlineApp?args=xxx.xxx.*` | `GET` | Register one or more services to the registry (only application addresses) | `application/json` | +| `onlineinterface` | `false` | `/actuator/dubbo/onlineInterface` or `/actuator/dubbo/onlineInterface?args=xxx.*` | `GET` | Register one or more services to the registry (only interface addresses) | `application/json` | +| `offline` | `false` | `/actuator/dubbo/offline` or `/actuator/dubbo/offline?args=xxx.*` | `GET` | Unregister one or more services from the registry (including application and interface addresses) | `application/json` | +| `offlineapp` | `false` | `/actuator/dubbo/offlineApp` or `/actuator/dubbo/offlineApp?args=xxx.*` | `GET` | Unregister one or more services from the registry (only application addresses) | `application/json` | +| `offlineinterface` | `false` | `/actuator/dubbo/offlineInterface` or `/actuator/dubbo/offlineInterface?args=xxx.*` | `GET` | Unregister one or more services from the registry (only interface addresses) | `application/json` | +| `loggerinfo` | `false` | `/actuator/dubbo/loggerInfo` | `GET` | Query log configuration | `application/json` | +| `switchlogger` | `false` | `/actuator/dubbo/switchLogger?args={loggerAdapterName}` | `GET` | Modify the log output framework,`loggerAdapterName`: `slf4j`, `jcl`, `log4j`, `jdk`, `log4j2` | `application/json` | +| `switchloglevel` | `false` | `/actuator/dubbo/switchLogLevel?args={level}` | `GET` | Modify log level,level: `ALL`, `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `OFF` | `application/json` | +| `disabledetailprofiler` | `false` | `/actuator/dubbo/disableDetailProfiler` | `GET` | Turn off `detail profiler` mode, it will not affect `simple profiler` | `application/json` | +| `enabledetailprofiler` | `false` | `/actuator/dubbo/enableDetailProfiler` | `GET` | Enable the `detail profiler` mode, which is disabled by default, you need to enable the `simple profiler` mode to actually enable it | `application/json` | +| `disablesimpleprofiler` | `false` | `/actuator/dubbo/disableSimpleProfiler` | `GET` | Turn off the `simple profiler` mode, and the `detail profiler` will not be enabled after it is turned off | `application/json` | +| `enablesimpleprofiler` | `false` | `/actuator/dubbo/enableSimpleProfiler` | `GET` | Enable `simple profiler` mode, enabled by default | `application/json` | +| `setprofilerwarnpercent` | `false` | `/actuator/dubbo/setProfilerWarnPercent?args={percent}` | `GET` | Control `serialization` alarm frequency (only for classes in the warning list) | `application/json` | +| `serializecheckstatus` | `false` | `/actuator/dubbo/dubboserializecheckstatus` | `GET` | View the current configuration information | `application/json` | +| `serializewarnedclasses` | `false` | `/actuator/dubbo/dubboserializewarnedclasses` | `GET` | View the real-time alarm list | `application/json` | +| `disableroutersnapshot` | `false` | `/actuator/dubbo/disableRouterSnapshot` or `/actuator/dubbo/disableRouterSnapshot?args=xxx.*` | `GET` | Disable routing result collection mode | `application/json` | +| `enableroutersnapshot` | `false` | `/actuator/dubbo/enableRouterSnapshot` or `/actuator/dubbo/enableRouterSnapshot?args=xxx.*` | `GET` | Enable routing result collection mode | `application/json` | +| `getrecentroutersnapshot` | `false` | `/actuator/dubbo/getRecentRouterSnapshot` | `GET` | Obtain the historical routing status (up to 32 results stored) | `application/json` | +| `getenabledroutersnapshot` | `false` | `/actuator/dubbo/getEnabledRouterSnapshot` | `GET` | Get the services that are currently collecting | `application/json` | +| `gracefulshutdown` | `false` | `/actuator/dubbo/gracefulShutdown` | `GET` | Unregister all services registered by the current IP instance from the registry | `application/json` | @@ -461,52 +462,24 @@ The key is the simple name of Dubbo `*Config` Class , the value is`*Config` Bea -`/actuator/dubbo/online` - -```json -{ - "org.apache.dubbo.springboot.demo.DemoService:null": "online" -} -``` - - - -`/actuator/dubbo/offline` - -```json -{ - "org.apache.dubbo.springboot.demo.DemoService:null": "offline" -} -``` - - - -`/actuator/dubbo/ready` - -`/actuator/dubbo/ready` Detect whether the current framework can provide services normally (may be temporarily offline) : +`/actuator/dubbo/ls `List consumers and providers : -```json -{ - "dubbo-springboot-demo-provider": "true" -} ``` +As Provider side: ++-----------------------------------------------------------------------------------+-----------------------------+ +| Provider Service Name | PUB | ++-----------------------------------------------------------------------------------+-----------------------------+ +| DubboInternal - dubbo-springboot-demo-provider/org.apache.dubbo.metadata.MetadataService: 1.0.0 | | ++-----------------------------------------------------------------------------------+-----------------------------+ +|DubboInternal - dubbo-springboot-demo-provider/org.apache.dubbo.metrics.service.MetricsService: 1.0.0| | ++-----------------------------------------------------------------------------------+-----------------------------+ +| org.apache.dubbo.springboot.demo.DemoService |zookeeper-A(Y)/zookeeper-I(Y)| ++-----------------------------------------------------------------------------------+-----------------------------+ +As Consumer side: ++---------------------+---+ +|Consumer Service Name|NUM| ++---------------------+---+ - - -`/actuator/dubbo/ls` - -`/actuator/dubbo/ls `List consumers and providers : - -```json -{ - "Providers": { - "DubboInternal - dubbo-springboot-demo-provider/org.apache.dubbo.metadata.MetadataService:1.0.0": "", - "DubboInternal - dubbo-springboot-demo-provider/org.apache.dubbo.metadata.MetadataServiceV2:2.0.0": "", - "DubboInternal - dubbo-springboot-demo-provider/org.apache.dubbo.metrics.service.MetricsService:1.0.0": "", - "org.apache.dubbo.springboot.demo.DemoService": "zookeeper-A(Y)/zookeeper-I(Y)" - }, - "Consumers": {} -} ``` - Services prefixed with `DubboInternal` are built-in services of Dubbo, and are not registered with the registry by default. @@ -515,134 +488,28 @@ The key is the simple name of Dubbo `*Config` Class , the value is`*Config` Bea - The first part of `zookeeper-AF(I-2,A-2)` in the service subscription status is the corresponding registration center name, and the second part is the subscription mode (`AF` stands for dual subscription mode, `FA` stands for only Application-level subscription, `FI` stands for interface-level subscription only), the first half of the third part represents the source of the address mode (`A` stands for application-level address, `I` stands for interface-level address), and the second half represents the corresponding number of addresses - - -`/actuator/dubbo/loggerInfo` - -`/actuator/dubbo/loggerInfo` show available logging framework, the logging framework and log level : - -```json -{ - "Available logger adapters": [ - "log4j2", - "slf4j", - "jcl", - "jdk" - ], - "Current Adapter": "slf4j", - "Log level": "INFO" -} -``` - -`/actuator/dubbo/switchLogger?logger={loggerAdapterName}` -`/actuator/dubbo/switchLogger?logger={loggerAdapterName}` allows switching between available logger adapters, and the parameter cannot be empty : - -```json -{ - "Current Adapter": "log4j2" -} -``` - - - -`/actuator/dubbo/switchLogLevel?level={level}` - -`/actuator/dubbo/loggerInfo` allows switching between permitted log levels, and the parameter cannot be empty : - -```json -{ - "Current Log Level": "WARN" -} -``` +`/actuator/dubbo/switchLogLevel?args={level}` allows switching between permitted log levels, and the parameter cannot be empty, `/actuator/dubbo/switchLogLevel?args=WARN`. The log configuration modified by `switchLogger`/`switchLogLevel` is not stored persistently and will become invalid after the application is restarted. -`/actuator/dubbo/disableSimpleProfiler` - -`/actuator/dubbo/disableSimpleProfiler` turn off the `simple profiler` mode, and the `detail profiler` will not be enabled after it is turned off : - -```json -{ - "WARN": "Dubbo Invocation Profiler has been disabled" -} -``` +`/actuator/dubbo/disableSimpleProfiler` turn off the `simple profiler` mode, and the `detail profiler` will not be enabled after it is turned off. The performance sampling function can detect the time consumption of various parts of the Dubbo processing link,where `simple profiler` mode is enabled by default. -`/actuator/dubbo/enableDetailProfiler` - -`/actuator/dubbo/enableDetailProfiler` enable the `detail profiler` mode, which is disabled by default, you need to enable the `simple profiler` mode to actually enable it : - -```json -{ - "WARN": "Dubbo Invocation Profiler has been enabled, This will cause performance degradation" -} -``` +`/actuator/dubbo/enableDetailProfiler` enable the `detail profiler` mode, which is disabled by default, you need to enable the `simple profiler` mode to actually enable it. Compared with the `simple profiler` mode, the `detail profiler` collects more time-consuming processing of each filter, specific time-consuming protocols, etc. In the `simple profiler` mode, if you find that there is a long time-consuming situation inside the Dubbo framework, you can enable the `detail profiler` mode to better troubleshoot the problem. -`/actuator/dubbo/setProfilerPercent?p={precent}` - -`/actuator/dubbo/setProfilerPercent?p={precent}` Control serialization alarm frequency (only for classes in the warning list) : -```json -{ - "Current Dubbo Invocation Profiler warn percent": 0.4 -} -``` - - - -`/actuator/dubbo/disableRouterSnapshot{?service={servicePatern}}` -`/actuator/dubbo/disableRouterSnapshot?service={servicePatern}` disable routing result collection mode, `servicePatern` is the name of the service to be collected, which supports matching : -```json -{ - "org.apache.dubbo.springboot.demo.DemoService": "Router snapshot disabled" -} -``` - - - -`/actuator/dubbo/enableRouterSnapshot` - -`/actuator/dubbo/enableRouterSnapshot?service={servicePatern}` enable routing result collection mode, `servicePatern` is the name of the service to be collected, which supports matching : - -```json -{ - "WARN": "Enable router snapshot will cause performance degradation, please be careful!", - "org.apache.dubbo.springboot.demo.DemoService": "Router snapshot enabled" -} -``` - - - -`/actuator/dubbo/getEnabledRouterSnapshot` - -`/actuator/dubbo/getEnabledRouterSnapshot` get the services that are currently collecting - -```json -{ - "Enabled router snapshot": [ - "org.apache.dubbo.springboot.demo.DemoService" - ] -} -``` - -`/actuator/dubbo/gracefulShutdown` unregister all services registered by the current IP instance from the registry. The difference from 'offline' is that this command will also notify all consumers via TCP connection to stop calling this instance : -```json -{ - "org.apache.dubbo.springboot.demo.DemoService:null": "offline" -} -``` -To restore, please execute 'online' to bring all services back online. +`/actuator/dubbo/gracefulShutdown` unregister all services registered by the current IP instance from the registry. The difference from 'offline' is that this command will also notify all consumers via TCP connection to stop calling this instance. To restore, please execute 'online' to bring all services back online. @@ -712,42 +579,38 @@ management.endpoint.dubboconfigs.enabled = true management.endpoint.dubboservices.enabled = true management.endpoint.dubboreferences.enabled = true management.endpoint.dubboproperties.enabled = true -management.endpoint.dubbohelp.enabled = true -management.endpoint.dubbocd.enabled = true -management.endpoint.dubbocount.enabled = true -management.endpoint.dubbopwd.enabled = true -management.endpoint.dubboinvoke.enabled = true -management.endpoint.dubboselect.enabled = true -management.endpoint.dubboready.enabled = true -management.endpoint.dubbols.enabled = true -management.endpoint.dubbostartup.enabled = true -management.endpoint.dubbops.enabled = true -management.endpoint.dubboversion.enabled = true -management.endpoint.dubbogetaddress.enabled = true -management.endpoint.dubbogetconfig.enabled = true -management.endpoint.dubbometrics.enabled = true -management.endpoint.dubbometrics_default.enabled = true -management.endpoint.dubbopublishMetadata.enabled = true -management.endpoint.dubboonline.enabled = true -management.endpoint.dubboonlineapp.enabled = true -management.endpoint.dubboonlineinterface.enabled = true -management.endpoint.dubbooffline.enabled = true -management.endpoint.dubboofflineapp.enabled = true -management.endpoint.dubboofflineinterface.enabled = true -management.endpoint.dubbologgerinfo.enabled = true -management.endpoint.dubboswitchlogger.enabled = true -management.endpoint.dubboswitchloglevel.enabled = true -management.endpoint.dubbodisabledetailprofiler.enabled = true -management.endpoint.dubbodisablesimpleprofiler.enabled = true -management.endpoint.dubboenabledetailprofiler.enabled = true -management.endpoint.dubboenablesimpleprofiler.enabled = true -management.endpoint.dubbosetprofilerwarnpercent.enabled = true -management.endpoint.dubboserializecheckstatus.enabled = true -management.endpoint.dubboserializewarnedclasses.enabled = true -management.endpoint.dubbodisableroutersnapshot.enabled = true -management.endpoint.dubboenableroutersnapshot.enabled = true -management.endpoint.dubbogetrecentroutersnapshot.enabled = true -management.endpoint.dubbogetenabledroutersnapshot.enabled = true -management.endpoint.dubbogracefulshutdown.enabled = true +management.endpoint.dubbo.help.enabled = true +management.endpoint.dubbo.ready.enabled = true +management.endpoint.dubbo.ls.enabled = true +management.endpoint.dubbo.live.enabled = true +management.endpoint.dubbo.startup.enabled = true +management.endpoint.dubbo.ps.enabled = true +management.endpoint.dubbo.version.enabled = true +management.endpoint.dubbo.getaddress.enabled = true +management.endpoint.dubbo.getconfig.enabled = true +management.endpoint.dubbo.metrics.enabled = true +management.endpoint.dubbo.metrics_default.enabled = true +management.endpoint.dubbo.publishmetadata.enabled = true +management.endpoint.dubbo.online.enabled = true +management.endpoint.dubbo.onlineapp.enabled = true +management.endpoint.dubbo.onlineinterface.enabled = true +management.endpoint.dubbo.offline.enabled = true +management.endpoint.dubbo.offlineapp.enabled = true +management.endpoint.dubbo.offlineinterface.enabled = true +management.endpoint.dubbo.loggerinfo.enabled = true +management.endpoint.dubbo.switchlogger.enabled = true +management.endpoint.dubbo.switchloglevel.enabled = true +management.endpoint.dubbo.disabledetailprofiler.enabled = true +management.endpoint.dubbo.disablesimpleprofiler.enabled = true +management.endpoint.dubbo.enabledetailprofiler.enabled = true +management.endpoint.dubbo.enablesimpleprofiler.enabled = true +management.endpoint.dubbo.setprofilerwarnpercent.enabled = true +management.endpoint.dubbo.serializecheckstatus.enabled = true +management.endpoint.dubbo.serializewarnedclasses.enabled = true +management.endpoint.dubbo.disableroutersnapshot.enabled = true +management.endpoint.dubbo.enableroutersnapshot.enabled = true +management.endpoint.dubbo.getrecentroutersnapshot.enabled = true +management.endpoint.dubbo.getenabledroutersnapshot.enabled = true +management.endpoint.dubbo.gracefulshutdown.enabled = true ``` diff --git a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties index a42bba69a5a..36078408ea9 100644 --- a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties +++ b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoints-default.properties @@ -9,6 +9,10 @@ management.endpoints.web.path-mapping.dubboconfigs = dubbo/configs management.endpoints.web.path-mapping.dubboservices = dubbo/services management.endpoints.web.path-mapping.dubboreferences = dubbo/references management.endpoints.web.path-mapping.dubboproperties = dubbo/properties + +# Set endpoint enablement to be opt-in rather than opt-out +management.endpoints.enabled-by-default = false + # Set enabled for Dubbo Endpoints management.endpoint.dubbo.enabled = true management.endpoint.dubbo.ready.enabled = true