Class WebServerAccessLogImpl
- java.lang.Object
-
- org.torproject.metrics.collector.webstats.WebServerAccessLogImpl
-
- All Implemented Interfaces:
java.io.Serializable,org.torproject.descriptor.Descriptor,org.torproject.descriptor.LogDescriptor,org.torproject.descriptor.WebServerAccessLog
public class WebServerAccessLogImpl extends java.lang.Object implements org.torproject.descriptor.WebServerAccessLogImplementation of web server access log descriptors.Defines sanitization and validation for web server access logs.
- Since:
- 2.2.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.PatternfilenamePatternThe mandatory web server log descriptor file name pattern.static java.lang.StringMARKERThe log's name should include this string.static java.lang.StringSEPLogfile name parts separator.
-
Constructor Summary
Constructors Modifier Constructor Description protectedWebServerAccessLogImpl(byte[] logBytes, java.io.File descriptorFile, java.lang.String logName)Creates a WebServerAccessLog from the given bytes and filename.protectedWebServerAccessLogImpl(java.lang.String virtualHost, java.lang.String physicalHost, java.time.LocalDate logDate)Creates an empty WebServerAccessLog from the given filename parts.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStreamdecompressedByteStream()java.util.List<java.lang.String>getAnnotations()java.lang.StringgetCompressionType()java.io.FilegetDescriptorFile()java.time.LocalDategetLogDate()java.lang.StringgetPhysicalHost()byte[]getRawDescriptorBytes()intgetRawDescriptorLength()java.util.List<java.lang.String>getUnrecognizedLines()java.lang.StringgetVirtualHost()java.util.stream.Stream<org.torproject.descriptor.WebServerAccessLog.Line>logLines()Returns a stream of all valid log lines.voidsetRawDescriptorBytes(byte[] bytes)
-
-
-
Field Detail
-
SEP
public static final java.lang.String SEP
Logfile name parts separator.- See Also:
- Constant Field Values
-
MARKER
public static final java.lang.String MARKER
The log's name should include this string.- See Also:
- Constant Field Values
-
filenamePattern
public static final java.util.regex.Pattern filenamePattern
The mandatory web server log descriptor file name pattern.
-
-
Constructor Detail
-
WebServerAccessLogImpl
protected WebServerAccessLogImpl(byte[] logBytes, java.io.File descriptorFile, java.lang.String logName) throws org.torproject.descriptor.DescriptorParseExceptionCreates a WebServerAccessLog from the given bytes and filename.The given bytes are read, whereas the file is not read.
The path of the given file has to be compliant to the following naming pattern
<virtualHost>-<physicalHost>-access.log-<yyyymmdd>.<compression>, where an unknown compression type (seegetCompressionType()) is interpreted as missing compression. In this case the bytes will be compressed to the default compression type. The immediate parent name is taken to be the physical host collecting the logs.- Throws:
org.torproject.descriptor.DescriptorParseException
-
WebServerAccessLogImpl
protected WebServerAccessLogImpl(java.lang.String virtualHost, java.lang.String physicalHost, java.time.LocalDate logDate)Creates an empty WebServerAccessLog from the given filename parts.This instance is not intended to be written to disk, as it doesn't have any content. The main intention of this instance is to compute storage paths.
- Parameters:
virtualHost- Virtual host name.physicalHost- Physical host name.logDate- Log date.
-
-
Method Detail
-
decompressedByteStream
public java.io.InputStream decompressedByteStream() throws org.torproject.descriptor.DescriptorParseException- Specified by:
decompressedByteStreamin interfaceorg.torproject.descriptor.LogDescriptor- Throws:
org.torproject.descriptor.DescriptorParseException
-
getCompressionType
public java.lang.String getCompressionType()
-
getRawDescriptorBytes
public byte[] getRawDescriptorBytes()
- Specified by:
getRawDescriptorBytesin interfaceorg.torproject.descriptor.Descriptor- Specified by:
getRawDescriptorBytesin interfaceorg.torproject.descriptor.LogDescriptor
-
setRawDescriptorBytes
public void setRawDescriptorBytes(byte[] bytes)
-
getRawDescriptorLength
public int getRawDescriptorLength()
- Specified by:
getRawDescriptorLengthin interfaceorg.torproject.descriptor.Descriptor
-
getAnnotations
public java.util.List<java.lang.String> getAnnotations()
- Specified by:
getAnnotationsin interfaceorg.torproject.descriptor.Descriptor- Specified by:
getAnnotationsin interfaceorg.torproject.descriptor.LogDescriptor
-
getUnrecognizedLines
public java.util.List<java.lang.String> getUnrecognizedLines()
- Specified by:
getUnrecognizedLinesin interfaceorg.torproject.descriptor.Descriptor- Specified by:
getUnrecognizedLinesin interfaceorg.torproject.descriptor.LogDescriptor- Specified by:
getUnrecognizedLinesin interfaceorg.torproject.descriptor.WebServerAccessLog
-
getDescriptorFile
public java.io.File getDescriptorFile()
- Specified by:
getDescriptorFilein interfaceorg.torproject.descriptor.Descriptor
-
getPhysicalHost
public java.lang.String getPhysicalHost()
- Specified by:
getPhysicalHostin interfaceorg.torproject.descriptor.WebServerAccessLog
-
getVirtualHost
public java.lang.String getVirtualHost()
- Specified by:
getVirtualHostin interfaceorg.torproject.descriptor.WebServerAccessLog
-
getLogDate
public java.time.LocalDate getLogDate()
- Specified by:
getLogDatein interfaceorg.torproject.descriptor.WebServerAccessLog
-
logLines
public java.util.stream.Stream<org.torproject.descriptor.WebServerAccessLog.Line> logLines() throws org.torproject.descriptor.DescriptorParseExceptionReturns a stream of all valid log lines.- Specified by:
logLinesin interfaceorg.torproject.descriptor.LogDescriptor- Specified by:
logLinesin interfaceorg.torproject.descriptor.WebServerAccessLog- Throws:
org.torproject.descriptor.DescriptorParseException
-
-