-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use suro file's lastModify/dateCreated time for build upload path #147
base: master
Are you sure you want to change the base?
Changes from all commits
fa43a3b
113a2c9
64ba50e
65f06e5
4c6d051
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.netflix.suro.sink.remotefile.formatter; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need a copyright /*
|
||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.netflix.suro.sink.localfile.FileNameFormatter; | ||
import com.netflix.suro.sink.remotefile.RemotePrefixFormatter; | ||
import org.joda.time.DateTime; | ||
import org.joda.time.format.DateTimeFormat; | ||
import org.joda.time.format.DateTimeFormatter; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* Created by [email protected] on 10/6/14. | ||
*/ | ||
public class FileDatePrefixFormatter implements RemotePrefixFormatter{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need the unit test for this class even though this class's logic is simple. |
||
public static final String TYPE = "FileDate"; | ||
private final DateTimeFormatter formatter; | ||
//lastModify or dateCreated | ||
private String dateType; | ||
|
||
public FileDatePrefixFormatter(@JsonProperty("format") String formatString, | ||
@JsonProperty("dateType") String dateType){ | ||
formatter = DateTimeFormat.forPattern(formatString); | ||
this.dateType = dateType; | ||
|
||
} | ||
|
||
@Override | ||
public String get(File file) { | ||
String prefix = formatter.print(getDateCreated(file));//use dateCreated as default. | ||
if("lastModify".equalsIgnoreCase(dateType)){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
prefix = formatter.print(file.lastModified()); | ||
} | ||
if(!prefix.endsWith("/")) prefix += "/"; | ||
return prefix; | ||
} | ||
|
||
private DateTime getDateCreated(File file){ | ||
return FileNameFormatter.getFileCreateTime(file); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is P20141006T213521 hardcoded? This might need more explanation or comments.
I guess because of
private static DateTimeFormatter fmt = DateTimeFormat.forPattern("'P'yyyyMMdd'T'HHmmss");
could you add comments?