public class DateTimeBucketer extends Object implements Bucketer
Bucketer that assigns to buckets based on current system time.
The DateTimeBucketer will create directories of the following form:
/{basePath}/{dateTimePath}/. The basePath is the path
that was specified as a base path when creating the
RollingSink. The dateTimePath
is determined based on the current system time and the user provided format string.
SimpleDateFormat is used to derive a date string from the current system time and
the date format string. The default format string is "yyyy-MM-dd--HH" so the rolling
files will have a granularity of hours.
Example:
Bucketer buck = new DateTimeBucketer("yyyy-MM-dd--HH");
This will create for example the following bucket path:
/base/1976-12-31-14/| Constructor and Description |
|---|
DateTimeBucketer()
Creates a new
DateTimeBucketer with format string "yyyy-MM-dd--HH". |
DateTimeBucketer(String formatString)
Creates a new
DateTimeBucketer with the given date/time format string. |
| Modifier and Type | Method and Description |
|---|---|
org.apache.hadoop.fs.Path |
getNextBucketPath(org.apache.hadoop.fs.Path basePath)
Returns the
Path of a new bucket file. |
static void |
setClock(Clock newClock)
This sets the internal
Clock implementation. |
boolean |
shouldStartNewBucket(org.apache.hadoop.fs.Path basePath,
org.apache.hadoop.fs.Path currentBucketPath)
Returns
true when a new bucket should be started. |
String |
toString() |
public DateTimeBucketer()
DateTimeBucketer with format string "yyyy-MM-dd--HH".public DateTimeBucketer(String formatString)
DateTimeBucketer with the given date/time format string.formatString - The format string that will be given to SimpleDateFormat to determine
the bucket path.public boolean shouldStartNewBucket(org.apache.hadoop.fs.Path basePath,
org.apache.hadoop.fs.Path currentBucketPath)
Bucketertrue when a new bucket should be started.shouldStartNewBucket in interface BucketercurrentBucketPath - The bucket Path that is currently being used.public org.apache.hadoop.fs.Path getNextBucketPath(org.apache.hadoop.fs.Path basePath)
BucketerPath of a new bucket file.getNextBucketPath in interface BucketerbasePath - The base path containing all the buckets.Path of the new bucket. This should include the basePath
and also the subtaskIndex tp avoid clashes with parallel sinks.Copyright © 2014–2016 The Apache Software Foundation. All rights reserved.