diff --git a/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/main/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/audit/AuditLogDirectParser.java b/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/main/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/audit/AuditLogDirectParser.java index f07d9ed469..f632d6a0ef 100644 --- a/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/main/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/audit/AuditLogDirectParser.java +++ b/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/main/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/audit/AuditLogDirectParser.java @@ -22,6 +22,7 @@ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.HashMap; import java.util.Map; import java.util.TimeZone; import java.util.function.Function; @@ -81,8 +82,6 @@ public class AuditLogDirectParser implements AuditCommandParser { public static final String AUDIT_LOG_PARSE_REGEX_DEFAULT = "^(?.+?) INFO [^:]+: (?.+)$"; - private static final Splitter.MapSplitter AUDIT_SPLITTER = Splitter.on("\t") - .trimResults().omitEmptyStrings().withKeyValueSeparator("="); private static final Splitter SPACE_SPLITTER = Splitter.on(" ").trimResults() .omitEmptyStrings(); @@ -132,8 +131,20 @@ public AuditReplayCommand parse(Text inputLine, // Sanitize the = in the rename options field into a : so we can split on = String auditMessageSanitized = m.group("message").replace("(options=", "(options:"); - Map parameterMap = AUDIT_SPLITTER - .split(auditMessageSanitized); + + Map parameterMap = new HashMap(); + String[] auditMessageSanitizedList = auditMessageSanitized.split("\t"); + + for (String auditMessage : auditMessageSanitizedList) { + String[] splitMessage = auditMessage.split("=", 2); + try { + parameterMap.put(splitMessage[0], splitMessage[1]); + } catch (ArrayIndexOutOfBoundsException e) { + throw new IOException( + "Exception while parsing a message from audit log", e); + } + } + return new AuditReplayCommand(relativeToAbsolute.apply(relativeTimestamp), // Split the UGI on space to remove the auth and proxy portions of it SPACE_SPLITTER.split(parameterMap.get("ugi")).iterator().next(), diff --git a/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/test/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/audit/TestAuditLogDirectParser.java b/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/test/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/audit/TestAuditLogDirectParser.java index f3a6eed565..a98b5c4716 100644 --- a/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/test/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/audit/TestAuditLogDirectParser.java +++ b/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/test/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/audit/TestAuditLogDirectParser.java @@ -58,6 +58,15 @@ public void testSimpleInput() throws Exception { assertEquals(expected, parser.parse(in, Function.identity())); } + @Test + public void testInputWithEquals() throws Exception { + Text in = getAuditString("1970-01-01 00:00:11,000", "fakeUser", + "listStatus", "day=1970", "null"); + AuditReplayCommand expected = new AuditReplayCommand(1000, "fakeUser", + "listStatus", "day=1970", "null", "0.0.0.0"); + assertEquals(expected, parser.parse(in, Function.identity())); + } + @Test public void testInputWithRenameOptions() throws Exception { Text in = getAuditString("1970-01-01 00:00:11,000", "fakeUser",