Class ValidateRecord

java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.ValidateRecord
All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent, org.apache.nifi.processor.Processor

@SideEffectFree @SupportsBatching @InputRequirement(INPUT_REQUIRED) @Tags({"record","schema","validate"}) @CapabilityDescription("Validates the Records of an incoming FlowFile against a given schema. All records that adhere to the schema are routed to the \"valid\" relationship while records that do not adhere to the schema are routed to the \"invalid\" relationship. It is therefore possible for a single incoming FlowFile to be split into two individual FlowFiles if some records are valid according to the schema and others are not. Any FlowFile that is routed to the \"invalid\" relationship will emit a ROUTE Provenance Event with the Details field populated to explain why records were invalid. In addition, to gain further explanation of why records were invalid, DEBUG-level logging can be enabled for the \"org.apache.nifi.processors.standard.ValidateRecord\" logger.") @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 routed to a relationship") public class ValidateRecord extends org.apache.nifi.processor.AbstractProcessor
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    private static final List<org.apache.nifi.components.PropertyDescriptor>
     
    (package private) static final org.apache.nifi.components.AllowableValue
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.processor.Relationship
     
    (package private) static final org.apache.nifi.processor.Relationship
     
    (package private) static final org.apache.nifi.processor.Relationship
     
    private static final Set<org.apache.nifi.processor.Relationship>
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
     
    private void
    completeFlowFile(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, org.apache.nifi.flowfile.FlowFile flowFile, RecordSetWriter writer, org.apache.nifi.processor.Relationship relationship, String details)
     
    createIfNecessary(RecordSetWriter writer, RecordSetWriterFactory factory, org.apache.nifi.processor.ProcessSession session, org.apache.nifi.flowfile.FlowFile flowFile, RecordSchema outputSchema)
     
    protected Collection<org.apache.nifi.components.ValidationResult>
    customValidate(org.apache.nifi.components.ValidationContext validationContext)
     
    Set<org.apache.nifi.processor.Relationship>
     
    protected List<org.apache.nifi.components.PropertyDescriptor>
     
    protected RecordSchema
    getValidationSchema(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile flowFile, RecordReader reader)
     
    private void
    logValidationErrors(org.apache.nifi.flowfile.FlowFile flowFile, int recordCount, SchemaValidationResult result)
     
    void
     
    void
    onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session)
     
    private void
     

    Methods inherited from class org.apache.nifi.processor.AbstractProcessor

    onTrigger

    Methods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor

    getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue

    Methods inherited from class org.apache.nifi.components.AbstractConfigurableComponent

    equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validate

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.nifi.components.ConfigurableComponent

    getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate

    Methods inherited from interface org.apache.nifi.processor.Processor

    isStateful, migrateRelationships
  • Field Details

    • READER_SCHEMA

      static final org.apache.nifi.components.AllowableValue READER_SCHEMA
    • RECORD_READER

      static final org.apache.nifi.components.PropertyDescriptor RECORD_READER
    • RECORD_WRITER

      static final org.apache.nifi.components.PropertyDescriptor RECORD_WRITER
    • INVALID_RECORD_WRITER

      static final org.apache.nifi.components.PropertyDescriptor INVALID_RECORD_WRITER
    • SCHEMA_ACCESS_STRATEGY

      static final org.apache.nifi.components.PropertyDescriptor SCHEMA_ACCESS_STRATEGY
    • ALLOW_EXTRA_FIELDS

      static final org.apache.nifi.components.PropertyDescriptor ALLOW_EXTRA_FIELDS
    • STRICT_TYPE_CHECKING

      static final org.apache.nifi.components.PropertyDescriptor STRICT_TYPE_CHECKING
    • COERCE_TYPES

      static final org.apache.nifi.components.PropertyDescriptor COERCE_TYPES
    • VALIDATION_DETAILS_ATTRIBUTE_NAME

      static final org.apache.nifi.components.PropertyDescriptor VALIDATION_DETAILS_ATTRIBUTE_NAME
    • MAX_VALIDATION_DETAILS_LENGTH

      static final org.apache.nifi.components.PropertyDescriptor MAX_VALIDATION_DETAILS_LENGTH
    • PROPERTY_DESCRIPTORS

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

      static final org.apache.nifi.processor.Relationship REL_VALID
    • REL_INVALID

      static final org.apache.nifi.processor.Relationship REL_INVALID
    • REL_FAILURE

      static final org.apache.nifi.processor.Relationship REL_FAILURE
    • RELATIONSHIPS

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

    • ValidateRecord

      public ValidateRecord()
  • Method Details

    • getSupportedPropertyDescriptors

      protected List<org.apache.nifi.components.PropertyDescriptor> getSupportedPropertyDescriptors()
      Overrides:
      getSupportedPropertyDescriptors in class org.apache.nifi.components.AbstractConfigurableComponent
    • 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
    • migrateProperties

      public void migrateProperties(PropertyConfiguration config)
    • customValidate

      protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext)
      Overrides:
      customValidate in class org.apache.nifi.components.AbstractConfigurableComponent
    • 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
    • writeRecord

      private void writeRecord(RecordSetWriter writer, Record record) throws IOException
      Throws:
      IOException
    • closeQuietly

      private void closeQuietly(RecordSetWriter writer)
    • completeFlowFile

      private void completeFlowFile(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, org.apache.nifi.flowfile.FlowFile flowFile, RecordSetWriter writer, org.apache.nifi.processor.Relationship relationship, String details) throws IOException
      Throws:
      IOException
    • createIfNecessary

      private RecordSetWriter createIfNecessary(RecordSetWriter writer, RecordSetWriterFactory factory, org.apache.nifi.processor.ProcessSession session, org.apache.nifi.flowfile.FlowFile flowFile, RecordSchema outputSchema) throws SchemaNotFoundException, IOException
      Throws:
      SchemaNotFoundException
      IOException
    • logValidationErrors

      private void logValidationErrors(org.apache.nifi.flowfile.FlowFile flowFile, int recordCount, SchemaValidationResult result)
    • getValidationSchema

      protected RecordSchema getValidationSchema(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile flowFile, RecordReader reader) throws MalformedRecordException, IOException, SchemaNotFoundException
      Throws:
      MalformedRecordException
      IOException
      SchemaNotFoundException