Class RouteText
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.RouteText
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent,org.apache.nifi.processor.Processor
@SideEffectFree
@SupportsBatching
@InputRequirement(INPUT_REQUIRED)
@Tags({"attributes","routing","text","regexp","regex","Regular Expression","Expression Language","csv","filter","logs","delimited","find","string","search","filter","detect"})
@CapabilityDescription("Routes textual data based on a set of user-defined rules. Each line in an incoming FlowFile is compared against the values specified by user-defined Properties. The mechanism by which the text is compared to these user-defined properties is defined by the \'Matching Strategy\'. The data is then routed according to these rules, routing each line of the text individually.")
@DynamicProperty(name="Relationship Name",
value="value to match against",
description="Routes data that matches the value specified in the Dynamic Property Value to the Relationship specified in the Dynamic Property Key.",
expressionLanguageScope=FLOWFILE_ATTRIBUTES)
@DynamicRelationship(name="Name from Dynamic Property",
description="FlowFiles that match the Dynamic Property\'s value")
@WritesAttribute(attribute="RouteText.Route",description="The name of the relationship to which the FlowFile was routed.") @WritesAttribute(attribute="RouteText.Group",description="The value captured by all capturing groups in the \'Grouping Regular Expression\' property. If this property is not set or contains no capturing groups, this attribute will not be added.")
@UseCase(description="Drop blank or empty lines from the FlowFile\'s content.",keywords={"filter","drop","empty","blank","remove","delete","strip out","lines","text"},configuration="\"Routing Strategy\" = \"Route to each matching Property Name\"\n\"Matching Strategy\" = \"Matches Regular Expression\"\n\"Empty Line\" = \"^$\"\n\nAuto-terminate the \"Empty Line\" relationship.\nConnect the \"unmatched\" relationship to the next processor in your flow.\n") @UseCase(description="Remove specific lines of text from a file, such as those containing a specific word or having a line length over some threshold.",keywords={"filter","drop","empty","blank","remove","delete","strip out","lines","text","expression language"},configuration="\"Routing Strategy\" = \"Route to each matching Property Name\"\n\"Matching Strategy\" = \"Satisfies Expression\"\n\nAn additional property should be added named \"Filter Out.\" The value should be a NiFi Expression Language Expression that can refer to two variables (in addition to FlowFile attributes): `line`, which is the line of text being evaluated; and `lineNo`, which is the line number in the file (starting with 1). The Expression should return `true` for any line that should be dropped.\n\nFor example, to remove any line that starts with a # symbol, we can set \"Filter Out\" to `${line:startsWith(\"#\")}`.\nWe could also remove the first 2 lines of text by setting \"Filter Out\" to `${lineNo:le(2)}`. Note that we use the `le` function because we want lines numbers less than or equal to `2`, since the line index is 1-based.\n\nAuto-terminate the \"Filter Out\" relationship.\nConnect the \"unmatched\" relationship to the next processor in your flow.\n")
public class RouteText
extends org.apache.nifi.processor.AbstractProcessor
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.nifi.components.PropertyDescriptorprivate Stringstatic final org.apache.nifi.components.AllowableValuestatic final org.apache.nifi.components.AllowableValueprivate static final Stringprivate static final Stringprivate static final RouteText.Groupstatic final org.apache.nifi.components.AllowableValueprivate static final Stringstatic final org.apache.nifi.components.AllowableValueprivate static final Stringstatic final String(package private) static final org.apache.nifi.components.PropertyDescriptorprivate Pattern(package private) static final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.AllowableValueprivate static final String(package private) static final int(package private) final ConcurrentMap<String, Pattern> LRU cache for the compiled patterns.private static final List<org.apache.nifi.components.PropertyDescriptor> private Map<org.apache.nifi.processor.Relationship, org.apache.nifi.components.PropertyValue> Cache of dynamic properties set duringonScheduled(ProcessContext)for quick access inonTrigger(ProcessContext, ProcessSession)static final org.apache.nifi.processor.Relationshipstatic final org.apache.nifi.processor.Relationshipstatic final org.apache.nifi.processor.Relationshipprivate final AtomicReference<Set<org.apache.nifi.processor.Relationship>> static final Stringstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.AllowableValuestatic final org.apache.nifi.components.AllowableValuestatic final org.apache.nifi.components.AllowableValueprivate static final Stringprivate static final Stringprivate static final Stringstatic final org.apache.nifi.components.AllowableValueprivate static final Stringstatic final org.apache.nifi.components.AllowableValueprivate static final Stringstatic final org.apache.nifi.components.PropertyDescriptor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidappendLine(org.apache.nifi.processor.ProcessSession session, Map<org.apache.nifi.processor.Relationship, Map<RouteText.Group, org.apache.nifi.flowfile.FlowFile>> flowFileMap, org.apache.nifi.processor.Relationship relationship, org.apache.nifi.flowfile.FlowFile original, String line, Charset charset, RouteText.Group group) private PatterncachedCompiledPattern(String regex, boolean ignoreCase) protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext) private RouteText.GroupSet<org.apache.nifi.processor.Relationship> protected org.apache.nifi.components.PropertyDescriptorgetSupportedDynamicPropertyDescriptor(String propertyDescriptorName) protected List<org.apache.nifi.components.PropertyDescriptor> protected static booleanlineMatches(String line, Object comparison, String matchingStrategy, boolean ignoreCase, org.apache.nifi.flowfile.FlowFile flowFile, Map<String, String> variables) voidonPropertyModified(org.apache.nifi.components.PropertyDescriptor descriptor, String oldValue, String newValue) voidonScheduled(org.apache.nifi.processor.ProcessContext context) When this processor is scheduled, update the dynamic properties into the map for quick access during each onTrigger callvoidonTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) Methods inherited from class org.apache.nifi.processor.AbstractProcessor
onTriggerMethods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueMethods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
equals, getPropertyDescriptor, getPropertyDescriptors, 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, migrateProperties, migrateRelationships
-
Field Details
-
ROUTE_ATTRIBUTE_KEY
- See Also:
-
GROUP_ATTRIBUTE_KEY
- See Also:
-
routeAllMatchValue
- See Also:
-
routeAnyMatchValue
- See Also:
-
routePropertyNameValue
- See Also:
-
startsWithValue
- See Also:
-
endsWithValue
- See Also:
-
containsValue
- See Also:
-
equalsValue
- See Also:
-
matchesRegularExpressionValue
- See Also:
-
containsRegularExpressionValue
- See Also:
-
satisfiesExpression
- See Also:
-
ROUTE_TO_MATCHING_PROPERTY_NAME
public static final org.apache.nifi.components.AllowableValue ROUTE_TO_MATCHING_PROPERTY_NAME -
ROUTE_TO_MATCHED_WHEN_ALL_PROPERTIES_MATCH
public static final org.apache.nifi.components.AllowableValue ROUTE_TO_MATCHED_WHEN_ALL_PROPERTIES_MATCH -
ROUTE_TO_MATCHED_WHEN_ANY_PROPERTY_MATCHES
public static final org.apache.nifi.components.AllowableValue ROUTE_TO_MATCHED_WHEN_ANY_PROPERTY_MATCHES -
STARTS_WITH
public static final org.apache.nifi.components.AllowableValue STARTS_WITH -
ENDS_WITH
public static final org.apache.nifi.components.AllowableValue ENDS_WITH -
CONTAINS
public static final org.apache.nifi.components.AllowableValue CONTAINS -
EQUALS
public static final org.apache.nifi.components.AllowableValue EQUALS -
MATCHES_REGULAR_EXPRESSION
public static final org.apache.nifi.components.AllowableValue MATCHES_REGULAR_EXPRESSION -
CONTAINS_REGULAR_EXPRESSION
public static final org.apache.nifi.components.AllowableValue CONTAINS_REGULAR_EXPRESSION -
SATISFIES_EXPRESSION
public static final org.apache.nifi.components.AllowableValue SATISFIES_EXPRESSION -
ROUTE_STRATEGY
public static final org.apache.nifi.components.PropertyDescriptor ROUTE_STRATEGY -
MATCH_STRATEGY
public static final org.apache.nifi.components.PropertyDescriptor MATCH_STRATEGY -
TRIM_WHITESPACE
public static final org.apache.nifi.components.PropertyDescriptor TRIM_WHITESPACE -
IGNORE_CASE
static final org.apache.nifi.components.PropertyDescriptor IGNORE_CASE -
GROUPING_REGEX
static final org.apache.nifi.components.PropertyDescriptor GROUPING_REGEX -
CHARACTER_SET
public static final org.apache.nifi.components.PropertyDescriptor CHARACTER_SET -
PROPERTY_DESCRIPTORS
-
REL_ORIGINAL
public static final org.apache.nifi.processor.Relationship REL_ORIGINAL -
REL_NO_MATCH
public static final org.apache.nifi.processor.Relationship REL_NO_MATCH -
REL_MATCH
public static final org.apache.nifi.processor.Relationship REL_MATCH -
EMPTY_GROUP
-
relationships
-
configuredRouteStrategy
-
dynamicPropertyNames
-
propertyMap
private volatile Map<org.apache.nifi.processor.Relationship,org.apache.nifi.components.PropertyValue> propertyMapCache of dynamic properties set duringonScheduled(ProcessContext)for quick access inonTrigger(ProcessContext, ProcessSession) -
groupingRegex
-
PATTERNS_CACHE_MAXIMUM_ENTRIES
static final int PATTERNS_CACHE_MAXIMUM_ENTRIES- See Also:
-
patternsCache
LRU cache for the compiled patterns. The size of the cache is determined by the value ofPATTERNS_CACHE_MAXIMUM_ENTRIES.
-
-
Constructor Details
-
RouteText
public RouteText()
-
-
Method Details
-
cachedCompiledPattern
-
getRelationships
- Specified by:
getRelationshipsin interfaceorg.apache.nifi.processor.Processor- Overrides:
getRelationshipsin classorg.apache.nifi.processor.AbstractSessionFactoryProcessor
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptorsin classorg.apache.nifi.components.AbstractConfigurableComponent
-
getSupportedDynamicPropertyDescriptor
protected org.apache.nifi.components.PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) - Overrides:
getSupportedDynamicPropertyDescriptorin classorg.apache.nifi.components.AbstractConfigurableComponent
-
onPropertyModified
public void onPropertyModified(org.apache.nifi.components.PropertyDescriptor descriptor, String oldValue, String newValue) - Specified by:
onPropertyModifiedin interfaceorg.apache.nifi.components.ConfigurableComponent- Overrides:
onPropertyModifiedin classorg.apache.nifi.components.AbstractConfigurableComponent
-
onScheduled
@OnScheduled public void onScheduled(org.apache.nifi.processor.ProcessContext context) When this processor is scheduled, update the dynamic properties into the map for quick access during each onTrigger call- Parameters:
context- ProcessContext used to retrieve dynamic properties
-
customValidate
protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext) - Overrides:
customValidatein classorg.apache.nifi.components.AbstractConfigurableComponent
-
onTrigger
public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) - Specified by:
onTriggerin classorg.apache.nifi.processor.AbstractProcessor
-
getGroup
-
appendLine
private void appendLine(org.apache.nifi.processor.ProcessSession session, Map<org.apache.nifi.processor.Relationship, Map<RouteText.Group, org.apache.nifi.flowfile.FlowFile>> flowFileMap, org.apache.nifi.processor.Relationship relationship, org.apache.nifi.flowfile.FlowFile original, String line, Charset charset, RouteText.Group group) -
lineMatches
-