Class Put<FC,C extends AutoCloseable>
java.lang.Object
org.apache.nifi.processor.util.pattern.Put<FC,C>
- Type Parameters:
FC- Class of context instance which is passed to each partial functions. Lifetime of an function context should be limited for a single onTrigger method.C- Class of connection to a data storage that this pattern puts data into.
- Direct Known Subclasses:
PutGroup
Abstract Put pattern class with a generic onTrigger method structure, composed with various partial functions.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PartialFunctions.AdjustFailedprotected PartialFunctions.AdjustRoute<FC> protected PartialFunctions.Cleanup<FC, C> protected PartialFunctions.FetchFlowFiles<FC> protected PartialFunctions.InitConnection<FC, C> protected org.apache.nifi.logging.ComponentLogprotected PartialFunctions.OnCompleted<FC, C> protected PartialFunctions.OnFailed<FC, C> protected Put.PutFlowFile<FC, C> protected PartialFunctions.TransferFlowFiles<FC> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSpecify an optional function that adjust if the result is failed before we call the onFailed or onCompleted function.voidSpecify an optional function that adjust routed FlowFiles before transfer it.voidSpecify an optional function which will be called in a finally block.voidSpecify an optional function that fetches incoming FlowFIles.voidSpecify a function that establishes a connection to target data storage.voidSpecify an optional function which will be called if input FlowFiles were successfully put to a target storage.voidSpecify an optional function which will be called if input FlowFiles failed being put to a target storage.voidonTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, FC functionContext) Processor using this pattern is expected to call this method from its onTrigger.voidSpecify a function that puts an incoming FlowFile to target data storage.protected voidputFlowFiles(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, FC functionContext, C connection, List<org.apache.nifi.flowfile.FlowFile> flowFiles, RoutingResult result) Put fetched FlowFiles to a data storage.voidsetLogger(org.apache.nifi.logging.ComponentLog logger) voidSpecify an optional function responsible for transferring routed FlowFiles.protected void
-
Field Details
-
initConnection
-
fetchFlowFiles
-
putFlowFile
-
transferFlowFiles
-
adjustRoute
-
onCompleted
-
onFailed
-
cleanup
-
adjustFailed
-
logger
protected org.apache.nifi.logging.ComponentLog logger
-
-
Constructor Details
-
Put
public Put()
-
-
Method Details
-
putFlowFiles
protected void putFlowFiles(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, FC functionContext, C connection, List<org.apache.nifi.flowfile.FlowFile> flowFiles, RoutingResult result) throws org.apache.nifi.processor.exception.ProcessException Put fetched FlowFiles to a data storage.- Parameters:
context- process context passed from a Processor onTrigger.session- process session passed from a Processor onTrigger.functionContext- function context passed from a Processor onTrigger.connection- connection to data storage, established byPartialFunctions.InitConnection.flowFiles- FlowFiles fetched fromPartialFunctions.FetchFlowFiles.result- Route incoming FlowFiles if necessary.- Throws:
org.apache.nifi.processor.exception.ProcessException
-
validateCompositePattern
protected void validateCompositePattern() -
onTrigger
public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, FC functionContext) throws org.apache.nifi.processor.exception.ProcessException Processor using this pattern is expected to call this method from its onTrigger.
Typical usage would be constructing a process pattern instance at a processor method which is annotated with
OnScheduled, and use pattern.onTrigger from processor.onTrigger.PartialFunctions.InitConnectionis required at least. In addition to any functions required by an implementation class.- Parameters:
context- process context passed from a Processor onTrigger.session- process session passed from a Processor onTrigger.functionContext- function context should be instantiated per onTrigger call.- Throws:
org.apache.nifi.processor.exception.ProcessException- Each partial function can throw ProcessException if onTrigger should stop immediately.
-
fetchFlowFiles
Specify an optional function that fetches incoming FlowFIles. If not specified, single FlowFile is fetched on each onTrigger.- Parameters:
f- Function to fetch incoming FlowFiles.
-
initConnection
Specify a function that establishes a connection to target data storage. This function will be called when there is valid incoming FlowFiles. The created connection instance is automatically closed when onTrigger is finished.- Parameters:
f- Function to initiate a connection to a data storage.
-
putFlowFile
Specify a function that puts an incoming FlowFile to target data storage.- Parameters:
f- a function to put a FlowFile to target storage.
-
adjustRoute
Specify an optional function that adjust routed FlowFiles before transfer it.- Parameters:
f- a function to adjust route.
-
adjustFailed
Specify an optional function that adjust if the result is failed before we call the onFailed or onCompleted function. If the result is failed, return true and do sth.- Parameters:
f- Function to be called to adjust if the result is failed
-
transferFlowFiles
Specify an optional function responsible for transferring routed FlowFiles. If not specified routed FlowFiles are simply transferred to its destination by default.- Parameters:
f- a function to transfer routed FlowFiles.
-
onCompleted
Specify an optional function which will be called if input FlowFiles were successfully put to a target storage.- Parameters:
f- Function to be called when a put operation finishes successfully.
-
onFailed
Specify an optional function which will be called if input FlowFiles failed being put to a target storage.- Parameters:
f- Function to be called when a put operation failed.
-
cleanup
Specify an optional function which will be called in a finally block. Typically useful when a special cleanup operation is needed for the connection.- Parameters:
f- Function to be called when a put operation finished regardless of whether it succeeded or not.
-
setLogger
public void setLogger(org.apache.nifi.logging.ComponentLog logger)
-