You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by et...@apache.org on 2020/01/03 06:19:38 UTC
[storm] branch 2.1.x-branch updated: STORM-3552 Fix update log
level from command line
This is an automated email from the ASF dual-hosted git repository.
ethanli pushed a commit to branch 2.1.x-branch
in repository https://gitbox.apache.org/repos/asf/storm.git
The following commit(s) were added to refs/heads/2.1.x-branch by this push:
new cf51921 STORM-3552 Fix update log level from command line
new 36fa80c Merge pull request #3182 from marjoral/STORM-3552-2.1.X
cf51921 is described below
commit cf51921ae61c71eb48dc19165f384fb9429bfa7d
Author: MARJORAM Luke <lm...@murex.com>
AuthorDate: Tue Dec 10 12:00:40 2019 +0000
STORM-3552 Fix update log level from command line
---
.../storm/daemon/worker/LogConfigManagerTest.java | 27 ++++++++++++++++++++++
.../jvm/org/apache/storm/command/SetLogLevel.java | 2 +-
.../org/apache/storm/command/SetLogLevelTest.java | 4 ++--
3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/storm-client/test/jvm/org/apache/storm/daemon/worker/LogConfigManagerTest.java b/storm-client/test/jvm/org/apache/storm/daemon/worker/LogConfigManagerTest.java
index bf8ded8..3731231 100644
--- a/storm-client/test/jvm/org/apache/storm/daemon/worker/LogConfigManagerTest.java
+++ b/storm-client/test/jvm/org/apache/storm/daemon/worker/LogConfigManagerTest.java
@@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.anyObject;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.eq;
@@ -203,6 +204,32 @@ public class LogConfigManagerTest {
}
@Test
+ public void testProcessLogConfigChangeThrowsNullPointerExceptionWhenTargetLogLevelIsNotSet() {
+ LogConfigManager logConfigManager = new LogConfigManager();
+
+ LogConfig logConfig = new LogConfig();
+ LogLevel logLevel = new LogLevel();
+ logLevel.set_action(LogLevelAction.UPDATE);
+ logLevel.set_reset_log_level("INFO");
+ logConfig.put_to_named_logger_level("RESET_LOG", logLevel);
+
+ assertThrows(NullPointerException.class, () -> logConfigManager.processLogConfigChange(logConfig));
+ }
+
+ @Test
+ public void testProcessLogConfigChangeExecutesSuccessfullyWhenTargetLogLevelIsSet() {
+ LogConfigManager logConfigManager = new LogConfigManager();
+
+ LogConfig logConfig = new LogConfig();
+ LogLevel logLevel = new LogLevel();
+ logLevel.set_action(LogLevelAction.UPDATE);
+ logLevel.set_target_log_level("DEBUG");
+ logConfig.put_to_named_logger_level("TARGET_LOG", logLevel);
+
+ logConfigManager.processLogConfigChange(logConfig);
+ }
+
+ @Test
public void testProcessRootLogLevelToDebugSetsLoggerAndTimeout() {
try (SimulatedTime t = new SimulatedTime()) {
LogConfig mockConfig = new LogConfig();
diff --git a/storm-core/src/jvm/org/apache/storm/command/SetLogLevel.java b/storm-core/src/jvm/org/apache/storm/command/SetLogLevel.java
index 7e9815a..c370b48 100644
--- a/storm-core/src/jvm/org/apache/storm/command/SetLogLevel.java
+++ b/storm-core/src/jvm/org/apache/storm/command/SetLogLevel.java
@@ -92,7 +92,7 @@ public class SetLogLevel {
splits = splits[1].split(":");
Integer timeout = 0;
Level level = Level.valueOf(splits[0]);
- logLevel.set_reset_log_level(level.toString());
+ logLevel.set_target_log_level(level.toString());
if (splits.length > 1) {
timeout = Integer.parseInt(splits[1]);
}
diff --git a/storm-core/test/jvm/org/apache/storm/command/SetLogLevelTest.java b/storm-core/test/jvm/org/apache/storm/command/SetLogLevelTest.java
index 5951752..af6aefc 100644
--- a/storm-core/test/jvm/org/apache/storm/command/SetLogLevelTest.java
+++ b/storm-core/test/jvm/org/apache/storm/command/SetLogLevelTest.java
@@ -25,11 +25,11 @@ public class SetLogLevelTest {
SetLogLevel.LogLevelsParser logLevelsParser = new SetLogLevel.LogLevelsParser(LogLevelAction.UPDATE);
LogLevel logLevel = ((Map<String, LogLevel>) logLevelsParser.parse("com.foo.one=warn")).get("com.foo.one");
Assert.assertEquals(0, logLevel.get_reset_log_level_timeout_secs());
- Assert.assertEquals("WARN", logLevel.get_reset_log_level());
+ Assert.assertEquals("WARN", logLevel.get_target_log_level());
logLevel = ((Map<String, LogLevel>) logLevelsParser.parse("com.foo.two=DEBUG:10")).get("com.foo.two");
Assert.assertEquals(10, logLevel.get_reset_log_level_timeout_secs());
- Assert.assertEquals("DEBUG", logLevel.get_reset_log_level());
+ Assert.assertEquals("DEBUG", logLevel.get_target_log_level());
}
@Test(expected = NumberFormatException.class)