diff options
19 files changed, 78 insertions, 551 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 diff --git a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java index 0337fe9eab9..2b27f60ef73 100644 --- a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java +++ b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java @@ -120,24 +120,23 @@ public class SearchHandler extends LoggingRequestHandler { public SearchHandler(Statistics statistics, Metric metric, ContainerThreadPool threadpool, - AccessLog accessLog, + AccessLog ignored, CompiledQueryProfileRegistry queryProfileRegistry, ContainerHttpConfig config, ExecutionFactory executionFactory) { - this(statistics, metric, threadpool.executor(), accessLog, queryProfileRegistry, config, executionFactory); + this(statistics, metric, threadpool.executor(), ignored, queryProfileRegistry, config, executionFactory); } public SearchHandler(Statistics statistics, Metric metric, Executor executor, - AccessLog accessLog, + AccessLog ignored, CompiledQueryProfileRegistry queryProfileRegistry, ContainerHttpConfig containerHttpConfig, ExecutionFactory executionFactory) { this(statistics, metric, executor, - accessLog, queryProfileRegistry, executionFactory, containerHttpConfig.numQueriesToTraceOnDebugAfterConstruction(), @@ -152,14 +151,13 @@ public class SearchHandler extends LoggingRequestHandler { public SearchHandler(Statistics statistics, Metric metric, Executor executor, - AccessLog accessLog, + AccessLog ignored, QueryProfilesConfig queryProfileConfig, ContainerHttpConfig containerHttpConfig, ExecutionFactory executionFactory) { this(statistics, metric, executor, - accessLog, QueryProfileConfigurer.createFromConfig(queryProfileConfig).compile(), executionFactory, containerHttpConfig.numQueriesToTraceOnDebugAfterConstruction(), @@ -170,22 +168,21 @@ public class SearchHandler extends LoggingRequestHandler { public SearchHandler(Statistics statistics, Metric metric, Executor executor, - AccessLog accessLog, + AccessLog ignored, CompiledQueryProfileRegistry queryProfileRegistry, ExecutionFactory executionFactory, Optional<String> hostResponseHeaderKey) { - this(statistics, metric, executor, accessLog, queryProfileRegistry, executionFactory, 0, hostResponseHeaderKey); + this(statistics, metric, executor, queryProfileRegistry, executionFactory, 0, hostResponseHeaderKey); } private SearchHandler(Statistics statistics, Metric metric, Executor executor, - AccessLog accessLog, CompiledQueryProfileRegistry queryProfileRegistry, ExecutionFactory executionFactory, long numQueriesToTraceOnDebugAfterStartup, Optional<String> hostResponseHeaderKey) { - super(executor, accessLog, metric, true); + super(executor, metric, true); log.log(Level.FINE, "SearchHandler.init " + System.identityHashCode(this)); this.queryProfileRegistry = queryProfileRegistry; this.executionFactory = executionFactory; diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java index cedae5b5a46..88191bc836b 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/BillingApiHandler.java @@ -63,9 +63,8 @@ public class BillingApiHandler extends LoggingRequestHandler { private final TenantController tenantController; public BillingApiHandler(Executor executor, - AccessLog accessLog, Controller controller) { - super(executor, accessLog); + super(executor); this.billingController = controller.serviceRegistry().billingController(); this.applicationController = controller.applications(); this.tenantController = controller.tenants(); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/systemflags/SystemFlagsHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/systemflags/SystemFlagsHandler.java index 43a03bf10f3..129f1e109df 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/systemflags/SystemFlagsHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/systemflags/SystemFlagsHandler.java @@ -5,8 +5,6 @@ import com.google.inject.Inject; 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 java.util.logging.Level; import com.yahoo.restapi.ErrorResponse; import com.yahoo.restapi.JacksonJsonResponse; import com.yahoo.restapi.Path; @@ -16,6 +14,7 @@ import com.yahoo.vespa.hosted.controller.api.systemflags.v1.FlagsTarget; import com.yahoo.vespa.hosted.controller.api.systemflags.v1.SystemFlagsDataArchive; import java.util.concurrent.Executor; +import java.util.logging.Level; /** * Handler implementation for '/system-flags/v1', an API for controlling system-wide feature flags @@ -32,9 +31,8 @@ public class SystemFlagsHandler extends LoggingRequestHandler { @Inject public SystemFlagsHandler(ZoneRegistry zoneRegistry, ServiceIdentityProvider identityProvider, - Executor executor, - AccessLog accessLog) { - super(executor, accessLog); + Executor executor) { + super(executor); this.deployer = new SystemFlagsDeployer(identityProvider, zoneRegistry.system(), FlagsTarget.getAllTargetsInSystem(zoneRegistry)); } diff --git a/jdisc_http_service/src/main/java/com/yahoo/container/logging/AccessLogEntry.java b/jdisc_http_service/src/main/java/com/yahoo/container/logging/AccessLogEntry.java index 763792298de..42285fb85bb 100644 --- a/jdisc_http_service/src/main/java/com/yahoo/container/logging/AccessLogEntry.java +++ b/jdisc_http_service/src/main/java/com/yahoo/container/logging/AccessLogEntry.java @@ -4,15 +4,10 @@ package com.yahoo.container.logging; import com.yahoo.collections.ListMap; import com.yahoo.yolean.trace.TraceNode; -import javax.security.auth.x500.X500Principal; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.security.Principal; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.function.Function; @@ -36,123 +31,12 @@ import static java.util.stream.Collectors.toMap; */ public class AccessLogEntry { - // Sadly, there's no way to do compile-time validation of these field references. - private static final String[] FIELDS_EXCLUDED_FROM_TOSTRING = new String[] { - "monitor" - }; - private final Object monitor = new Object(); - private String ipV4AddressInDotDecimalNotation; - private long timeStampMillis; - private long durationBetweenRequestResponseMillis; - private long numBytesReturned; - - private String remoteAddress; - private int remotePort; - private String peerAddress; - private int peerPort; - - private String profile; - private String errorMessage; - private String fileName; - private String userAgent; - private String referer; - private String user; private HitCounts hitCounts; - private String httpMethod; - private String httpVersion; - private String hostString; - private int statusCode; - private String scheme; - private int localPort; - private Principal principal; - private X500Principal sslPrincipal; - private String rawPath; - private String rawQuery; private TraceNode traceNode; - private String connectionId; - private ListMap<String,String> keyValues=null; - public void setProfile( String profile ) { - synchronized (monitor) { - requireNull(this.profile); - this.profile = profile; - } - } - - public String getProfile() { - synchronized (monitor) { - return profile; - } - } - - public void setErrorMessage(String errorMessage) { - synchronized (monitor) { - requireNull(this.errorMessage); - this.errorMessage = errorMessage; - } - } - - public String getErrorMessage() { - synchronized (monitor) { - return errorMessage; - } - } - - public void setFileName(String fileName) { - synchronized (monitor) { - requireNull(this.fileName); - this.fileName = fileName; - } - } - - public String getFileName() { - synchronized (monitor) { - return fileName; - } - } - - public void setUserAgent(String userAgent) { - synchronized (monitor) { - requireNull(this.userAgent); - this.userAgent = userAgent; - } - } - - public String getUserAgent() { - synchronized (monitor) { - return userAgent; - } - } - - public void setReferer(String referer) { - synchronized (monitor) { - requireNull(this.referer); - this.referer = referer; - } - } - - public String getReferer() { - synchronized (monitor) { - return referer; - } - } - - public void setUser(final String user) { - synchronized (monitor) { - requireNull(this.user); - this.user = user; - } - } - - public String getUser() { - synchronized (monitor) { - return user; - } - } - public void setHitCounts(final HitCounts hitCounts) { synchronized (monitor) { requireNull(this.hitCounts); @@ -197,323 +81,26 @@ public class AccessLogEntry { entry -> valueConverter.apply(entry.getValue()))); } - public enum HttpMethod { - GET, POST; - } - - public void setHttpMethod(HttpMethod method) { - setHttpMethod(method.toString()); - } - - public void setHttpMethod(String method) { - synchronized (monitor) { - requireNull(this.httpMethod); - this.httpMethod = method; - } - } - - public String getHttpMethod() { - synchronized (monitor) { - return httpMethod; - } - } - - public void setHttpVersion(final String httpVersion) { - synchronized (monitor) { - requireNull(this.httpVersion); - this.httpVersion = httpVersion; - } - } - - public String getHttpVersion() { - synchronized (monitor) { - return httpVersion; - } - } - - public void setHostString(String hostString) { - synchronized (monitor) { - requireNull(this.hostString); - this.hostString = hostString; - } - } - - public String getHostString() { - synchronized (monitor) { - return hostString; - } - } - - public void setIpV4Address(String ipV4AddressInDotDecimalNotation) { - synchronized (monitor) { - requireNull(this.ipV4AddressInDotDecimalNotation); - this.ipV4AddressInDotDecimalNotation = ipV4AddressInDotDecimalNotation; - } - } - - public String getIpV4Address() { - synchronized (monitor) { - return ipV4AddressInDotDecimalNotation; - } - } - - public void setTimeStamp(long numMillisSince1Jan1970AtMidnightUTC) { - synchronized (monitor) { - requireZero(this.timeStampMillis); - timeStampMillis = numMillisSince1Jan1970AtMidnightUTC; - } - } - - public long getTimeStampMillis() { - synchronized (monitor) { - return timeStampMillis; - } - } - - public void setDurationBetweenRequestResponse(long timeInMillis) { - synchronized (monitor) { - requireZero(this.durationBetweenRequestResponseMillis); - durationBetweenRequestResponseMillis = timeInMillis; - } - } - - public long getDurationBetweenRequestResponseMillis() { - synchronized (monitor) { - return durationBetweenRequestResponseMillis; - } - } - - public void setReturnedContentSize(int byteCount) { - setReturnedContentSize((long) byteCount); - } - - public void setReturnedContentSize(long byteCount) { - synchronized (monitor) { - requireZero(this.numBytesReturned); - numBytesReturned = byteCount; - } - } - - public long getReturnedContentSize() { - synchronized (monitor) { - return numBytesReturned; - } - } - - public void setRemoteAddress(String remoteAddress) { - synchronized (monitor) { - requireNull(this.remoteAddress); - this.remoteAddress = remoteAddress; - } - } - - public void setRemoteAddress(final InetSocketAddress remoteAddress) { - setRemoteAddress(getIpAddressAsString(remoteAddress)); - } - - private static String getIpAddressAsString(final InetSocketAddress remoteAddress) { - final InetAddress inetAddress = remoteAddress.getAddress(); - if (inetAddress == null) { - return null; - } - return inetAddress.getHostAddress(); - } - - public String getRemoteAddress() { - synchronized (monitor) { - return remoteAddress; - } - } - - public void setRemotePort(int remotePort) { - synchronized (monitor) { - requireZero(this.remotePort); - this.remotePort = remotePort; - } - } - - public int getRemotePort() { - synchronized (monitor) { - return remotePort; - } - } - - public void setPeerAddress(final String peerAddress) { - synchronized (monitor) { - requireNull(this.peerAddress); - this.peerAddress = peerAddress; - } - } - - public void setPeerPort(int peerPort) { - synchronized (monitor) { - requireZero(this.peerPort); - this.peerPort = peerPort; - } - } - - public int getPeerPort() { - synchronized (monitor) { - return peerPort; - } - } - - public String getPeerAddress() { - synchronized (monitor) { - return peerAddress; - } - } - - public void setStatusCode(int statusCode) { - synchronized (monitor) { - requireZero(this.statusCode); - this.statusCode = statusCode; - } - } - - public int getStatusCode() { - synchronized (monitor) { - return statusCode; - } - } - - public String getScheme() { - synchronized (monitor) { - return scheme; - } - } - - public void setScheme(String scheme) { - synchronized (monitor) { - requireNull(this.scheme); - this.scheme = scheme; - } - } - - public int getLocalPort() { - synchronized (monitor) { - return localPort; - } - } - - public void setLocalPort(int localPort) { - synchronized (monitor) { - requireZero(this.localPort); - this.localPort = localPort; - } - } - - public Principal getUserPrincipal() { - synchronized (monitor) { - return principal; - } - } - - public void setUserPrincipal(Principal principal) { - synchronized (monitor) { - requireNull(this.principal); - this.principal = principal; - } - } - - public Principal getSslPrincipal() { - synchronized (monitor) { - return sslPrincipal; - } - } - - public void setSslPrincipal(X500Principal sslPrincipal) { - synchronized (monitor) { - requireNull(this.sslPrincipal); - this.sslPrincipal = sslPrincipal; - } - } - - public void setRawPath(String rawPath) { - synchronized (monitor) { - requireNull(this.rawPath); - this.rawPath = rawPath; - } - } - - public String getRawPath() { - synchronized (monitor) { - return rawPath; - } - } - - public void setRawQuery(String rawQuery) { - synchronized (monitor) { - requireNull(this.rawQuery); - this.rawQuery = rawQuery; - } - } - - public Optional<String> getRawQuery() { - synchronized (monitor) { - return Optional.ofNullable(rawQuery); - } - } - public void setTrace(TraceNode traceNode) { synchronized (monitor) { requireNull(this.traceNode); this.traceNode = traceNode; } } + public TraceNode getTrace() { synchronized (monitor) { return traceNode; } } - public void setConnectionId(String id) { - synchronized (monitor) { - requireNull(this.connectionId); - this.connectionId = id; - } - } - - public Optional<String> getConnectionId() { - synchronized (monitor) { - return Optional.ofNullable(this.connectionId); - } - } - @Override public String toString() { - synchronized (monitor) { - return "AccessLogEntry{" + - "ipV4AddressInDotDecimalNotation='" + ipV4AddressInDotDecimalNotation + '\'' + - ", timeStampMillis=" + timeStampMillis + - ", durationBetweenRequestResponseMillis=" + durationBetweenRequestResponseMillis + - ", numBytesReturned=" + numBytesReturned + - ", remoteAddress='" + remoteAddress + '\'' + - ", remotePort=" + remotePort + - ", peerAddress='" + peerAddress + '\'' + - ", peerPort=" + peerPort + - ", profile='" + profile + '\'' + - ", errorMessage='" + errorMessage + '\'' + - ", fileName='" + fileName + '\'' + - ", userAgent='" + userAgent + '\'' + - ", referer='" + referer + '\'' + - ", user='" + user + '\'' + - ", hitCounts=" + hitCounts + - ", httpMethod='" + httpMethod + '\'' + - ", httpVersion='" + httpVersion + '\'' + - ", hostString='" + hostString + '\'' + - ", statusCode=" + statusCode + - ", scheme='" + scheme + '\'' + - ", localPort=" + localPort + - ", principal=" + principal + - ", sslPrincipal=" + sslPrincipal + - ", rawPath='" + rawPath + '\'' + - ", rawQuery='" + rawQuery + '\'' + - ", traceNode=" + traceNode + - ", connectionId='" + connectionId + '\'' + - ", keyValues=" + keyValues + - '}'; - } + return "AccessLogEntry{" + + "hitCounts=" + hitCounts + + ", traceNode=" + traceNode + + ", keyValues=" + keyValues + + '}'; } private static void requireNull(final Object value) { @@ -522,16 +109,4 @@ public class AccessLogEntry { } } - private static void requireZero(final long value) { - if (value != 0) { - throw new IllegalStateException("Attempt to overwrite field that has been assigned. Value: " + value); - } - } - - private static void requireZero(final int value) { - if (value != 0) { - throw new IllegalStateException("Attempt to overwrite field that has been assigned. Value: " + value); - } - } - } diff --git a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/AccessLoggingRequestHandler.java b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/AccessLoggingRequestHandler.java index e30d50ecdbf..842ab75a312 100644 --- a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/AccessLoggingRequestHandler.java +++ b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/AccessLoggingRequestHandler.java @@ -4,7 +4,6 @@ package com.yahoo.jdisc.http.server.jetty; import com.google.common.base.Preconditions; import com.yahoo.container.logging.AccessLogEntry; import com.yahoo.jdisc.Request; -import com.yahoo.jdisc.Response; import com.yahoo.jdisc.handler.AbstractRequestHandler; import com.yahoo.jdisc.handler.ContentChannel; import com.yahoo.jdisc.handler.RequestHandler; @@ -23,7 +22,6 @@ import java.util.Optional; * Does not otherwise interfere with the request processing of the delegate request handler. * * @author bakksjo - * $Id$ */ public class AccessLoggingRequestHandler extends AbstractRequestHandler { public static final String CONTEXT_KEY_ACCESS_LOG_ENTRY @@ -54,30 +52,8 @@ public class AccessLoggingRequestHandler extends AbstractRequestHandler { Preconditions.checkArgument(request instanceof HttpRequest, "Expected HttpRequest, got " + request); final HttpRequest httpRequest = (HttpRequest) request; httpRequest.context().put(CONTEXT_KEY_ACCESS_LOG_ENTRY, accessLogEntry); - final ResponseHandler accessLoggingResponseHandler = new AccessLoggingResponseHandler(httpRequest, handler, accessLogEntry); - final ContentChannel requestContentChannel = delegate.handleRequest(request, accessLoggingResponseHandler); - return requestContentChannel; + return delegate.handleRequest(request, handler); } - private static class AccessLoggingResponseHandler implements ResponseHandler { - private final HttpRequest request; - private final ResponseHandler delegateHandler; - private final AccessLogEntry accessLogEntry; - - public AccessLoggingResponseHandler( - HttpRequest request, final ResponseHandler delegateHandler, - final AccessLogEntry accessLogEntry) { - this.request = request; - this.delegateHandler = delegateHandler; - this.accessLogEntry = accessLogEntry; - } - - @Override - public ContentChannel handleResponse(Response response) { - accessLogEntry.setUserPrincipal(request.getUserPrincipal()); - return delegateHandler.handleResponse(response); - } - - } } diff --git a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestRunnerHandler.java b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestRunnerHandler.java index 77c68012005..f32714ec4da 100644 --- a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestRunnerHandler.java +++ b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestRunnerHandler.java @@ -9,7 +9,6 @@ import com.yahoo.container.jdisc.EmptyResponse; 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.slime.Cursor; import com.yahoo.slime.JsonFormat; import com.yahoo.slime.Slime; @@ -47,8 +46,8 @@ public class TestRunnerHandler extends LoggingRequestHandler { private final boolean useOsgiMode; @Inject - public TestRunnerHandler(Executor executor, AccessLog accessLog, TestRunner junitRunner, LegacyTestRunner testRunner) { - super(executor, accessLog); + public TestRunnerHandler(Executor executor, TestRunner junitRunner, LegacyTestRunner testRunner) { + super(executor); this.junitRunner = junitRunner; this.testRunner = testRunner; this.useOsgiMode = junitRunner.isSupported(); diff --git a/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/TestRunnerHandlerTest.java b/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/TestRunnerHandlerTest.java index 2234bdff0a0..16f1c7de0ff 100644 --- a/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/TestRunnerHandlerTest.java +++ b/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/TestRunnerHandlerTest.java @@ -4,7 +4,6 @@ package com.yahoo.vespa.testrunner; import ai.vespa.hosted.api.TestDescriptor; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.container.logging.AccessLog; import com.yahoo.test.json.JsonTestHelper; import com.yahoo.vespa.testrunner.legacy.LegacyTestRunner; import org.junit.jupiter.api.BeforeAll; @@ -20,7 +19,6 @@ import java.util.logging.LogRecord; import static com.yahoo.jdisc.http.HttpRequest.Method.GET; import static org.junit.Assert.assertEquals; - import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -49,7 +47,6 @@ public class TestRunnerHandlerTest { testRunnerHandler = new TestRunnerHandler( Executors.newSingleThreadExecutor(), - AccessLog.voidAccessLog(), new MockJunitRunner(LegacyTestRunner.Status.SUCCESS, testReport), null); } @@ -85,7 +82,6 @@ public class TestRunnerHandlerTest { when(testRunner.getReport()).thenReturn(null); testRunnerHandler = new TestRunnerHandler( Executors.newSingleThreadExecutor(), - AccessLog.voidAccessLog(), testRunner, null); HttpResponse response = testRunnerHandler.handle(HttpRequest.createTestRequest("http://localhost:1234/tester/v1/log", GET)); @@ -103,7 +99,6 @@ public class TestRunnerHandlerTest { testRunnerHandler = new TestRunnerHandler( Executors.newSingleThreadExecutor(), - AccessLog.voidAccessLog(), testRunner, legacyTestRunner); HttpResponse response = testRunnerHandler.handle(HttpRequest.createTestRequest("http://localhost:1234/tester/v1/log", GET)); diff --git a/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunnerHandler.java b/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunnerHandler.java index 8f9966a898f..854a9aa1874 100644 --- a/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunnerHandler.java +++ b/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunnerHandler.java @@ -7,7 +7,6 @@ import com.google.inject.Inject; 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.io.IOUtils; import com.yahoo.slime.Cursor; import com.yahoo.slime.JsonFormat; @@ -37,8 +36,8 @@ public class TestRunnerHandler extends LoggingRequestHandler { private final TestRunner testRunner; @Inject - public TestRunnerHandler(Executor executor, AccessLog accessLog, TestRunner testRunner) { - super(executor, accessLog); + public TestRunnerHandler(Executor executor, TestRunner testRunner) { + super(executor); this.testRunner = testRunner; } diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java index bd63a2ecbfc..abe791eed1b 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java @@ -5,6 +5,7 @@ import com.google.inject.Inject; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.LoggingRequestHandler; +import com.yahoo.jdisc.Metric; /** * Dummy for internal use. @@ -15,7 +16,7 @@ public class RestApi extends LoggingRequestHandler { @Inject public RestApi() { - super(ignored -> { throw new IllegalStateException("Not supposed to handle anything"); }, null, null); + super(ignored -> { throw new IllegalStateException("Not supposed to handle anything"); }, (Metric)null); } @Override diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandler.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandler.java index 50806d7aa20..0a07e978868 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandler.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandler.java @@ -7,7 +7,6 @@ import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.LoggingRequestHandler; import com.yahoo.container.jdisc.messagebus.SessionCache; -import com.yahoo.container.logging.AccessLog; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.documentapi.metrics.DocumentApiMetrics; import com.yahoo.jdisc.Metric; @@ -46,13 +45,12 @@ public class FeedHandler extends LoggingRequestHandler { @Inject public FeedHandler(ContainerThreadPool threadpool, Metric metric, - AccessLog accessLog, DocumentmanagerConfig documentManagerConfig, SessionCache sessionCache, MetricReceiver metricReceiver) { - super(threadpool.executor(), accessLog, metric); + super(threadpool.executor(), metric); metricsHelper = new DocumentApiMetrics(metricReceiver, "vespa.http.server"); - feedHandlerV3 = new FeedHandlerV3(threadpool.executor(), metric, accessLog, documentManagerConfig, sessionCache, metricsHelper); + feedHandlerV3 = new FeedHandlerV3(threadpool.executor(), metric, documentManagerConfig, sessionCache, metricsHelper); feedReplyHandler = new FeedReplyReader(metric, metricsHelper); } diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandlerV3.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandlerV3.java index be432834d1b..3143b66e094 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandlerV3.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandlerV3.java @@ -6,7 +6,6 @@ import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.LoggingRequestHandler; import com.yahoo.container.jdisc.messagebus.SessionCache; -import com.yahoo.container.logging.AccessLog; import com.yahoo.document.DocumentTypeManager; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.documentapi.metrics.DocumentApiMetrics; @@ -47,11 +46,10 @@ public class FeedHandlerV3 extends LoggingRequestHandler { public FeedHandlerV3(Executor executor, Metric metric, - AccessLog accessLog, DocumentmanagerConfig documentManagerConfig, SessionCache sessionCache, DocumentApiMetrics metricsHelper) { - super(executor, accessLog, metric); + super(executor, metric); docTypeManager = new DocumentTypeManager(documentManagerConfig); this.sessionCache = sessionCache; feedReplyHandler = new FeedReplyReader(metric, metricsHelper); diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerTest.java b/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerTest.java index d236ec1f7a0..ab7b224c7be 100644 --- a/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerTest.java +++ b/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerTest.java @@ -2,7 +2,6 @@ package com.yahoo.vespa.http.server;// Copyright Verizon Media. Licensed under t import com.yahoo.container.handler.threadpool.ContainerThreadPool; import com.yahoo.container.jdisc.RequestHandlerTestDriver; -import com.yahoo.container.logging.AccessLog; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.jdisc.handler.OverloadException; import com.yahoo.metrics.simple.MetricReceiver; @@ -25,7 +24,6 @@ public class FeedHandlerTest { FeedHandler handler = new FeedHandler( new RejectingContainerThreadpool(), new CollectingMetric(), - AccessLog.voidAccessLog(), new DocumentmanagerConfig(new DocumentmanagerConfig.Builder().enablecompression(true)), null /* session cache */, MetricReceiver.nullImplementation); diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerV3Test.java b/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerV3Test.java index 4d56448b587..1e835750039 100644 --- a/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerV3Test.java +++ b/vespaclient-container-plugin/src/test/java/com/yahoo/vespa/http/server/FeedHandlerV3Test.java @@ -5,7 +5,6 @@ import com.google.common.base.Splitter; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.messagebus.SessionCache; -import com.yahoo.container.logging.AccessLog; import com.yahoo.document.DataType; import com.yahoo.document.DocumentType; import com.yahoo.document.DocumentTypeManager; @@ -118,7 +117,6 @@ public class FeedHandlerV3Test { FeedHandlerV3 feedHandlerV3 = new FeedHandlerV3( threadPool, metric, - AccessLog.voidAccessLog(), docMan, null /* session cache */, new DocumentApiMetrics(MetricReceiver.nullImplementation, "test")) { |