public class AuditLogDirectParser extends Object implements AuditCommandParser
AuditCommandParser is used to read commands from an audit log in
the original format audit logs are produced in with a standard configuration.
It requires setting the "auditreplay.log-start-time.ms" configuration to
specify what the start time of the audit log was to determine when events
occurred relative to this start time.
By default, this assumes that the audit log is in the default log format set up by Hadoop, like:
1970-01-01 00:00:00,000 INFO FSNamesystem.audit: allowed=true ...
You can adjust this parsing behavior using the various configurations
available.| Modifier and Type | Field and Description |
|---|---|
static String |
AUDIT_LOG_DATE_FORMAT_DEFAULT |
static String |
AUDIT_LOG_DATE_FORMAT_KEY
The format string used to parse the date which is present in the audit
log.
|
static String |
AUDIT_LOG_DATE_TIME_ZONE_DEFAULT |
static String |
AUDIT_LOG_DATE_TIME_ZONE_KEY
The time zone to use when parsing the audit log timestamp.
|
static String |
AUDIT_LOG_PARSE_REGEX_DEFAULT |
static String |
AUDIT_LOG_PARSE_REGEX_KEY
The regex to use when parsing the audit log lines.
|
static String |
AUDIT_START_TIMESTAMP_KEY
See class Javadoc for more detail.
|
| Constructor and Description |
|---|
AuditLogDirectParser() |
| Modifier and Type | Method and Description |
|---|---|
void |
initialize(org.apache.hadoop.conf.Configuration conf)
Initialize this parser with the given configuration.
|
org.apache.hadoop.tools.dynamometer.workloadgenerator.audit.AuditReplayCommand |
parse(org.apache.hadoop.io.Text inputLine,
Function<Long,Long> relativeToAbsolute)
Convert a line of input into an
AuditReplayCommand. |
public static final String AUDIT_START_TIMESTAMP_KEY
public static final String AUDIT_LOG_DATE_FORMAT_KEY
SimpleDateFormat.public static final String AUDIT_LOG_DATE_FORMAT_DEFAULT
public static final String AUDIT_LOG_DATE_TIME_ZONE_KEY
TimeZone.getTimeZone(String).public static final String AUDIT_LOG_DATE_TIME_ZONE_DEFAULT
public static final String AUDIT_LOG_PARSE_REGEX_KEY
date formatter. The other must be titled "message"
and return the audit content, such as "allowed=true ugi=user ...". See
AUDIT_LOG_PARSE_REGEX_DEFAULT for an example.public static final String AUDIT_LOG_PARSE_REGEX_DEFAULT
public void initialize(org.apache.hadoop.conf.Configuration conf)
throws IOException
AuditCommandParserAuditCommandParser.parse(Text, Function).initialize in interface AuditCommandParserconf - The Configuration to be used to set up this parser.IOException - if error on initializing a parser.public org.apache.hadoop.tools.dynamometer.workloadgenerator.audit.AuditReplayCommand parse(org.apache.hadoop.io.Text inputLine,
Function<Long,Long> relativeToAbsolute)
throws IOException
AuditCommandParserAuditReplayCommand. Since
AuditReplayCommands store absolute timestamps, relativeToAbsolute
can be used to convert relative timestamps (i.e., milliseconds elapsed
between the start of the audit log and this command) into absolute
timestamps.parse in interface AuditCommandParserinputLine - Single input line to convert.relativeToAbsolute - Function converting relative timestamps
(in milliseconds) to absolute timestamps
(in milliseconds).IOException - if error on parsing.Copyright © 2008–2023 Apache Software Foundation. All rights reserved.