diff --git a/src/main/config/secor.dev.properties b/src/main/config/secor.dev.properties index 928dc1c12..39a0c845b 100644 --- a/src/main/config/secor.dev.properties +++ b/src/main/config/secor.dev.properties @@ -32,4 +32,6 @@ secor.max.file.age.policy=oldest # kafkaPartition - The kafka partition # fmOffset - First Message offset in the file. # randomHex - A 4 character random hex to append to the file name +# currentTimestamp - Epoch time +# currentTime - Time in HH-mm format secor.s3.output_file_pattern={randomHex}_{partition}_{topic}_{generation}.json \ No newline at end of file diff --git a/src/main/java/com/pinterest/secor/common/LogFilePath.java b/src/main/java/com/pinterest/secor/common/LogFilePath.java index da40b3995..ec642de41 100644 --- a/src/main/java/com/pinterest/secor/common/LogFilePath.java +++ b/src/main/java/com/pinterest/secor/common/LogFilePath.java @@ -21,8 +21,11 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.text.StrSubstitutor; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -56,6 +59,7 @@ public class LogFilePath { private final long mOffset; private final String mExtension; private String mOutputFilePattern; + private SimpleDateFormat timeFormat = new SimpleDateFormat("HH-mm"); public LogFilePath(String prefix, int generation, long lastCommittedOffset, ParsedMessage message, String extension) { @@ -184,6 +188,7 @@ private String getLogFilePath(String pattern) { private Map getValueMap() { + Map valueMap = new HashMap(); valueMap.put("randomHex", getRandomHex()); valueMap.put("partition", mPartitions[0]); @@ -191,6 +196,8 @@ private Map getValueMap() { valueMap.put("generation", mGeneration + ""); valueMap.put("kafkaPartition", mKafkaPartition + ""); valueMap.put("fmOffset", String.format("%020d", mOffset)); + valueMap.put("currentTimestamp", System.currentTimeMillis() + ""); + valueMap.put("currentTime", timeFormat.format(new Date())); return valueMap; }