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.WebServerAccessLog
Implementation 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.Pattern
filenamePattern
The mandatory web server log descriptor file name pattern.static java.lang.String
MARKER
The log's name should include this string.static java.lang.String
SEP
Logfile name parts separator.
-
Constructor Summary
Constructors Modifier Constructor Description protected
WebServerAccessLogImpl(byte[] logBytes, java.io.File descriptorFile, java.lang.String logName)
Creates a WebServerAccessLog from the given bytes and filename.protected
WebServerAccessLogImpl(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.InputStream
decompressedByteStream()
java.util.List<java.lang.String>
getAnnotations()
java.lang.String
getCompressionType()
java.io.File
getDescriptorFile()
java.time.LocalDate
getLogDate()
java.lang.String
getPhysicalHost()
byte[]
getRawDescriptorBytes()
int
getRawDescriptorLength()
java.util.List<java.lang.String>
getUnrecognizedLines()
java.lang.String
getVirtualHost()
java.util.stream.Stream<org.torproject.descriptor.WebServerAccessLog.Line>
logLines()
Returns a stream of all valid log lines.void
setRawDescriptorBytes(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.DescriptorParseException
Creates 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:
decompressedByteStream
in interfaceorg.torproject.descriptor.LogDescriptor
- Throws:
org.torproject.descriptor.DescriptorParseException
-
getCompressionType
public java.lang.String getCompressionType()
-
getRawDescriptorBytes
public byte[] getRawDescriptorBytes()
- Specified by:
getRawDescriptorBytes
in interfaceorg.torproject.descriptor.Descriptor
- Specified by:
getRawDescriptorBytes
in interfaceorg.torproject.descriptor.LogDescriptor
-
setRawDescriptorBytes
public void setRawDescriptorBytes(byte[] bytes)
-
getRawDescriptorLength
public int getRawDescriptorLength()
- Specified by:
getRawDescriptorLength
in interfaceorg.torproject.descriptor.Descriptor
-
getAnnotations
public java.util.List<java.lang.String> getAnnotations()
- Specified by:
getAnnotations
in interfaceorg.torproject.descriptor.Descriptor
- Specified by:
getAnnotations
in interfaceorg.torproject.descriptor.LogDescriptor
-
getUnrecognizedLines
public java.util.List<java.lang.String> getUnrecognizedLines()
- Specified by:
getUnrecognizedLines
in interfaceorg.torproject.descriptor.Descriptor
- Specified by:
getUnrecognizedLines
in interfaceorg.torproject.descriptor.LogDescriptor
- Specified by:
getUnrecognizedLines
in interfaceorg.torproject.descriptor.WebServerAccessLog
-
getDescriptorFile
public java.io.File getDescriptorFile()
- Specified by:
getDescriptorFile
in interfaceorg.torproject.descriptor.Descriptor
-
getPhysicalHost
public java.lang.String getPhysicalHost()
- Specified by:
getPhysicalHost
in interfaceorg.torproject.descriptor.WebServerAccessLog
-
getVirtualHost
public java.lang.String getVirtualHost()
- Specified by:
getVirtualHost
in interfaceorg.torproject.descriptor.WebServerAccessLog
-
getLogDate
public java.time.LocalDate getLogDate()
- Specified by:
getLogDate
in interfaceorg.torproject.descriptor.WebServerAccessLog
-
logLines
public java.util.stream.Stream<org.torproject.descriptor.WebServerAccessLog.Line> logLines() throws org.torproject.descriptor.DescriptorParseException
Returns a stream of all valid log lines.- Specified by:
logLines
in interfaceorg.torproject.descriptor.LogDescriptor
- Specified by:
logLines
in interfaceorg.torproject.descriptor.WebServerAccessLog
- Throws:
org.torproject.descriptor.DescriptorParseException
-
-