Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfrazee/26deffba3a7d50e991495e223a020b93 to your computer and use it in GitHub Desktop.
Save jfrazee/26deffba3a7d50e991495e223a020b93 to your computer and use it in GitHub Desktop.
LookupAttribute XML PutFile Example
import org.apache.nifi.attribute.expression.language.Query
import org.apache.nifi.attribute.expression.language.PreparedQuery
def flowFile = session.get()
if (!flowFile) return
def attributes = flowFile.getAttributes()
def query = Query.prepare(attributes['to.path']);
def path = query.evaluateExpressions(attributes, null);
flowFile = session.putAttribute(flowFile, 'to.path', path)
session.transfer(flowFile, REL_SUCCESS)
<?xml version="1.0" ?>
<template encoding-version="1.1">
<description></description>
<groupId>18319dc6-015d-1000-91aa-285ed4b20da0</groupId>
<name>LookupAttribute XML PutFile Example</name>
<snippet>
<processGroups>
<id>760e741a-ea1e-30bd-0000-000000000000</id>
<parentGroupId>8ae65505-bd2f-37a4-0000-000000000000</parentGroupId>
<position>
<x>0.0</x>
<y>0.0</y>
</position>
<comments></comments>
<contents>
<connections>
<id>8b1c2e07-f414-3afc-0000-000000000000</id>
<parentGroupId>760e741a-ea1e-30bd-0000-000000000000</parentGroupId>
<backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold>
<backPressureObjectThreshold>10000</backPressureObjectThreshold>
<destination>
<groupId>760e741a-ea1e-30bd-0000-000000000000</groupId>
<id>460ec50a-8e65-3c2c-0000-000000000000</id>
<type>PROCESSOR</type>
</destination>
<flowFileExpiration>0 sec</flowFileExpiration>
<labelIndex>1</labelIndex>
<name></name>
<selectedRelationships>success</selectedRelationships>
<source>
<groupId>760e741a-ea1e-30bd-0000-000000000000</groupId>
<id>d9d6c5b2-6d7d-3fce-0000-000000000000</id>
<type>PROCESSOR</type>
</source>
<zIndex>0</zIndex>
</connections>
<connections>
<id>b0822237-4385-3930-0000-000000000000</id>
<parentGroupId>760e741a-ea1e-30bd-0000-000000000000</parentGroupId>
<backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold>
<backPressureObjectThreshold>10000</backPressureObjectThreshold>
<destination>
<groupId>760e741a-ea1e-30bd-0000-000000000000</groupId>
<id>4d528142-18bd-3cd9-0000-000000000000</id>
<type>PROCESSOR</type>
</destination>
<flowFileExpiration>0 sec</flowFileExpiration>
<labelIndex>1</labelIndex>
<name></name>
<selectedRelationships>success</selectedRelationships>
<source>
<groupId>760e741a-ea1e-30bd-0000-000000000000</groupId>
<id>e91e60bd-cadd-3e1e-0000-000000000000</id>
<type>PROCESSOR</type>
</source>
<zIndex>0</zIndex>
</connections>
<connections>
<id>eb59991f-8813-3693-0000-000000000000</id>
<parentGroupId>760e741a-ea1e-30bd-0000-000000000000</parentGroupId>
<backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold>
<backPressureObjectThreshold>10000</backPressureObjectThreshold>
<destination>
<groupId>760e741a-ea1e-30bd-0000-000000000000</groupId>
<id>e91e60bd-cadd-3e1e-0000-000000000000</id>
<type>PROCESSOR</type>
</destination>
<flowFileExpiration>0 sec</flowFileExpiration>
<labelIndex>1</labelIndex>
<name></name>
<selectedRelationships>matched</selectedRelationships>
<source>
<groupId>760e741a-ea1e-30bd-0000-000000000000</groupId>
<id>460ec50a-8e65-3c2c-0000-000000000000</id>
<type>PROCESSOR</type>
</source>
<zIndex>0</zIndex>
</connections>
<connections>
<id>0ccb7fe2-d4bf-31d5-0000-000000000000</id>
<parentGroupId>760e741a-ea1e-30bd-0000-000000000000</parentGroupId>
<backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold>
<backPressureObjectThreshold>10000</backPressureObjectThreshold>
<destination>
<groupId>760e741a-ea1e-30bd-0000-000000000000</groupId>
<id>d9d6c5b2-6d7d-3fce-0000-000000000000</id>
<type>PROCESSOR</type>
</destination>
<flowFileExpiration>0 sec</flowFileExpiration>
<labelIndex>1</labelIndex>
<name></name>
<selectedRelationships>success</selectedRelationships>
<source>
<groupId>760e741a-ea1e-30bd-0000-000000000000</groupId>
<id>2fca754f-e43d-352c-0000-000000000000</id>
<type>PROCESSOR</type>
</source>
<zIndex>0</zIndex>
</connections>
<controllerServices>
<id>6c2d6ccd-b080-32b5-0000-000000000000</id>
<parentGroupId>760e741a-ea1e-30bd-0000-000000000000</parentGroupId>
<bundle>
<artifact>nifi-lookup-services-nar</artifact>
<group>org.apache.nifi</group>
<version>1.3.0</version>
</bundle>
<comments></comments>
<descriptors>
<entry>
<key>configuration-file</key>
<value>
<name>configuration-file</name>
</value>
</entry>
</descriptors>
<name>XMLFileLookupService</name>
<persistsState>false</persistsState>
<properties>
<entry>
<key>configuration-file</key>
<value>/tmp/config.xml</value>
</entry>
</properties>
<state>ENABLED</state>
<type>org.apache.nifi.lookup.XMLFileLookupService</type>
</controllerServices>
<processors>
<id>d9d6c5b2-6d7d-3fce-0000-000000000000</id>
<parentGroupId>760e741a-ea1e-30bd-0000-000000000000</parentGroupId>
<position>
<x>281.0</x>
<y>247.0</y>
</position>
<bundle>
<artifact>nifi-standard-nar</artifact>
<group>org.apache.nifi</group>
<version>1.3.0</version>
</bundle>
<config>
<bulletinLevel>WARN</bulletinLevel>
<comments></comments>
<concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
<descriptors>
<entry>
<key>File to Fetch</key>
<value>
<name>File to Fetch</name>
</value>
</entry>
<entry>
<key>Completion Strategy</key>
<value>
<name>Completion Strategy</name>
</value>
</entry>
<entry>
<key>Move Destination Directory</key>
<value>
<name>Move Destination Directory</name>
</value>
</entry>
<entry>
<key>Move Conflict Strategy</key>
<value>
<name>Move Conflict Strategy</name>
</value>
</entry>
<entry>
<key>Log level when file not found</key>
<value>
<name>Log level when file not found</name>
</value>
</entry>
<entry>
<key>Log level when permission denied</key>
<value>
<name>Log level when permission denied</name>
</value>
</entry>
</descriptors>
<executionNode>ALL</executionNode>
<lossTolerant>false</lossTolerant>
<penaltyDuration>30 sec</penaltyDuration>
<properties>
<entry>
<key>File to Fetch</key>
<value>${absolute.path}/${filename}</value>
</entry>
<entry>
<key>Completion Strategy</key>
<value>None</value>
</entry>
<entry>
<key>Move Destination Directory</key>
</entry>
<entry>
<key>Move Conflict Strategy</key>
<value>Rename</value>
</entry>
<entry>
<key>Log level when file not found</key>
<value>ERROR</value>
</entry>
<entry>
<key>Log level when permission denied</key>
<value>ERROR</value>
</entry>
</properties>
<runDurationMillis>0</runDurationMillis>
<schedulingPeriod>0 sec</schedulingPeriod>
<schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
<yieldDuration>1 sec</yieldDuration>
</config>
<name>FetchFile</name>
<relationships>
<autoTerminate>true</autoTerminate>
<name>failure</name>
</relationships>
<relationships>
<autoTerminate>true</autoTerminate>
<name>not.found</name>
</relationships>
<relationships>
<autoTerminate>true</autoTerminate>
<name>permission.denied</name>
</relationships>
<relationships>
<autoTerminate>false</autoTerminate>
<name>success</name>
</relationships>
<style></style>
<type>org.apache.nifi.processors.standard.FetchFile</type>
</processors>
<processors>
<id>e91e60bd-cadd-3e1e-0000-000000000000</id>
<parentGroupId>760e741a-ea1e-30bd-0000-000000000000</parentGroupId>
<position>
<x>921.4999877929687</x>
<y>-3.299998474121068</y>
</position>
<bundle>
<artifact>nifi-scripting-nar</artifact>
<group>org.apache.nifi</group>
<version>1.3.0</version>
</bundle>
<config>
<bulletinLevel>WARN</bulletinLevel>
<comments></comments>
<concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
<descriptors>
<entry>
<key>Script Engine</key>
<value>
<name>Script Engine</name>
</value>
</entry>
<entry>
<key>Script File</key>
<value>
<name>Script File</name>
</value>
</entry>
<entry>
<key>Script Body</key>
<value>
<name>Script Body</name>
</value>
</entry>
<entry>
<key>Module Directory</key>
<value>
<name>Module Directory</name>
</value>
</entry>
</descriptors>
<executionNode>ALL</executionNode>
<lossTolerant>false</lossTolerant>
<penaltyDuration>30 sec</penaltyDuration>
<properties>
<entry>
<key>Script Engine</key>
<value>Groovy</value>
</entry>
<entry>
<key>Script File</key>
<value>/tmp/evalexp.groovy</value>
</entry>
<entry>
<key>Script Body</key>
</entry>
<entry>
<key>Module Directory</key>
<value>./lib/bootstrap/nifi-expression-language-1.3.0.jar,./lib/bootstrap/antlr-runtime-3.5.2.jar</value>
</entry>
</properties>
<runDurationMillis>0</runDurationMillis>
<schedulingPeriod>0 sec</schedulingPeriod>
<schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
<yieldDuration>1 sec</yieldDuration>
</config>
<name>ExecuteScript</name>
<relationships>
<autoTerminate>true</autoTerminate>
<name>failure</name>
</relationships>
<relationships>
<autoTerminate>false</autoTerminate>
<name>success</name>
</relationships>
<style></style>
<type>org.apache.nifi.processors.script.ExecuteScript</type>
</processors>
<processors>
<id>2fca754f-e43d-352c-0000-000000000000</id>
<parentGroupId>760e741a-ea1e-30bd-0000-000000000000</parentGroupId>
<position>
<x>282.0</x>
<y>4.0</y>
</position>
<bundle>
<artifact>nifi-standard-nar</artifact>
<group>org.apache.nifi</group>
<version>1.3.0</version>
</bundle>
<config>
<bulletinLevel>WARN</bulletinLevel>
<comments></comments>
<concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
<descriptors>
<entry>
<key>Input Directory</key>
<value>
<name>Input Directory</name>
</value>
</entry>
<entry>
<key>Recurse Subdirectories</key>
<value>
<name>Recurse Subdirectories</name>
</value>
</entry>
<entry>
<key>Input Directory Location</key>
<value>
<name>Input Directory Location</name>
</value>
</entry>
<entry>
<key>File Filter</key>
<value>
<name>File Filter</name>
</value>
</entry>
<entry>
<key>Path Filter</key>
<value>
<name>Path Filter</name>
</value>
</entry>
<entry>
<key>Minimum File Age</key>
<value>
<name>Minimum File Age</name>
</value>
</entry>
<entry>
<key>Maximum File Age</key>
<value>
<name>Maximum File Age</name>
</value>
</entry>
<entry>
<key>Minimum File Size</key>
<value>
<name>Minimum File Size</name>
</value>
</entry>
<entry>
<key>Maximum File Size</key>
<value>
<name>Maximum File Size</name>
</value>
</entry>
<entry>
<key>Ignore Hidden Files</key>
<value>
<name>Ignore Hidden Files</name>
</value>
</entry>
</descriptors>
<executionNode>ALL</executionNode>
<lossTolerant>false</lossTolerant>
<penaltyDuration>30 sec</penaltyDuration>
<properties>
<entry>
<key>Input Directory</key>
<value>/tmp/input</value>
</entry>
<entry>
<key>Recurse Subdirectories</key>
<value>true</value>
</entry>
<entry>
<key>Input Directory Location</key>
<value>Local</value>
</entry>
<entry>
<key>File Filter</key>
<value>[^\.].*</value>
</entry>
<entry>
<key>Path Filter</key>
</entry>
<entry>
<key>Minimum File Age</key>
<value>0 sec</value>
</entry>
<entry>
<key>Maximum File Age</key>
</entry>
<entry>
<key>Minimum File Size</key>
<value>0 B</value>
</entry>
<entry>
<key>Maximum File Size</key>
</entry>
<entry>
<key>Ignore Hidden Files</key>
<value>true</value>
</entry>
</properties>
<runDurationMillis>0</runDurationMillis>
<schedulingPeriod>0 sec</schedulingPeriod>
<schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
<yieldDuration>1 sec</yieldDuration>
</config>
<name>ListFile</name>
<relationships>
<autoTerminate>false</autoTerminate>
<name>success</name>
</relationships>
<style></style>
<type>org.apache.nifi.processors.standard.ListFile</type>
</processors>
<processors>
<id>460ec50a-8e65-3c2c-0000-000000000000</id>
<parentGroupId>760e741a-ea1e-30bd-0000-000000000000</parentGroupId>
<position>
<x>283.0</x>
<y>482.0</y>
</position>
<bundle>
<artifact>nifi-standard-nar</artifact>
<group>org.apache.nifi</group>
<version>1.3.0</version>
</bundle>
<config>
<bulletinLevel>WARN</bulletinLevel>
<comments></comments>
<concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
<descriptors>
<entry>
<key>lookup-service</key>
<value>
<identifiesControllerService>org.apache.nifi.lookup.StringLookupService</identifiesControllerService>
<name>lookup-service</name>
</value>
</entry>
<entry>
<key>include-empty-values</key>
<value>
<name>include-empty-values</name>
</value>
</entry>
<entry>
<key>country</key>
<value>
<name>country</name>
</value>
</entry>
<entry>
<key>datasource</key>
<value>
<name>datasource</name>
</value>
</entry>
<entry>
<key>to.path</key>
<value>
<name>to.path</name>
</value>
</entry>
</descriptors>
<executionNode>ALL</executionNode>
<lossTolerant>false</lossTolerant>
<penaltyDuration>30 sec</penaltyDuration>
<properties>
<entry>
<key>lookup-service</key>
<value>6c2d6ccd-b080-32b5-0000-000000000000</value>
</entry>
<entry>
<key>include-empty-values</key>
<value>true</value>
</entry>
<entry>
<key>country</key>
<value>dataFlows(0).dataFlow.properties.property(0)[@value]</value>
</entry>
<entry>
<key>datasource</key>
<value>dataFlows(0).dataFlow.properties.property(1)[@value]</value>
</entry>
<entry>
<key>to.path</key>
<value>dataFlows(0).dataFlow.to(0).path</value>
</entry>
</properties>
<runDurationMillis>0</runDurationMillis>
<schedulingPeriod>0 sec</schedulingPeriod>
<schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
<yieldDuration>1 sec</yieldDuration>
</config>
<name>LookupAttribute</name>
<relationships>
<autoTerminate>true</autoTerminate>
<name>failure</name>
</relationships>
<relationships>
<autoTerminate>false</autoTerminate>
<name>matched</name>
</relationships>
<relationships>
<autoTerminate>true</autoTerminate>
<name>unmatched</name>
</relationships>
<style></style>
<type>org.apache.nifi.processors.standard.LookupAttribute</type>
</processors>
<processors>
<id>4d528142-18bd-3cd9-0000-000000000000</id>
<parentGroupId>760e741a-ea1e-30bd-0000-000000000000</parentGroupId>
<position>
<x>913.9999389648438</x>
<y>247.4000244140625</y>
</position>
<bundle>
<artifact>nifi-standard-nar</artifact>
<group>org.apache.nifi</group>
<version>1.3.0</version>
</bundle>
<config>
<bulletinLevel>WARN</bulletinLevel>
<comments></comments>
<concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
<descriptors>
<entry>
<key>Directory</key>
<value>
<name>Directory</name>
</value>
</entry>
<entry>
<key>Conflict Resolution Strategy</key>
<value>
<name>Conflict Resolution Strategy</name>
</value>
</entry>
<entry>
<key>Create Missing Directories</key>
<value>
<name>Create Missing Directories</name>
</value>
</entry>
<entry>
<key>Maximum File Count</key>
<value>
<name>Maximum File Count</name>
</value>
</entry>
<entry>
<key>Last Modified Time</key>
<value>
<name>Last Modified Time</name>
</value>
</entry>
<entry>
<key>Permissions</key>
<value>
<name>Permissions</name>
</value>
</entry>
<entry>
<key>Owner</key>
<value>
<name>Owner</name>
</value>
</entry>
<entry>
<key>Group</key>
<value>
<name>Group</name>
</value>
</entry>
</descriptors>
<executionNode>ALL</executionNode>
<lossTolerant>false</lossTolerant>
<penaltyDuration>30 sec</penaltyDuration>
<properties>
<entry>
<key>Directory</key>
<value>${to.path}</value>
</entry>
<entry>
<key>Conflict Resolution Strategy</key>
<value>fail</value>
</entry>
<entry>
<key>Create Missing Directories</key>
<value>true</value>
</entry>
<entry>
<key>Maximum File Count</key>
</entry>
<entry>
<key>Last Modified Time</key>
</entry>
<entry>
<key>Permissions</key>
</entry>
<entry>
<key>Owner</key>
</entry>
<entry>
<key>Group</key>
</entry>
</properties>
<runDurationMillis>0</runDurationMillis>
<schedulingPeriod>0 sec</schedulingPeriod>
<schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
<yieldDuration>1 sec</yieldDuration>
</config>
<name>PutFile</name>
<relationships>
<autoTerminate>true</autoTerminate>
<name>failure</name>
</relationships>
<relationships>
<autoTerminate>true</autoTerminate>
<name>success</name>
</relationships>
<style></style>
<type>org.apache.nifi.processors.standard.PutFile</type>
</processors>
</contents>
<name>LookupAttribute XML PutFile Example</name>
</processGroups>
</snippet>
<timestamp>07/06/2017 09:45:17 CDT</timestamp>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment