Skip to content

Commit

Permalink
Add two additional placeholders to file path (currentTimestamp and cu…
Browse files Browse the repository at this point in the history
…rrentTime)
  • Loading branch information
Santhosh Vasabhaktula authored and Santhosh Vasabhaktula committed Dec 16, 2015
1 parent 35c6b99 commit 9d2b89a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/config/secor.dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions src/main/java/com/pinterest/secor/common/LogFilePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -184,13 +188,16 @@ private String getLogFilePath(String pattern) {

private Map<String, String> getValueMap() {


Map<String, String> valueMap = new HashMap<String, String>();
valueMap.put("randomHex", getRandomHex());
valueMap.put("partition", mPartitions[0]);
valueMap.put("topic", mTopic);
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;
}

Expand Down

0 comments on commit 9d2b89a

Please sign in to comment.