public final class StandardProcessSession extends java.lang.Object implements ProcessSession, ProvenanceEventEnricher
Provides a ProcessSession that ensures all accesses, changes and transfers occur in an atomic manner for all FlowFiles including their contents and attributes
NOT THREAD SAFE
| Modifier and Type | Field and Description | 
|---|---|
| static java.lang.String | DEFAULT_FLOWFILE_PATH | 
| static int | VERBOSE_LOG_THRESHOLD | 
| Constructor and Description | 
|---|
| StandardProcessSession(ProcessContext context) | 
| Modifier and Type | Method and Description | 
|---|---|
| void | adjustCounter(java.lang.String name,
             long delta,
             boolean immediate)Adjusts counter data for the given counter name and takes care of
 registering the counter if not already present. | 
| FlowFile | append(FlowFile source,
      OutputStreamCallback writer)Executes the given callback against the content corresponding to the
 given FlowFile, such that any data written to the OutputStream of the
 content will be appended to the end of FlowFile. | 
| void | checkpoint() | 
| FlowFile | clone(FlowFile example)Creates a new FlowFile that is a clone of the given FlowFile as of the
 time this is called, both in content and attributes. | 
| FlowFile | clone(FlowFile example,
     long offset,
     long size)Creates a new FlowFile whose parent is the given FlowFile. | 
| void | commit()
 Commits the current session ensuring all operations against FlowFiles
 within this session are atomically persisted. | 
| FlowFile | create()Creates a new FlowFile in the repository with no content and without any
 linkage to a parent FlowFile. | 
| FlowFile | create(java.util.Collection<FlowFile> parents)Creates a new FlowFile in the repository with no content but with a
 parent linkage to the FlowFiles specified by the parents Collection. | 
| FlowFile | create(FlowFile parent)Creates a new FlowFile in the repository with no content but with a
 parent linkage to  parent. | 
| StandardProvenanceEventRecord | enrich(ProvenanceEventRecord rawEvent,
      FlowFile flowFile)Returns a new Provenance event that has been updated to contain the original and updated FlowFile attributes and content claim information. | 
| void | expireFlowFiles() | 
| void | exportTo(FlowFile source,
        java.io.OutputStream destination)Writes the content of the given FlowFile to the given destination stream | 
| void | exportTo(FlowFile source,
        java.nio.file.Path destination,
        boolean append)Writes the content of the given FlowFile to the given destination path. | 
| protected void | finalize() | 
| FlowFile | get() | 
| java.util.List<FlowFile> | get(FlowFileFilter filter)
 Returns all FlowFiles from all of the incoming queues for which the given
  FlowFileFilterindicates should be accepted. | 
| java.util.List<FlowFile> | get(int maxResults)Returns up to  maxResultsFlowFiles from the work queue. | 
| ProvenanceReporter | getProvenanceReporter()Returns a ProvenanceReporter that is tied to this ProcessSession. | 
| QueueSize | getQueueSize() | 
| FlowFile | importFrom(java.io.InputStream source,
          FlowFile destination)Writes to the given FlowFile all content from the given content path. | 
| FlowFile | importFrom(java.nio.file.Path source,
          boolean keepSourceFile,
          FlowFile destination)Writes to the given FlowFile all content from the given content path. | 
| FlowFile | merge(java.util.Collection<FlowFile> sources,
     FlowFile destination)Combines the content of all given source FlowFiles into a single given
 destination FlowFile. | 
| FlowFile | merge(java.util.Collection<FlowFile> sources,
     FlowFile destination,
     byte[] header,
     byte[] footer,
     byte[] demarcator)Combines the content of all given source FlowFiles into a single given
 destination FlowFile. | 
| void | migrate(ProcessSession newOwner,
       java.util.Collection<FlowFile> flowFiles)
 Migrates ownership of the given FlowFiles from  thisto the givennewOwner. | 
| FlowFile | penalize(FlowFile flowFile)Sets a penalty for the given FlowFile which will make it unavailable to
 be operated on any further during the penalty period. | 
| FlowFile | putAllAttributes(FlowFile flowFile,
                java.util.Map<java.lang.String,java.lang.String> attributes)Updates the given FlowFiles attributes with the given key/value pairs. | 
| FlowFile | putAttribute(FlowFile flowFile,
            java.lang.String key,
            java.lang.String value)Updates the given FlowFiles attributes with the given key/value pair. | 
| java.io.InputStream | read(FlowFile source)Provides an InputStream that can be used to read the contents of the given FlowFile. | 
| void | read(FlowFile source,
    boolean allowSessionStreamManagement,
    InputStreamCallback reader)Executes the given callback against the contents corresponding to the
 given FlowFile. | 
| void | read(FlowFile source,
    InputStreamCallback reader)Executes the given callback against the contents corresponding to the
 given FlowFile. | 
| void | remove(java.util.Collection<FlowFile> flowFiles)Ends the managed persistence for the given FlowFiles. | 
| void | remove(FlowFile flowFile)Ends the managed persistence for the given FlowFile. | 
| FlowFile | removeAllAttributes(FlowFile flowFile,
                   java.util.regex.Pattern keyPattern)Remove all attributes from the given FlowFile that have keys which match
 the given pattern. | 
| FlowFile | removeAllAttributes(FlowFile flowFile,
                   java.util.Set<java.lang.String> keys)Removes the attributes with the given keys from the given FlowFile. | 
| FlowFile | removeAttribute(FlowFile flowFile,
               java.lang.String key)Removes the given FlowFile attribute with the given key. | 
| void | rollback()Reverts any changes made during this session. | 
| void | rollback(boolean penalize)Reverts any changes made during this session. | 
| java.lang.String | toString() | 
| void | transfer(java.util.Collection<FlowFile> flowFiles)Transfers the given FlowFiles back to the work queues from which the
 FlowFiles were pulled. | 
| void | transfer(java.util.Collection<FlowFile> flowFiles,
        Relationship relationship)Transfers the given FlowFile to the appropriate destination processor
 work queue(s) based on the given relationship. | 
| void | transfer(FlowFile flowFile)Transfers the given FlowFile back to the work queue from which it was
 pulled. | 
| void | transfer(FlowFile flowFile,
        Relationship relationship)Transfers the given FlowFile to the appropriate destination processor
 work queue(s) based on the given relationship. | 
| java.io.OutputStream | write(FlowFile source)Provides an OutputStream that can be used to write to the contents of the
 given FlowFile. | 
| FlowFile | write(FlowFile source,
     OutputStreamCallback writer)Executes the given callback against the content corresponding to the
 given FlowFile. | 
| FlowFile | write(FlowFile source,
     StreamCallback writer)Executes the given callback against the content corresponding to the
 given flow file. | 
public static final int VERBOSE_LOG_THRESHOLD
public static final java.lang.String DEFAULT_FLOWFILE_PATH
public StandardProcessSession(ProcessContext context)
public void checkpoint()
public void commit()
ProcessSessionCommits the current session ensuring all operations against FlowFiles within this session are atomically persisted. All FlowFiles operated on within this session must be accounted for by transfer or removal or the commit will fail.
As soon as the commit completes the session is again ready to be used
commit in interface ProcessSessionpublic StandardProvenanceEventRecord enrich(ProvenanceEventRecord rawEvent, FlowFile flowFile)
ProvenanceEventEnricherenrich in interface ProvenanceEventEnricherrawEvent - recordflowFile - flowfilepublic void rollback()
ProcessSessionProcessSession.rollback(boolean) passing
 false as the parameter.rollback in interface ProcessSessionpublic void rollback(boolean penalize)
ProcessSessionrollback in interface ProcessSessionpenalize - whether or not the FlowFiles that are being restored back
 to their queues should be penalizedpublic void migrate(ProcessSession newOwner, java.util.Collection<FlowFile> flowFiles)
ProcessSession
 Migrates ownership of the given FlowFiles from this to the given newOwner.
 
When calling this method, all of the following pre-conditions must be met:
ProcessSession.write(FlowFile, OutputStreamCallback), ProcessSession.write(FlowFile, StreamCallback),
 ProcessSession.read(FlowFile, InputStreamCallback), ProcessSession.read(FlowFile, boolean, InputStreamCallback) for any of
 the given FlowFiles.ProcessSession.read(FlowFile)).ProcessSession.write(FlowFile).ProcessSession.create(FlowFile) and passing the FlowFile
 as the argument), then all children that were created must also be in the Collection of provided FlowFiles.
 Also note, that if any FlowFile given is not the most up-to-date version of that FlowFile, then the most up-to-date
 version of the FlowFile will be migrated to the new owner. For example, if a call to ProcessSession.putAttribute(FlowFile, String, String) is made,
 passing flowFile1 as the FlowFile, and then flowFile1 is passed to this method, then the newest version (including the
 newly added attribute) will be migrated, not the outdated version of the FlowFile that flowFile1 points to.
 
migrate in interface ProcessSessionnewOwner - the ProcessSession that is to become the new owner of all FlowFiles
            that currently belong to this.flowFiles - the FlowFiles to migratepublic void adjustCounter(java.lang.String name,
                          long delta,
                          boolean immediate)
ProcessSessionadjustCounter in interface ProcessSessionname - the name of the counterdelta - the delta by which to modify the counter (+ or -)immediate - if true, the counter will be updated immediately,
            without regard to whether the ProcessSession is commit or rolled back;
            otherwise, the counter will be incremented only if and when the
            ProcessSession is committed.public FlowFile get()
get in interface ProcessSessionpublic java.util.List<FlowFile> get(int maxResults)
ProcessSessionmaxResults FlowFiles from the work queue. If
 no FlowFiles are available, returns an empty list. Will not return null.
 If multiple incoming queues are present, the behavior is unspecified in
 terms of whether all queues or only a single queue will be polled in a
 single call.get in interface ProcessSessionmaxResults - the maximum number of FlowFiles to returnmaxResults FlowFiles from the work queue. If
 no FlowFiles are available, returns an empty list. Will not return null.public java.util.List<FlowFile> get(FlowFileFilter filter)
ProcessSession
 Returns all FlowFiles from all of the incoming queues for which the given
 FlowFileFilter indicates should be accepted. Calls to this method
 provide exclusive access to the underlying queues. I.e., no other thread
 will be permitted to pull FlowFiles from this Processor's queues or add
 FlowFiles to this Processor's incoming queues until this method call has
 returned.
 
get in interface ProcessSessionfilter - to limit which flow files are returnedFlowFileFilter indicates should be accepted.public QueueSize getQueueSize()
getQueueSize in interface ProcessSessionpublic FlowFile create()
ProcessSessionProcessSession.create(FlowFile) or
 ProcessSession.create(Collection).
 When this method is used, a Provenance CREATE or RECEIVE Event should be
 generated. See the ProcessSession.getProvenanceReporter() method and
 ProvenanceReporter class for more informationcreate in interface ProcessSessionpublic FlowFile clone(FlowFile example)
ProcessSessionclone in interface ProcessSessionexample - FlowFile to be the source of cloning - given FlowFile must
 be a part of the given sessionpublic FlowFile clone(FlowFile example, long offset, long size)
ProcessSessionclone in interface ProcessSessionexample - to base the new flowfile attributes onoffset - of the parent flowfile to base the child flowfile content onsize - of the new flowfile from the offsetpublic FlowFile penalize(FlowFile flowFile)
ProcessSessionpenalize in interface ProcessSessionflowFile - to penalizepublic FlowFile putAttribute(FlowFile flowFile, java.lang.String key, java.lang.String value)
ProcessSessionuuid, this attribute will be ignored.putAttribute in interface ProcessSessionflowFile - to updatekey - of attributevalue - of attributepublic FlowFile putAllAttributes(FlowFile flowFile, java.util.Map<java.lang.String,java.lang.String> attributes)
ProcessSessionuuid, this attribute will be
 ignored.putAllAttributes in interface ProcessSessionflowFile - to updateattributes - the attributes to add to the given FlowFilepublic FlowFile removeAttribute(FlowFile flowFile, java.lang.String key)
ProcessSessionuuid, this method will return the same FlowFile without
 removing any attribute.removeAttribute in interface ProcessSessionflowFile - to updatekey - of attributepublic FlowFile removeAllAttributes(FlowFile flowFile, java.util.Set<java.lang.String> keys)
ProcessSessionuuid, this key will be ignoredremoveAllAttributes in interface ProcessSessionflowFile - to updatekeys - of attributepublic FlowFile removeAllAttributes(FlowFile flowFile, java.util.regex.Pattern keyPattern)
ProcessSessionuuid, this key
 will not be removed.removeAllAttributes in interface ProcessSessionflowFile - to updatekeyPattern - may be null; if supplied is matched against each of the
 FlowFile attribute keyspublic void transfer(FlowFile flowFile, Relationship relationship)
ProcessSessiontransfer in interface ProcessSessionflowFile - to transferrelationship - to transfer topublic void transfer(FlowFile flowFile)
ProcessSessiontransfer in interface ProcessSessionflowFile - to transferpublic void transfer(java.util.Collection<FlowFile> flowFiles)
ProcessSessiontransfer in interface ProcessSessionflowFiles - to transferpublic void transfer(java.util.Collection<FlowFile> flowFiles, Relationship relationship)
ProcessSessiontransfer in interface ProcessSessionflowFiles - to transferrelationship - to transfer topublic void remove(FlowFile flowFile)
ProcessSessionremove in interface ProcessSessionflowFile - to removepublic void remove(java.util.Collection<FlowFile> flowFiles)
ProcessSessionremove in interface ProcessSessionflowFiles - to removepublic void expireFlowFiles()
public void read(FlowFile source, InputStreamCallback reader)
ProcessSessionread in interface ProcessSessionsource - flowfile to retrieve content ofreader - that will be called to read the flowfile contentpublic void read(FlowFile source, boolean allowSessionStreamManagement, InputStreamCallback reader)
ProcessSessionread in interface ProcessSessionsource - flowfile to retrieve content ofallowSessionStreamManagement - allow session to hold the stream open for performance reasonsreader - that will be called to read the flowfile contentpublic java.io.InputStream read(FlowFile source)
ProcessSessionProcessSession.commit() or ProcessSession.rollback()
 is called, but the responsibility of doing so belongs to the caller. The InputStream will throw
 an IOException if an attempt is made to read from the stream after the session is committed or
 rolled back.read in interface ProcessSessionsource - the FlowFile to readpublic FlowFile merge(java.util.Collection<FlowFile> sources, FlowFile destination)
ProcessSessionmerge in interface ProcessSessionsources - the flowfiles to mergedestination - the flowfile to use as the merged resultpublic FlowFile merge(java.util.Collection<FlowFile> sources, FlowFile destination, byte[] header, byte[] footer, byte[] demarcator)
ProcessSessionmerge in interface ProcessSessionsources - to merge togetherdestination - to merge toheader - bytes that will be added to the beginning of the merged
 output. May be null or empty.footer - bytes that will be added to the end of the merged output.
 May be null or empty.demarcator - bytes that will be placed in between each object merged
 together. May be null or empty.public java.io.OutputStream write(FlowFile source)
ProcessSessionwrite in interface ProcessSessionsource - to write topublic FlowFile write(FlowFile source, OutputStreamCallback writer)
ProcessSessionwrite in interface ProcessSessionsource - to write towriter - used to write new contentpublic FlowFile append(FlowFile source, OutputStreamCallback writer)
ProcessSessionappend in interface ProcessSessionsource - the flowfile for which content should be appendedwriter - used to write new bytes to the flowfile contentpublic FlowFile write(FlowFile source, StreamCallback writer)
ProcessSessionwrite in interface ProcessSessionsource - to read from and write towriter - used to read the old content and write new contentpublic FlowFile importFrom(java.nio.file.Path source, boolean keepSourceFile, FlowFile destination)
ProcessSessionimportFrom in interface ProcessSessionsource - the file from which content will be obtainedkeepSourceFile - if true the content is simply copied; if false the
 original content might be used in a destructive way for efficiency such
 that the repository will have the data but the original data will be
 gone. If false the source object will be removed or gone once imported.
 It will not be restored if the session is rolled back so this must be
 used with caution. In some cases it can result in tremendous efficiency
 gains but is also dangerous.destination - the FlowFile whose content will be updatedpublic FlowFile importFrom(java.io.InputStream source, FlowFile destination)
ProcessSessionimportFrom in interface ProcessSessionsource - the file from which content will be obtaineddestination - the FlowFile whose content will be updatedpublic void exportTo(FlowFile source, java.nio.file.Path destination, boolean append)
ProcessSessionexportTo in interface ProcessSessionsource - to export the content ofdestination - to export the content toappend - if true will append to the current content at the given
 path; if false will replace any current contentpublic void exportTo(FlowFile source, java.io.OutputStream destination)
ProcessSessionexportTo in interface ProcessSessionsource - to export the content ofdestination - to export the content topublic FlowFile create(FlowFile parent)
ProcessSessionparent. The newly created FlowFile will
 inherit all of the parent's attributes except for the UUID. This method
 will automatically generate a Provenance FORK event or a Provenance JOIN
 event, depending on whether or not other FlowFiles are generated from the
 same parent before the ProcessSession is committed.create in interface ProcessSessionparent - to base the new flowfile onpublic FlowFile create(java.util.Collection<FlowFile> parents)
ProcessSessioncreate in interface ProcessSessionparents - which the new flowfile should inherit shared attributes fromprotected void finalize()
                 throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic ProvenanceReporter getProvenanceReporter()
ProcessSessiongetProvenanceReporter in interface ProcessSessionpublic java.lang.String toString()
toString in class java.lang.Object