mirror of https://github.com/apache/druid.git
Composite request logger doesn't invoke @LifeCycleStart and @LifeCycleStop methods on its dependencies (#6173)
This commit is contained in:
parent
0c3bb47558
commit
1c8032f9f3
|
@ -23,6 +23,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.druid.java.util.common.lifecycle.LifecycleStart;
|
||||
import io.druid.java.util.common.lifecycle.LifecycleStop;
|
||||
import io.druid.java.util.common.logger.Logger;
|
||||
import io.druid.server.RequestLogLine;
|
||||
|
||||
|
@ -63,6 +65,24 @@ public class ComposingRequestLoggerProvider implements RequestLoggerProvider
|
|||
this.loggers = loggers;
|
||||
}
|
||||
|
||||
@LifecycleStart
|
||||
@Override
|
||||
public void start() throws Exception
|
||||
{
|
||||
for (RequestLogger logger : loggers) {
|
||||
logger.start();
|
||||
}
|
||||
}
|
||||
|
||||
@LifecycleStop
|
||||
@Override
|
||||
public void stop()
|
||||
{
|
||||
for (RequestLogger logger : loggers) {
|
||||
logger.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(RequestLogLine requestLogLine) throws IOException
|
||||
{
|
||||
|
|
|
@ -63,7 +63,8 @@ public class FileRequestLogger implements RequestLogger
|
|||
}
|
||||
|
||||
@LifecycleStart
|
||||
public void start()
|
||||
@Override
|
||||
public void start() throws Exception
|
||||
{
|
||||
try {
|
||||
baseDir.mkdirs();
|
||||
|
@ -117,6 +118,7 @@ public class FileRequestLogger implements RequestLogger
|
|||
}
|
||||
|
||||
@LifecycleStop
|
||||
@Override
|
||||
public void stop()
|
||||
{
|
||||
synchronized (lock) {
|
||||
|
|
|
@ -28,4 +28,8 @@ import java.io.IOException;
|
|||
public interface RequestLogger
|
||||
{
|
||||
void log(RequestLogLine requestLogLine) throws IOException;
|
||||
|
||||
default void start() throws Exception {}
|
||||
|
||||
default void stop() {}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.junit.Test;
|
|||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.concurrent.Executors;
|
||||
|
@ -45,7 +44,7 @@ public class FileRequestLoggerTest
|
|||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
@Test public void testLog() throws IOException
|
||||
@Test public void testLog() throws Exception
|
||||
{
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
DateTime dateTime = DateTimes.nowUtc();
|
||||
|
|
Loading…
Reference in New Issue