diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2021-01-21 15:49:05 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2021-01-21 16:54:09 +0100 |
commit | 6cc469b7950f4f6f2b67596b162cd73e59c22336 (patch) | |
tree | b19e9a8bf8c1bda395da8862494c3edafabf9b4e /container-core | |
parent | be7847731521fb516269b65905029c1639d4aec8 (diff) |
Deprecate LoggingRequestHandler constructors taking AccessLog
Add replacement constructors without AccessLog.
Remove use of deprecated constructors for internal handlers.
Diffstat (limited to 'container-core')
6 files changed, 51 insertions, 55 deletions
diff --git a/container-core/abi-spec.json b/container-core/abi-spec.json index 06366250c09..4077a0742dc 100644 --- a/container-core/abi-spec.json +++ b/container-core/abi-spec.json @@ -515,13 +515,15 @@ "abstract" ], "methods": [ - "public void <init>(java.util.concurrent.Executor, com.yahoo.container.logging.AccessLog)", - "public void <init>(java.util.concurrent.Executor)", "public static com.yahoo.container.jdisc.LoggingRequestHandler$Context testOnlyContext()", "public void <init>(com.yahoo.container.jdisc.LoggingRequestHandler$Context)", + "public void <init>(java.util.concurrent.Executor, com.yahoo.container.logging.AccessLog)", + "public void <init>(java.util.concurrent.Executor)", "public void <init>(com.yahoo.container.jdisc.LoggingRequestHandler$Context, boolean)", + "public void <init>(java.util.concurrent.Executor, com.yahoo.jdisc.Metric)", "public void <init>(java.util.concurrent.Executor, com.yahoo.container.logging.AccessLog, com.yahoo.jdisc.Metric)", "public void <init>(java.util.concurrent.Executor, com.yahoo.container.logging.AccessLog, com.yahoo.jdisc.Metric, boolean)", + "public void <init>(java.util.concurrent.Executor, com.yahoo.jdisc.Metric, boolean)", "protected com.yahoo.container.jdisc.LoggingCompletionHandler createLoggingCompletionHandler(long, long, com.yahoo.container.jdisc.HttpResponse, com.yahoo.container.jdisc.HttpRequest, com.yahoo.container.jdisc.ContentChannelOutputStream)" ], "fields": [] diff --git a/container-core/src/main/java/com/yahoo/container/handler/test/MockService.java b/container-core/src/main/java/com/yahoo/container/handler/test/MockService.java index 0228bc06c51..625212bcfe9 100644 --- a/container-core/src/main/java/com/yahoo/container/handler/test/MockService.java +++ b/container-core/src/main/java/com/yahoo/container/handler/test/MockService.java @@ -5,7 +5,6 @@ import com.google.common.annotations.Beta; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.LoggingRequestHandler; -import com.yahoo.container.logging.AccessLog; import com.yahoo.filedistribution.fileacquirer.FileAcquirer; import com.yahoo.jdisc.Metric; @@ -19,7 +18,6 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; -import java.util.logging.Logger; /** * This is a generic http handler that can be used to mock a service when testing your application on jDISC. @@ -50,14 +48,13 @@ public class MockService extends LoggingRequestHandler { * A custom handler can be created by subclassing and overriding the createHandler method. * * @param executor used to create threads - * @param accessLog where requests will be logged * @param fileAcquirer used to fetch file from config * @param config the mock config for this service * @throws InterruptedException if unable to get data file within timeout * @throws IOException if unable to create handler due to some IO errors */ - public MockService(Executor executor, AccessLog accessLog, FileAcquirer fileAcquirer, MockserviceConfig config, Metric metric) throws InterruptedException, IOException { - super(executor, accessLog, metric); + public MockService(Executor executor, FileAcquirer fileAcquirer, MockserviceConfig config, Metric metric) throws InterruptedException, IOException { + super(executor, metric); File dataFile = fileAcquirer.waitFor(config.file(), config.fileAcquirerTimeout(), TimeUnit.SECONDS); this.handler = createHandler(dataFile); } diff --git a/container-core/src/main/java/com/yahoo/container/jdisc/LoggingRequestHandler.java b/container-core/src/main/java/com/yahoo/container/jdisc/LoggingRequestHandler.java index 9bb9819cd1f..0d20fc05586 100644 --- a/container-core/src/main/java/com/yahoo/container/jdisc/LoggingRequestHandler.java +++ b/container-core/src/main/java/com/yahoo/container/jdisc/LoggingRequestHandler.java @@ -26,43 +26,33 @@ import java.util.logging.Level; * * @author Steinar Knutsen */ -// TODO Vespa 8: Deprecate all constructors taking AccessLog as parameter +// TODO Vespa 8: Remove deprecated constructors public abstract class LoggingRequestHandler extends ThreadedHttpRequestHandler { - public LoggingRequestHandler(Executor executor, AccessLog ignored) { - this(executor, ignored, null); - } - - public LoggingRequestHandler(Executor executor) { - this(executor, null, null); - } - public static class Context { final Executor executor; - final AccessLog ignored; final Metric metric; - @Inject + /** @deprecated Use {@link #Context(Executor, Metric)} instead */ + @Deprecated(forRemoval = true, since = "7") public Context(Executor executor, AccessLog ignored, Metric metric) { - this.executor = executor; - this.ignored = ignored; - this.metric = metric; + this(executor, metric); } - + @Inject public Context(Executor executor, Metric metric) { - this(executor, null, metric); + this.executor = executor; + this.metric = metric; } public Context(Context other) { this.executor = other.executor; - this.ignored = other.ignored; this.metric = other.metric; } public Executor getExecutor() { return executor; } - public AccessLog getAccessLog() { return ignored; } + @Deprecated(forRemoval = true, since = "7") public AccessLog getAccessLog() { return null; } public Metric getMetric() { return metric; } } @@ -74,24 +64,45 @@ public abstract class LoggingRequestHandler extends ThreadedHttpRequestHandler { command.run(); } }, - AccessLog.voidAccessLog(), null); } @Inject public LoggingRequestHandler(Context ctx) { - this(ctx.executor, ctx.ignored, ctx.metric); + this(ctx.executor, ctx.metric); + } + + /** @deprecated Use {@link #LoggingRequestHandler(Executor)} instead */ + @Deprecated(forRemoval = true, since = "7") + public LoggingRequestHandler(Executor executor, AccessLog ignored) { + this(executor, (Metric)null); + } + + public LoggingRequestHandler(Executor executor) { + this(executor, (Metric)null); } public LoggingRequestHandler(Context ctx, boolean allowAsyncResponse) { - this(ctx.executor, ctx.ignored, ctx.metric, allowAsyncResponse); + this(ctx.executor, ctx.metric, allowAsyncResponse); + } + + public LoggingRequestHandler(Executor executor, Metric metric) { + this(executor, metric, false); } + /** @deprecated Use {@link #LoggingRequestHandler(Executor, Metric)} instead */ + @Deprecated(forRemoval = true, since = "7") public LoggingRequestHandler(Executor executor, AccessLog ignored, Metric metric) { - this(executor, ignored, metric, false); + this(executor, metric, false); } + /** @deprecated Use {@link #LoggingRequestHandler(Executor, Metric, boolean)} instead */ + @Deprecated(forRemoval = true, since = "7") public LoggingRequestHandler(Executor executor, AccessLog ignored, Metric metric, boolean allowAsyncResponse) { + this(executor, metric, allowAsyncResponse); + } + + public LoggingRequestHandler(Executor executor, Metric metric, boolean allowAsyncResponse) { super(executor, metric, allowAsyncResponse); } diff --git a/container-core/src/main/java/com/yahoo/processing/handler/AbstractProcessingHandler.java b/container-core/src/main/java/com/yahoo/processing/handler/AbstractProcessingHandler.java index 6ab71c9a9dc..a4b2db74300 100644 --- a/container-core/src/main/java/com/yahoo/processing/handler/AbstractProcessingHandler.java +++ b/container-core/src/main/java/com/yahoo/processing/handler/AbstractProcessingHandler.java @@ -13,7 +13,6 @@ import com.yahoo.container.jdisc.ContentChannelOutputStream; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.LoggingRequestHandler; -import com.yahoo.container.jdisc.VespaHeaders; import com.yahoo.container.logging.AccessLog; import com.yahoo.jdisc.Metric; import com.yahoo.jdisc.handler.ContentChannel; @@ -29,15 +28,8 @@ import com.yahoo.processing.rendering.Renderer; import com.yahoo.processing.request.CompoundName; import com.yahoo.processing.request.ErrorMessage; import com.yahoo.processing.request.Properties; -import com.yahoo.processing.response.Data; -import com.yahoo.processing.response.DataList; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; import java.util.Map; -import java.util.Set; import java.util.concurrent.Executor; import static com.yahoo.component.chain.ChainsConfigurer.prepareChainRegistry; @@ -68,9 +60,9 @@ public abstract class AbstractProcessingHandler<COMPONENT extends Processor> ext public AbstractProcessingHandler(ChainRegistry<COMPONENT> chainRegistry, ComponentRegistry<Renderer> renderers, Executor executor, - AccessLog accessLog, + AccessLog ignored, Metric metric) { - super(executor, accessLog, metric, true); + super(executor, metric, true); renderingExecutor = executor; this.chainRegistry = chainRegistry; this.renderers = renderers; @@ -87,16 +79,16 @@ public abstract class AbstractProcessingHandler<COMPONENT extends Processor> ext public AbstractProcessingHandler(ChainRegistry<COMPONENT> chainRegistry, ComponentRegistry<Renderer> renderers, Executor executor, - AccessLog accessLog) { - this(chainRegistry, renderers, executor, accessLog, null); + AccessLog ignored) { + this(chainRegistry, renderers, executor, ignored, null); } public AbstractProcessingHandler(ChainsConfig processingChainsConfig, ComponentRegistry <COMPONENT> chainedComponents, ComponentRegistry<Renderer> renderers, Executor executor, - AccessLog accessLog) { - this(processingChainsConfig, chainedComponents, renderers, executor, accessLog, null); + AccessLog ignored) { + this(processingChainsConfig, chainedComponents, renderers, executor, ignored, null); } @Inject @@ -104,9 +96,9 @@ public abstract class AbstractProcessingHandler<COMPONENT extends Processor> ext ComponentRegistry<COMPONENT> chainedComponents, ComponentRegistry<Renderer> renderers, Executor executor, - AccessLog accessLog, + AccessLog ignored, Metric metric) { - this(createChainRegistry(processingChainsConfig, chainedComponents), renderers, executor, accessLog, metric); + this(createChainRegistry(processingChainsConfig, chainedComponents), renderers, executor, ignored, metric); } /** Throws UnsupportedOperationException: Call handle(request, channel instead) */ diff --git a/container-core/src/test/java/com/yahoo/container/handler/test/MockServiceTest.java b/container-core/src/test/java/com/yahoo/container/handler/test/MockServiceTest.java index f1a9fdcd0a3..cd5a3ce860a 100644 --- a/container-core/src/test/java/com/yahoo/container/handler/test/MockServiceTest.java +++ b/container-core/src/test/java/com/yahoo/container/handler/test/MockServiceTest.java @@ -3,7 +3,6 @@ package com.yahoo.container.handler.test; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.container.logging.AccessLog; import com.yahoo.filedistribution.fileacquirer.MockFileAcquirer; import org.junit.Test; @@ -75,7 +74,7 @@ public class MockServiceTest { private HttpResponse runHandlerWithFile(com.yahoo.jdisc.http.HttpRequest.Method method, String path, File file) throws InterruptedException, IOException { MockserviceConfig.Builder builder = new MockserviceConfig.Builder(); builder.file(file.getPath()); - MockService handler = new MockService(new MockExecutor(), AccessLog.voidAccessLog(), MockFileAcquirer.returnFile(file), new MockserviceConfig(builder), null); + MockService handler = new MockService(new MockExecutor(), MockFileAcquirer.returnFile(file), new MockserviceConfig(builder), null); return handler.handle(HttpRequest.createTestRequest(path, method)); } diff --git a/container-core/src/test/java/com/yahoo/container/jdisc/LoggingRequestHandlerTestCase.java b/container-core/src/test/java/com/yahoo/container/jdisc/LoggingRequestHandlerTestCase.java index 734b3fa11af..34144ee8a59 100644 --- a/container-core/src/test/java/com/yahoo/container/jdisc/LoggingRequestHandlerTestCase.java +++ b/container-core/src/test/java/com/yahoo/container/jdisc/LoggingRequestHandlerTestCase.java @@ -2,12 +2,9 @@ package com.yahoo.container.jdisc; import com.google.inject.Key; -import com.yahoo.component.provider.ComponentRegistry; import com.yahoo.container.handler.Coverage; import com.yahoo.container.handler.Timing; -import com.yahoo.container.logging.AccessLog; import com.yahoo.container.logging.HitCounts; -import com.yahoo.container.logging.RequestLogHandler; import com.yahoo.jdisc.Container; import com.yahoo.jdisc.References; import com.yahoo.jdisc.ResourceReference; @@ -102,8 +99,8 @@ public class LoggingRequestHandlerTestCase { static final class AccessLogTestHandler extends LoggingRequestHandler { - public AccessLogTestHandler(Executor executor, AccessLog accessLog) { - super(executor, accessLog); + public AccessLogTestHandler(Executor executor) { + super(executor); } @Override @@ -115,10 +112,8 @@ public class LoggingRequestHandlerTestCase { @Before public void setUp() throws Exception { - ComponentRegistry<RequestLogHandler> implementers = new ComponentRegistry<>(); - implementers.freeze(); executor = Executors.newCachedThreadPool(); - handler = new AccessLogTestHandler(executor, new AccessLog(implementers)); + handler = new AccessLogTestHandler(executor); } @After |