diff options
author | Arne Juul <arnej@yahoo-inc.com> | 2018-03-12 10:31:15 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahoo-inc.com> | 2018-03-12 12:38:38 +0000 |
commit | 236ec279fdbc3f9a412d968d0593268ff3f566e9 (patch) | |
tree | 4e8de7db5ddd50f8994f3554c6df0a24a95284f7 | |
parent | 39b7feb6c665f795f346348894bdad333664618b (diff) |
ensure gzip of access logs for hosted vespa only
3 files changed, 19 insertions, 4 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/component/AccessLogComponent.java b/config-model/src/main/java/com/yahoo/vespa/model/container/component/AccessLogComponent.java index dbde510f9e0..7da7abe0546 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/component/AccessLogComponent.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/component/AccessLogComponent.java @@ -17,18 +17,18 @@ import static com.yahoo.container.core.AccessLogConfig.FileHandler.RotateScheme; */ public final class AccessLogComponent extends SimpleComponent implements AccessLogConfig.Producer { - public enum AccessLogType { queryAccessLog, yApacheAccessLog, jsonAccessLog } private final String fileNamePattern; private final String rotationInterval; private final RotateScheme.Enum rotationScheme; + private final Boolean compression; private final String symlinkName; public AccessLogComponent(AccessLogType logType, String clusterName) { this(logType, String.format("logs/vespa/qrs/%s.%s.%s", capitalize(logType.name()), clusterName, "%Y%m%d%H%M%S"), - null, null, + null, null, null, capitalize(logType.name()) + "." + clusterName); } @@ -39,11 +39,15 @@ public final class AccessLogComponent extends SimpleComponent implements AccessL public AccessLogComponent(AccessLogType logType, String fileNamePattern, String rotationInterval, - RotateScheme.Enum rotationScheme, String symlinkName) { + RotateScheme.Enum rotationScheme, + Boolean compressOnRotation, + String symlinkName) + { super(new ComponentModel(accessLogClass(logType), null, "container-core", null)); this.fileNamePattern = fileNamePattern; this.rotationInterval = rotationInterval; this.rotationScheme = rotationScheme; + this.compression = compressOnRotation; this.symlinkName = symlinkName; if (fileNamePattern == null) @@ -78,6 +82,11 @@ public final class AccessLogComponent extends SimpleComponent implements AccessL builder.rotateScheme(rotationScheme); if (symlinkName != null) builder.symlink(symlinkName); + if (compression != null) { + builder.compressOnRotation(compression); + } else if (isHostedVespa()) { + builder.compressOnRotation(true); + } return builder; } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/AccessLogBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/AccessLogBuilder.java index 4d422d921c8..1b15a49462e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/AccessLogBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/AccessLogBuilder.java @@ -57,6 +57,7 @@ public class AccessLogBuilder { fileNamePattern(spec), rotationInterval(spec), rotationScheme(spec), + compressOnRotation(spec), symlinkName(spec)); } @@ -64,6 +65,11 @@ public class AccessLogBuilder { return nullIfEmpty(spec.getAttribute("symlinkName")); } + private Boolean compressOnRotation(Element spec) { + String compress = spec.getAttribute("compressOnRotation"); + return (compress.isEmpty() ? null : Boolean.parseBoolean(compress)); + } + private AccessLogConfig.FileHandler.RotateScheme.Enum rotationScheme(Element spec) { return AccessLogComponent.rotateScheme(nullIfEmpty(spec.getAttribute("rotationScheme"))); } diff --git a/container-accesslogging/src/main/resources/configdefinitions/access-log.def b/container-accesslogging/src/main/resources/configdefinitions/access-log.def index 7f932540c2b..276128e0405 100644 --- a/container-accesslogging/src/main/resources/configdefinitions/access-log.def +++ b/container-accesslogging/src/main/resources/configdefinitions/access-log.def @@ -27,4 +27,4 @@ fileHandler.rotateScheme enum {DATE, SEQUENCE} default=DATE fileHandler.symlink string default="" # compress the previous access log after rotation -fileHandler.compressOnRotation bool default=true +fileHandler.compressOnRotation bool default=false |