Search in sources :

Example 6 with LogConfig

use of org.apache.storm.generated.LogConfig in project storm by apache.

the class LogConfigManagerTest method testProcessRootLogLevelToDebugSetsLoggerAndTimeout2.

@Test
public void testProcessRootLogLevelToDebugSetsLoggerAndTimeout2() {
    try (SimulatedTime t = new SimulatedTime()) {
        LogConfig mockConfig = new LogConfig();
        AtomicReference<TreeMap<String, LogLevel>> mockConfigAtom = new AtomicReference<>(null);
        long inThirtySeconds = Time.currentTimeMillis() + 30_000;
        mockConfig.put_to_named_logger_level("ROOT", ll("DEBUG", inThirtySeconds));
        LogConfigManager underTest = spy(new LogConfigManagerUnderTest(mockConfigAtom));
        underTest.processLogConfigChange(mockConfig);
        // test that the set-logger-level function was not called
        LOG.info("Tests {}", mockConfigAtom.get());
        verify(underTest).setLoggerLevel(anyObject(), eq(""), eq("DEBUG"));
        LogLevel rootResult = mockConfigAtom.get().get(LogManager.ROOT_LOGGER_NAME);
        assertNotNull(rootResult);
        assertEquals(LogLevelAction.UPDATE, rootResult.get_action());
        assertEquals("DEBUG", rootResult.get_target_log_level());
        // defaults to INFO level when the logger isn't found previously
        assertEquals("INFO", rootResult.get_reset_log_level());
        assertEquals(inThirtySeconds, rootResult.get_reset_log_level_timeout_epoch());
    }
}
Also used : SimulatedTime(org.apache.storm.utils.Time.SimulatedTime) AtomicReference(java.util.concurrent.atomic.AtomicReference) TreeMap(java.util.TreeMap) LogLevel(org.apache.storm.generated.LogLevel) LogConfig(org.apache.storm.generated.LogConfig) Test(org.junit.Test)

Aggregations

LogConfig (org.apache.storm.generated.LogConfig)6 LogLevel (org.apache.storm.generated.LogLevel)3 IOException (java.io.IOException)2 InterruptedIOException (java.io.InterruptedIOException)2 BindException (java.net.BindException)2 TreeMap (java.util.TreeMap)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 IStormClusterState (org.apache.storm.cluster.IStormClusterState)2 AlreadyAliveException (org.apache.storm.generated.AlreadyAliveException)2 AuthorizationException (org.apache.storm.generated.AuthorizationException)2 InvalidTopologyException (org.apache.storm.generated.InvalidTopologyException)2 KeyAlreadyExistsException (org.apache.storm.generated.KeyAlreadyExistsException)2 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)2 NotAliveException (org.apache.storm.generated.NotAliveException)2 SimulatedTime (org.apache.storm.utils.Time.SimulatedTime)2 TException (org.apache.thrift.TException)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 LogLevelAction (org.apache.storm.generated.LogLevelAction)1