eolivelli commented on a change in pull request #14200:
URL: https://github.com/apache/pulsar/pull/14200#discussion_r806735706
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -437,5 +440,79 @@ private void doShutDownBrokerGracefully(int
maxConcurrentUnloadPerSec,
pulsar().getBrokerService().unloadNamespaceBundlesGracefully(maxConcurrentUnloadPerSec,
forcedTerminateTopic);
pulsar().closeAsync();
}
+
+ /**
+ * dynamically update log4j2 logger level at runtime.
+ *
+ * @param targetClassName : class name to update
+ * @param targetLevel : target log level
+ */
+ private CompletableFuture<Void> internalUpdateLoggerLevelAsync(String
targetClassName, String targetLevel) {
+ CompletableFuture<Void> loggerLevelFuture = new CompletableFuture<>();
+ CompletableFuture.runAsync(() -> {
+ try {
+ String className;
+ // if set "ROOT" will take effect to rootLogger
+ if (targetClassName.trim().equalsIgnoreCase("ROOT")) {
+ className = LogManager.ROOT_LOGGER_NAME;
+ } else {
+ try {
+ className = targetClassName.trim();
+ // Check if class name valid
+ Class.forName(className);
Review comment:
Here you aree triggering the load of a class from a APi call.
This may be seen as a security issue.
There is no need to do this.
Please remove
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -437,5 +440,79 @@ private void doShutDownBrokerGracefully(int
maxConcurrentUnloadPerSec,
pulsar().getBrokerService().unloadNamespaceBundlesGracefully(maxConcurrentUnloadPerSec,
forcedTerminateTopic);
pulsar().closeAsync();
}
+
+ /**
+ * dynamically update log4j2 logger level at runtime.
+ *
+ * @param targetClassName : class name to update
+ * @param targetLevel : target log level
+ */
+ private CompletableFuture<Void> internalUpdateLoggerLevelAsync(String
targetClassName, String targetLevel) {
+ CompletableFuture<Void> loggerLevelFuture = new CompletableFuture<>();
+ CompletableFuture.runAsync(() -> {
Review comment:
Why are we executing this a a unknown thread?
We can execute this code in the main thread of the http handler
##########
File path:
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdBrokers.java
##########
@@ -176,6 +176,20 @@ void run() throws Exception {
}
}
+ @Parameters(commandDescription = "Update dynamic log4j2 logger level in
runtime by classname.")
+ private class UpdateLoggerLevelCmd extends CliCommand {
Review comment:
Please note that there is no control about the broker who is serving the
request.
Can we report this to the user?
- report the id of the broker that process the request
- write a generic warning
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]