Class ListHDFS

java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.hadoop.AbstractHadoopProcessor
org.apache.nifi.processors.hadoop.ListHDFS
All Implemented Interfaces:
org.apache.nifi.components.ClassloaderIsolationKeyProvider, org.apache.nifi.components.ConfigurableComponent, org.apache.nifi.processor.Processor

@PrimaryNodeOnly @TriggerSerially @TriggerWhenEmpty @InputRequirement(INPUT_FORBIDDEN) @Tags({"hadoop","HCFS","HDFS","get","list","ingest","source","filesystem"}) @SeeAlso({GetHDFS.class,FetchHDFS.class,PutHDFS.class}) @CapabilityDescription("Retrieves a listing of files from HDFS. For each file that is listed in HDFS, this processor creates a FlowFile that represents the HDFS file to be fetched in conjunction with FetchHDFS. This Processor is designed to run on Primary Node only in a cluster. If the primary node changes, the new Primary Node will pick up where the previous node left off without duplicating all of the data. Unlike GetHDFS, this Processor does not delete any data from HDFS.") @WritesAttribute(attribute="filename",description="The name of the file that was read from HDFS.") @WritesAttribute(attribute="path",description="The path is set to the absolute path of the file\'s directory on HDFS. For example, if the Directory property is set to /tmp, then files picked up from /tmp will have the path attribute set to \"./\". If the Recurse Subdirectories property is set to true and a file is picked up from /tmp/abc/1/2/3, then the path attribute will be set to \"/tmp/abc/1/2/3\".") @WritesAttribute(attribute="hdfs.owner",description="The user that owns the file in HDFS") @WritesAttribute(attribute="hdfs.group",description="The group that owns the file in HDFS") @WritesAttribute(attribute="hdfs.lastModified",description="The timestamp of when the file in HDFS was last modified, as milliseconds since midnight Jan 1, 1970 UTC") @WritesAttribute(attribute="hdfs.length",description="The number of bytes in the file in HDFS") @WritesAttribute(attribute="hdfs.replication",description="The number of HDFS replicas for hte file") @WritesAttribute(attribute="hdfs.permissions",description="The permissions for the file in HDFS. This is formatted as 3 characters for the owner, 3 for the group, and 3 for other users. For example rw-rw-r--") @Stateful(scopes=CLUSTER, description="After performing a listing of HDFS files, the latest timestamp of all the files listed is stored. This allows the Processor to list only files that have been added or modified after this date the next time that the Processor is run, without having to store all of the actual filenames/paths which could lead to performance problems. State is stored across the cluster so that this Processor can be run on Primary Node only and if a new Primary Node is selected, the new node can pick up where the previous node left off, without duplicating the data.") @DefaultSchedule(strategy=TIMER_DRIVEN, period="1 min") public class ListHDFS extends AbstractHadoopProcessor
  • Field Details

    • NON_HIDDEN_FILES_REGEX

      private static final String NON_HIDDEN_FILES_REGEX
      See Also:
    • HDFS_ATTRIBUTE_PREFIX

      private static final String HDFS_ATTRIBUTE_PREFIX
      See Also:
    • RECURSE_SUBDIRS

      public static final org.apache.nifi.components.PropertyDescriptor RECURSE_SUBDIRS
    • RECORD_WRITER

      public static final org.apache.nifi.components.PropertyDescriptor RECORD_WRITER
    • FILE_FILTER

      public static final org.apache.nifi.components.PropertyDescriptor FILE_FILTER
    • FILE_FILTER_MODE

      public static final org.apache.nifi.components.PropertyDescriptor FILE_FILTER_MODE
    • MINIMUM_FILE_AGE

      public static final org.apache.nifi.components.PropertyDescriptor MINIMUM_FILE_AGE
    • MAXIMUM_FILE_AGE

      public static final org.apache.nifi.components.PropertyDescriptor MAXIMUM_FILE_AGE
    • REL_SUCCESS

      public static final org.apache.nifi.processor.Relationship REL_SUCCESS
    • LEGACY_EMITTED_TIMESTAMP_KEY

      public static final String LEGACY_EMITTED_TIMESTAMP_KEY
      See Also:
    • LEGACY_LISTING_TIMESTAMP_KEY

      public static final String LEGACY_LISTING_TIMESTAMP_KEY
      See Also:
    • LATEST_TIMESTAMP_KEY

      public static final String LATEST_TIMESTAMP_KEY
      See Also:
    • LATEST_FILES_KEY

      public static final String LATEST_FILES_KEY
      See Also:
    • PROPERTY_DESCRIPTORS

      private static final List<org.apache.nifi.components.PropertyDescriptor> PROPERTY_DESCRIPTORS
    • RELATIONSHIPS

      private static final Set<org.apache.nifi.processor.Relationship> RELATIONSHIPS
    • fileFilterRegexPattern

      private Pattern fileFilterRegexPattern
    • resetState

      private volatile boolean resetState
  • Constructor Details

    • ListHDFS

      public ListHDFS()
  • Method Details

    • preProcessConfiguration

      protected void preProcessConfiguration(org.apache.hadoop.conf.Configuration config, org.apache.nifi.processor.ProcessContext context)
      Overrides:
      preProcessConfiguration in class AbstractHadoopProcessor
    • getSupportedPropertyDescriptors

      protected List<org.apache.nifi.components.PropertyDescriptor> getSupportedPropertyDescriptors()
      Overrides:
      getSupportedPropertyDescriptors in class AbstractHadoopProcessor
    • getRelationships

      public Set<org.apache.nifi.processor.Relationship> getRelationships()
      Specified by:
      getRelationships in interface org.apache.nifi.processor.Processor
      Overrides:
      getRelationships in class org.apache.nifi.processor.AbstractSessionFactoryProcessor
    • customValidate

      protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext context)
      Overrides:
      customValidate in class AbstractHadoopProcessor
    • onPropertyModified

      public void onPropertyModified(org.apache.nifi.components.PropertyDescriptor descriptor, String oldValue, String newValue)
      Specified by:
      onPropertyModified in interface org.apache.nifi.components.ConfigurableComponent
      Overrides:
      onPropertyModified in class org.apache.nifi.components.AbstractConfigurableComponent
    • resetStateIfNecessary

      @OnScheduled public void resetStateIfNecessary(org.apache.nifi.processor.ProcessContext context) throws IOException
      Throws:
      IOException
    • onTrigger

      public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) throws org.apache.nifi.processor.exception.ProcessException
      Specified by:
      onTrigger in class org.apache.nifi.processor.AbstractProcessor
      Throws:
      org.apache.nifi.processor.exception.ProcessException
    • createPathFilter

      private org.apache.hadoop.fs.PathFilter createPathFilter(org.apache.nifi.processor.ProcessContext context)
    • getPathSegmentsToSkip

      private int getPathSegmentsToSkip(boolean recursive)
    • updateState

      private void updateState(org.apache.nifi.processor.ProcessSession session, Map<String,String> newState)
    • getSuccessRelationship

      protected org.apache.nifi.processor.Relationship getSuccessRelationship()
    • getAttributePrefix

      protected String getAttributePrefix()