org.apache.storm.hdfs.trident.format

## Class DefaultFileNameFormat

- java.lang.Object
- - 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

    Constructors
    Constructor and Description
    `DefaultFileNameFormat()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getName(long rotation, long timeStamp)` Returns the filename the HdfsBolt will create.
    `String` | `getPath()`
    `void` | `prepare(Map<String,Object> 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.

    - #### withExtension

          public DefaultFileNameFormat withExtension(String extension)

      Overrides the default file extension.

    - #### withPath

          public DefaultFileNameFormat withPath(String path)

    - #### prepare

          public void prepare(Map<String,Object> 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

    - #### getPath

          public String getPath()

      Specified by:
        `getPath` in interface `FileNameFormat`

Copyright © 2021 The Apache Software Foundation. All rights reserved.