org.apache.storm.hdfs.trident.format
Class DefaultFileNameFormat

java.lang.Object
  extended by org.apache.storm.hdfs.trident.format.DefaultFileNameFormat
All Implemented Interfaces:
Serializable, FileNameFormat

public class DefaultFileNameFormat
extends Object
implements FileNameFormat

Creates file names with the following format:

     {prefix}-{partitionId}-{rotationNum}-{timestamp}{extension}
 
For example:
     MyBolt-5-7-1390579837830.txt
 
By default, prefix is empty and extenstion is ".txt".

See Also:
Serialized Form

Constructor Summary
DefaultFileNameFormat()
           
 
Method Summary
 String getName(long rotation, long timeStamp)
          Returns the filename the HdfsBolt will create.
 String getPath()
           
 void prepare(Map conf, int partitionIndex, int numPartitions)
           
 DefaultFileNameFormat withExtension(String extension)
          Overrides the default file extension.
 DefaultFileNameFormat withPath(String path)
           
 DefaultFileNameFormat withPrefix(String prefix)
          Overrides the default prefix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFileNameFormat

public DefaultFileNameFormat()
Method Detail

withPrefix

public DefaultFileNameFormat withPrefix(String prefix)
Overrides the default prefix.

Parameters:
prefix -
Returns:

withExtension

public DefaultFileNameFormat withExtension(String extension)
Overrides the default file extension.

Parameters:
extension -
Returns:

withPath

public DefaultFileNameFormat withPath(String path)

prepare

public void prepare(Map conf,
                    int partitionIndex,
                    int numPartitions)
Specified by:
prepare in interface FileNameFormat

getName

public String getName(long rotation,
                      long timeStamp)
Description copied from interface: FileNameFormat
Returns the filename the HdfsBolt will create.

Specified by:
getName in interface FileNameFormat
Parameters:
rotation - the current file rotation number (incremented on every rotation)
timeStamp - current time in milliseconds when the rotation occurs
Returns:

getPath

public String getPath()
Specified by:
getPath in interface FileNameFormat


Copyright © 2016 The Apache Software Foundation. All Rights Reserved.