@EventDriven @SideEffectFree @SupportsBatching @InputRequirement(value=INPUT_REQUIRED) @WritesAttribute(attribute="mime.type",description="Sets the mime.type attribute to the MIME Type specified by the Record Writer") @WritesAttribute(attribute="record.count",description="The number of records in the FlowFile") @Tags(value={"lookup","enrichment","route","record","csv","json","avro","database","db","logs","convert","filter"}) @CapabilityDescription(value="Extracts one or more fields from a Record and looks up a value for those fields in a LookupService. If a result is returned by the LookupService, that result is optionally added to the Record. In this case, the processor functions as an Enrichment processor. Regardless, the Record is then routed to either the \'matched\' relationship or \'unmatched\' relationship (if the \'Routing Strategy\' property is configured to do so), indicating whether or not a result was returned by the LookupService, allowing the processor to also function as a Routing processor. The \"coordinates\" to use for looking up a value in the Lookup Service are defined by adding a user-defined property. Each property that is added will have an entry added to a Map, where the name of the property becomes the Map Key and the value returned by the RecordPath becomes the value for that key. If multiple values are returned by the RecordPath, then the Record will be routed to the \'unmatched\' relationship (or \'success\', depending on the \'Routing Strategy\' property\'s configuration). If one or more fields match the Result RecordPath, all fields that match will be updated. If there is no match in the configured LookupService, then no fields will be updated. I.e., it will not overwrite an existing value in the Record with a null value. Please note, however, that if the results returned by the LookupService are not accounted for in your schema (specifically, the schema that is configured for your Record Writer) then the fields will not be written out to the FlowFile.") @DynamicProperty(name="Value To Lookup", value="Valid Record Path", expressionLanguageScope=FLOWFILE_ATTRIBUTES, description="A RecordPath that points to the field whose value will be looked up in the configured Lookup Service") @SeeAlso(value={ConvertRecord.class,SplitRecord.class}, classNames={"org.apache.nifi.lookup.SimpleKeyValueLookupService","org.apache.nifi.lookup.maxmind.IPLookupService","org.apache.nifi.lookup.db.DatabaseRecordLookupService"}) public class LookupRecord extends AbstractProcessor
| Modifier and Type | Class and Description |
|---|---|
private class |
LookupRecord.InPlaceReplacementStrategy |
private static class |
LookupRecord.LookupContext |
private class |
LookupRecord.RecordPathReplacementStrategy |
private static interface |
LookupRecord.ReplacementStrategy |
| Constructor and Description |
|---|
LookupRecord() |
| Modifier and Type | Method and Description |
|---|---|
protected LookupRecord.LookupContext |
createLookupContext(FlowFile flowFile,
ProcessContext context,
ProcessSession session,
RecordSetWriterFactory writerFactory) |
private LookupRecord.ReplacementStrategy |
createReplacementStrategy(ProcessContext context) |
protected Collection<ValidationResult> |
customValidate(ValidationContext validationContext) |
Set<Relationship> |
getRelationships() |
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
void |
onPropertyModified(PropertyDescriptor descriptor,
String oldValue,
String newValue) |
void |
onScheduled(ProcessContext context) |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueequals, getPropertyDescriptor, getPropertyDescriptors, hashCode, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitisStatefulgetPropertyDescriptor, getPropertyDescriptors, validateprivate final RecordPathCache recordPathCache
private volatile LookupService<?> lookupService
static final AllowableValue ROUTE_TO_SUCCESS
static final AllowableValue ROUTE_TO_MATCHED_UNMATCHED
static final AllowableValue RESULT_ENTIRE_RECORD
static final AllowableValue RESULT_RECORD_FIELDS
static final AllowableValue USE_PROPERTY
static final AllowableValue REPLACE_EXISTING_VALUES
static final PropertyDescriptor RECORD_READER
static final PropertyDescriptor RECORD_WRITER
static final PropertyDescriptor LOOKUP_SERVICE
static final PropertyDescriptor RESULT_RECORD_PATH
static final PropertyDescriptor RESULT_CONTENTS
static final PropertyDescriptor ROUTING_STRATEGY
static final PropertyDescriptor REPLACEMENT_STRATEGY
static final PropertyDescriptor CACHE_SIZE
static final Relationship REL_MATCHED
static final Relationship REL_UNMATCHED
static final Relationship REL_SUCCESS
static final Relationship REL_FAILURE
private static final Set<Relationship> MATCHED_COLLECTION
private static final Set<Relationship> UNMATCHED_COLLECTION
private static final Set<Relationship> SUCCESS_COLLECTION
private volatile Set<Relationship> relationships
private volatile boolean routeToMatchedUnmatched
@OnScheduled public void onScheduled(ProcessContext context)
public Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorprotected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentprotected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
getSupportedDynamicPropertyDescriptor in class AbstractConfigurableComponentprotected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate in class AbstractConfigurableComponentpublic void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
onPropertyModified in interface ConfigurableComponentonPropertyModified in class AbstractConfigurableComponentpublic void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException
onTrigger in class AbstractProcessorProcessExceptionprivate LookupRecord.ReplacementStrategy createReplacementStrategy(ProcessContext context)
protected LookupRecord.LookupContext createLookupContext(FlowFile flowFile, ProcessContext context, ProcessSession session, RecordSetWriterFactory writerFactory)
Copyright © 2023 Apache NiFi Project. All rights reserved.