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”.
Constructor and Description |
---|
DefaultFileNameFormat() |
Modifier and Type | Method and Description |
---|---|
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.
|
public DefaultFileNameFormat withPrefix(String prefix)
Overrides the default prefix.
prefix
- public DefaultFileNameFormat withExtension(String extension)
Overrides the default file extension.
extension
- public DefaultFileNameFormat withPath(String path)
public void prepare(Map conf, int partitionIndex, int numPartitions)
prepare
in interface FileNameFormat
public String getName(long rotation, long timeStamp)
FileNameFormat
Returns the filename the HdfsBolt will create.
getName
in interface FileNameFormat
rotation
- the current file rotation number (incremented on every rotation)timeStamp
- current time in milliseconds when the rotation occurspublic String getPath()
getPath
in interface FileNameFormat
Copyright © 2022 The Apache Software Foundation. All Rights Reserved.