Class ListFile
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processor.util.list.AbstractListProcessor<FileInfo>
org.apache.nifi.processors.standard.ListFile
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent,org.apache.nifi.processor.Processor,org.apache.nifi.processor.VerifiableProcessor
@TriggerSerially
@InputRequirement(INPUT_FORBIDDEN)
@Tags({"file","get","list","ingest","source","filesystem"})
@CapabilityDescription("Retrieves a listing of files from the input directory. For each file listed, creates a FlowFile that represents the file so that it can be fetched in conjunction with FetchFile. This Processor is designed to run on Primary Node only in a cluster when \'Input Directory Location\' is set to \'Remote\'. If the primary node changes, the new Primary Node will pick up where the previous node left off without duplicating all the data. When \'Input Directory Location\' is \'Local\', the \'Execution\' mode can be anything, and synchronization won\'t happen. Unlike GetFile, this Processor does not delete any data from the local filesystem.")
@WritesAttribute(attribute="filename",description="The name of the file that was read from filesystem.") @WritesAttribute(attribute="path",description="The path is set to the relative path of the file\'s directory on filesystem compared to the Input Directory property. For example, if Input Directory 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 \"abc/1/2/3/\".") @WritesAttribute(attribute="absolute.path",description="The absolute.path is set to the absolute path of the file\'s directory on filesystem. For example, if the Input Directory property is set to /tmp, then files picked up from /tmp will have the path attribute set to \"/tmp/\". 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="file.owner",description="The user that owns the file in filesystem") @WritesAttribute(attribute="file.group",description="The group that owns the file in filesystem") @WritesAttribute(attribute="file.size",description="The number of bytes in the file in filesystem") @WritesAttribute(attribute="file.permissions",description="The permissions for the file in filesystem. This is formatted as 3 characters for the owner, 3 for the group, and 3 for other users. For example rw-rw-r--") @WritesAttribute(attribute="file.lastModifiedTime",description="The timestamp of when the file in filesystem was last modified as \'yyyy-MM-dd\'T\'HH:mm:ssZ\'") @WritesAttribute(attribute="file.lastAccessTime",description="The timestamp of when the file in filesystem was last accessed as \'yyyy-MM-dd\'T\'HH:mm:ssZ\'") @WritesAttribute(attribute="file.creationTime",description="The timestamp of when the file in filesystem was created as \'yyyy-MM-dd\'T\'HH:mm:ssZ\'")
@SeeAlso({GetFile.class,PutFile.class,FetchFile.class})
@Stateful(scopes={LOCAL,CLUSTER},
description="After performing a listing of files, the timestamp of the newest file 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. Whether the state is stored with a Local or Cluster scope depends on the value of the <Input Directory Location> property.")
@DefaultSchedule(strategy=TIMER_DRIVEN,
period="1 min")
public class ListFile
extends AbstractListProcessor<FileInfo>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enum(package private) static class(package private) static interface(package private) static interfacePerformanceTracker is responsible for providing a mechanism by which any disk operation can be timed and the timing information can both be used to issue warnings as well as be aggregated for some amount of time, in order to understand how long certain disk operations take and which files may be responsible for causing longer-than-usual operations to be performed.private static classstatic final classTracks metrics using a rolling window of time, in which older metrics are 'aged off' by callingListFile.RollingMetricPerformanceTracker.purgeTimingInfo(long).private static classprivate static classprivate static classProvides a mechanism for timing how long a particular operation takes to complete, logging if it takes longer than the configured threshold.static classA PerformanceTracker that is capable of tracking which disk access operation is active and which directory is actively being listed, as well as timing specific operations, but does not track metrics over any amount of time.Nested classes/interfaces inherited from class org.apache.nifi.processor.util.list.AbstractListProcessor
AbstractListProcessor.ListingMode -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final DateTimeFormatterstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorprivate boolean(package private) static final org.apache.nifi.components.AllowableValue(package private) static final org.apache.nifi.components.AllowableValuestatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorprivate Future<?> private ScheduledExecutorServicestatic final org.apache.nifi.components.PropertyDescriptorprivate longprivate ListFile.PerformanceTrackerprivate static final List<org.apache.nifi.components.PropertyDescriptor> static final org.apache.nifi.components.PropertyDescriptorprivate static final Set<org.apache.nifi.processor.Relationship> static final org.apache.nifi.components.PropertyDescriptorFields inherited from class org.apache.nifi.processor.util.list.AbstractListProcessor
BY_ENTITIES, BY_TIME_WINDOW, BY_TIMESTAMPS, LISTING_LAG_MILLIS, LISTING_STRATEGY, NO_TRACKING, PRECISION_AUTO_DETECT, PRECISION_MILLIS, PRECISION_MINUTES, PRECISION_SECONDS, RECORD_WRITER, REL_SUCCESS, TARGET_SYSTEM_TIMESTAMP_PRECISION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected IntegercountUnfilteredListing(org.apache.nifi.processor.ProcessContext context) createAttributes(FileInfo fileInfo, org.apache.nifi.processor.ProcessContext context) private BiPredicate<Path, BasicFileAttributes> createFileFilter(org.apache.nifi.processor.ProcessContext context, ListFile.PerformanceTracker performanceTracker, boolean applyFilters, Path basePath) private StringformatDateTime(long dateTime) protected StringgetListingContainerName(org.apache.nifi.processor.ProcessContext context) protected StringgetPath(org.apache.nifi.processor.ProcessContext context) protected ListFile.PerformanceTrackerprotected RecordSchemaSet<org.apache.nifi.processor.Relationship> protected org.apache.nifi.components.state.ScopegetStateScope(org.apache.nifi.context.PropertyContext context) protected List<org.apache.nifi.components.PropertyDescriptor> protected voidinit(org.apache.nifi.processor.ProcessorInitializationContext context) protected booleanisListingResetNecessary(org.apache.nifi.components.PropertyDescriptor property) voidvoidonScheduled(org.apache.nifi.processor.ProcessContext context) voidonStopped(org.apache.nifi.processor.ProcessContext context) performListing(org.apache.nifi.processor.ProcessContext context, Long minTimestamp, AbstractListProcessor.ListingMode listingMode) performListing(org.apache.nifi.processor.ProcessContext context, Long minTimestamp, AbstractListProcessor.ListingMode listingMode, boolean applyFilters) Methods inherited from class org.apache.nifi.processor.util.list.AbstractListProcessor
createListedEntityTracker, customValidate, customValidate, getCurrentNanoTime, getCurrentTime, getDefaultTimePrecision, getKey, initListedEntityTracker, listByNoTracking, listByTimeWindow, listByTrackingTimestamps, migrateProperties, onPrimaryNodeChange, onPropertyModified, onTrigger, updateState, verifyMethods inherited from class org.apache.nifi.processor.AbstractProcessor
onTriggerMethods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueMethods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.nifi.components.ConfigurableComponent
getPropertyDescriptor, getPropertyDescriptors, validateMethods inherited from interface org.apache.nifi.processor.Processor
isStateful, migrateRelationships
-
Field Details
-
LOCATION_LOCAL
static final org.apache.nifi.components.AllowableValue LOCATION_LOCAL -
LOCATION_REMOTE
static final org.apache.nifi.components.AllowableValue LOCATION_REMOTE -
DIRECTORY
public static final org.apache.nifi.components.PropertyDescriptor DIRECTORY -
RECURSE
public static final org.apache.nifi.components.PropertyDescriptor RECURSE -
DIRECTORY_LOCATION
public static final org.apache.nifi.components.PropertyDescriptor DIRECTORY_LOCATION -
FILE_FILTER
public static final org.apache.nifi.components.PropertyDescriptor FILE_FILTER -
PATH_FILTER
public static final org.apache.nifi.components.PropertyDescriptor PATH_FILTER -
INCLUDE_FILE_ATTRIBUTES
public static final org.apache.nifi.components.PropertyDescriptor INCLUDE_FILE_ATTRIBUTES -
MIN_AGE
public static final org.apache.nifi.components.PropertyDescriptor MIN_AGE -
MAX_AGE
public static final org.apache.nifi.components.PropertyDescriptor MAX_AGE -
MIN_SIZE
public static final org.apache.nifi.components.PropertyDescriptor MIN_SIZE -
MAX_SIZE
public static final org.apache.nifi.components.PropertyDescriptor MAX_SIZE -
IGNORE_HIDDEN_FILES
public static final org.apache.nifi.components.PropertyDescriptor IGNORE_HIDDEN_FILES -
TRACK_PERFORMANCE
public static final org.apache.nifi.components.PropertyDescriptor TRACK_PERFORMANCE -
MAX_TRACKED_FILES
public static final org.apache.nifi.components.PropertyDescriptor MAX_TRACKED_FILES -
MAX_DISK_OPERATION_TIME
public static final org.apache.nifi.components.PropertyDescriptor MAX_DISK_OPERATION_TIME -
MAX_LISTING_TIME
public static final org.apache.nifi.components.PropertyDescriptor MAX_LISTING_TIME -
PROPERTY_DESCRIPTORS
-
RELATIONSHIPS
-
monitoringThreadPool
-
monitoringFuture
-
includeFileAttributes
private volatile boolean includeFileAttributes -
performanceTracker
-
performanceLoggingTimestamp
private volatile long performanceLoggingTimestamp -
FILE_CREATION_TIME_ATTRIBUTE
- See Also:
-
FILE_LAST_MODIFY_TIME_ATTRIBUTE
- See Also:
-
FILE_LAST_ACCESS_TIME_ATTRIBUTE
- See Also:
-
FILE_SIZE_ATTRIBUTE
- See Also:
-
FILE_OWNER_ATTRIBUTE
- See Also:
-
FILE_GROUP_ATTRIBUTE
- See Also:
-
FILE_PERMISSIONS_ATTRIBUTE
- See Also:
-
FILE_MODIFY_DATE_ATTR_FORMAT
- See Also:
-
DATE_TIME_FORMATTER
-
-
Constructor Details
-
ListFile
public ListFile()
-
-
Method Details
-
init
protected void init(org.apache.nifi.processor.ProcessorInitializationContext context) - Overrides:
initin classorg.apache.nifi.processor.AbstractSessionFactoryProcessor
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptorsin classorg.apache.nifi.components.AbstractConfigurableComponent
-
getRelationships
- Specified by:
getRelationshipsin interfaceorg.apache.nifi.processor.Processor- Overrides:
getRelationshipsin classAbstractListProcessor<FileInfo>
-
onScheduled
@OnScheduled public void onScheduled(org.apache.nifi.processor.ProcessContext context) -
onStopped
@OnStopped public void onStopped(org.apache.nifi.processor.ProcessContext context) -
getPerformanceTracker
-
logPerformance
public void logPerformance() -
createAttributes
protected Map<String,String> createAttributes(FileInfo fileInfo, org.apache.nifi.processor.ProcessContext context) - Specified by:
createAttributesin classAbstractListProcessor<FileInfo>
-
getPath
- Specified by:
getPathin classAbstractListProcessor<FileInfo>
-
getStateScope
protected org.apache.nifi.components.state.Scope getStateScope(org.apache.nifi.context.PropertyContext context) - Specified by:
getStateScopein classAbstractListProcessor<FileInfo>
-
getRecordSchema
- Specified by:
getRecordSchemain classAbstractListProcessor<FileInfo>
-
countUnfilteredListing
protected Integer countUnfilteredListing(org.apache.nifi.processor.ProcessContext context) throws IOException - Specified by:
countUnfilteredListingin classAbstractListProcessor<FileInfo>- Throws:
IOException
-
performListing
protected List<FileInfo> performListing(org.apache.nifi.processor.ProcessContext context, Long minTimestamp, AbstractListProcessor.ListingMode listingMode) throws IOException - Specified by:
performListingin classAbstractListProcessor<FileInfo>- Throws:
IOException
-
performListing
private List<FileInfo> performListing(org.apache.nifi.processor.ProcessContext context, Long minTimestamp, AbstractListProcessor.ListingMode listingMode, boolean applyFilters) throws IOException - Throws:
IOException
-
getListingContainerName
- Specified by:
getListingContainerNamein classAbstractListProcessor<FileInfo>
-
isListingResetNecessary
protected boolean isListingResetNecessary(org.apache.nifi.components.PropertyDescriptor property) - Specified by:
isListingResetNecessaryin classAbstractListProcessor<FileInfo>
-
formatDateTime
-
createFileFilter
private BiPredicate<Path,BasicFileAttributes> createFileFilter(org.apache.nifi.processor.ProcessContext context, ListFile.PerformanceTracker performanceTracker, boolean applyFilters, Path basePath)
-