Skip to content

Instantly share code, notes, and snippets.

@alopresto
Created February 27, 2017 20:28
Show Gist options
  • Save alopresto/e0840c7932b1743a1e432a1652c0c92d to your computer and use it in GitHub Desktop.
Save alopresto/e0840c7932b1743a1e432a1652c0c92d to your computer and use it in GitHub Desktop.
Example of using rev and sed against flowfile content.
<?xml version="1.0" ?>
<template encoding-version="1.0">
<description>Example of using rev and sed against flowfile content. </description>
<groupId>81363c71-015a-1000-f0a6-b32176dacbe9</groupId>
<name>ExecuteStreamCommand Examples</name>
<snippet>
<connections>
<id>8138777c-015a-1000-0000-000000000000</id>
<parentGroupId>81363c71-015a-1000-0000-000000000000</parentGroupId>
<backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold>
<backPressureObjectThreshold>10000</backPressureObjectThreshold>
<destination>
<groupId>81363c71-015a-1000-0000-000000000000</groupId>
<id>8136fcc2-015a-1000-0000-000000000000</id>
<type>PROCESSOR</type>
</destination>
<flowFileExpiration>0 sec</flowFileExpiration>
<labelIndex>1</labelIndex>
<name></name>
<selectedRelationships>success</selectedRelationships>
<source>
<groupId>81363c71-015a-1000-0000-000000000000</groupId>
<id>8136d0db-015a-1000-0000-000000000000</id>
<type>PROCESSOR</type>
</source>
<zIndex>0</zIndex>
</connections>
<connections>
<id>81388eca-015a-1000-0000-000000000000</id>
<parentGroupId>81363c71-015a-1000-0000-000000000000</parentGroupId>
<backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold>
<backPressureObjectThreshold>10000</backPressureObjectThreshold>
<destination>
<groupId>81363c71-015a-1000-0000-000000000000</groupId>
<id>81372065-015a-1000-0000-000000000000</id>
<type>PROCESSOR</type>
</destination>
<flowFileExpiration>0 sec</flowFileExpiration>
<labelIndex>1</labelIndex>
<name></name>
<selectedRelationships>output stream</selectedRelationships>
<source>
<groupId>81363c71-015a-1000-0000-000000000000</groupId>
<id>8136fcc2-015a-1000-0000-000000000000</id>
<type>PROCESSOR</type>
</source>
<zIndex>0</zIndex>
</connections>
<connections>
<id>813ce96a-015a-1000-0000-000000000000</id>
<parentGroupId>81363c71-015a-1000-0000-000000000000</parentGroupId>
<backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold>
<backPressureObjectThreshold>10000</backPressureObjectThreshold>
<destination>
<groupId>81363c71-015a-1000-0000-000000000000</groupId>
<id>813c5eb7-015a-1000-0000-000000000000</id>
<type>PROCESSOR</type>
</destination>
<flowFileExpiration>0 sec</flowFileExpiration>
<labelIndex>1</labelIndex>
<name></name>
<selectedRelationships>success</selectedRelationships>
<source>
<groupId>81363c71-015a-1000-0000-000000000000</groupId>
<id>8136d0db-015a-1000-0000-000000000000</id>
<type>PROCESSOR</type>
</source>
<zIndex>0</zIndex>
</connections>
<connections>
<id>813cff41-015a-1000-0000-000000000000</id>
<parentGroupId>81363c71-015a-1000-0000-000000000000</parentGroupId>
<backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold>
<backPressureObjectThreshold>10000</backPressureObjectThreshold>
<destination>
<groupId>81363c71-015a-1000-0000-000000000000</groupId>
<id>81372065-015a-1000-0000-000000000000</id>
<type>PROCESSOR</type>
</destination>
<flowFileExpiration>0 sec</flowFileExpiration>
<labelIndex>1</labelIndex>
<name></name>
<selectedRelationships>output stream</selectedRelationships>
<source>
<groupId>81363c71-015a-1000-0000-000000000000</groupId>
<id>813c5eb7-015a-1000-0000-000000000000</id>
<type>PROCESSOR</type>
</source>
<zIndex>0</zIndex>
</connections>
<processors>
<id>8136d0db-015a-1000-0000-000000000000</id>
<parentGroupId>81363c71-015a-1000-0000-000000000000</parentGroupId>
<position>
<x>191.0</x>
<y>0.0</y>
</position>
<config>
<bulletinLevel>WARN</bulletinLevel>
<comments></comments>
<concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
<descriptors>
<entry>
<key>File Size</key>
<value>
<name>File Size</name>
</value>
</entry>
<entry>
<key>Batch Size</key>
<value>
<name>Batch Size</name>
</value>
</entry>
<entry>
<key>Data Format</key>
<value>
<name>Data Format</name>
</value>
</entry>
<entry>
<key>Unique FlowFiles</key>
<value>
<name>Unique FlowFiles</name>
</value>
</entry>
<entry>
<key>generate-ff-custom-text</key>
<value>
<name>generate-ff-custom-text</name>
</value>
</entry>
</descriptors>
<executionNode>ALL</executionNode>
<lossTolerant>false</lossTolerant>
<penaltyDuration>30 sec</penaltyDuration>
<properties>
<entry>
<key>File Size</key>
<value>0B</value>
</entry>
<entry>
<key>Batch Size</key>
<value>1</value>
</entry>
<entry>
<key>Data Format</key>
<value>Text</value>
</entry>
<entry>
<key>Unique FlowFiles</key>
<value>false</value>
</entry>
<entry>
<key>generate-ff-custom-text</key>
<value>This is a plaintext message.</value>
</entry>
</properties>
<runDurationMillis>0</runDurationMillis>
<schedulingPeriod>3 sec</schedulingPeriod>
<schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
<yieldDuration>1 sec</yieldDuration>
</config>
<name>GenerateFlowFile</name>
<relationships>
<autoTerminate>false</autoTerminate>
<name>success</name>
</relationships>
<style></style>
<type>org.apache.nifi.processors.standard.GenerateFlowFile</type>
</processors>
<processors>
<id>8136fcc2-015a-1000-0000-000000000000</id>
<parentGroupId>81363c71-015a-1000-0000-000000000000</parentGroupId>
<position>
<x>0.0</x>
<y>231.0</y>
</position>
<config>
<bulletinLevel>WARN</bulletinLevel>
<comments></comments>
<concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
<descriptors>
<entry>
<key>Command Arguments</key>
<value>
<name>Command Arguments</name>
</value>
</entry>
<entry>
<key>Command Path</key>
<value>
<name>Command Path</name>
</value>
</entry>
<entry>
<key>Ignore STDIN</key>
<value>
<name>Ignore STDIN</name>
</value>
</entry>
<entry>
<key>Working Directory</key>
<value>
<name>Working Directory</name>
</value>
</entry>
<entry>
<key>Argument Delimiter</key>
<value>
<name>Argument Delimiter</name>
</value>
</entry>
<entry>
<key>Output Destination Attribute</key>
<value>
<name>Output Destination Attribute</name>
</value>
</entry>
<entry>
<key>Max Attribute Length</key>
<value>
<name>Max Attribute Length</name>
</value>
</entry>
</descriptors>
<executionNode>ALL</executionNode>
<lossTolerant>false</lossTolerant>
<penaltyDuration>30 sec</penaltyDuration>
<properties>
<entry>
<key>Command Arguments</key>
</entry>
<entry>
<key>Command Path</key>
<value>rev</value>
</entry>
<entry>
<key>Ignore STDIN</key>
<value>false</value>
</entry>
<entry>
<key>Working Directory</key>
</entry>
<entry>
<key>Argument Delimiter</key>
<value>;</value>
</entry>
<entry>
<key>Output Destination Attribute</key>
</entry>
<entry>
<key>Max Attribute Length</key>
<value>256</value>
</entry>
</properties>
<runDurationMillis>0</runDurationMillis>
<schedulingPeriod>0 sec</schedulingPeriod>
<schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
<yieldDuration>1 sec</yieldDuration>
</config>
<name>Reverse With rev</name>
<relationships>
<autoTerminate>true</autoTerminate>
<name>original</name>
</relationships>
<relationships>
<autoTerminate>false</autoTerminate>
<name>output stream</name>
</relationships>
<style></style>
<type>org.apache.nifi.processors.standard.ExecuteStreamCommand</type>
</processors>
<processors>
<id>81372065-015a-1000-0000-000000000000</id>
<parentGroupId>81363c71-015a-1000-0000-000000000000</parentGroupId>
<position>
<x>196.0</x>
<y>514.0</y>
</position>
<config>
<bulletinLevel>WARN</bulletinLevel>
<comments></comments>
<concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
<descriptors>
<entry>
<key>Log Level</key>
<value>
<name>Log Level</name>
</value>
</entry>
<entry>
<key>Log Payload</key>
<value>
<name>Log Payload</name>
</value>
</entry>
<entry>
<key>Attributes to Log</key>
<value>
<name>Attributes to Log</name>
</value>
</entry>
<entry>
<key>Attributes to Ignore</key>
<value>
<name>Attributes to Ignore</name>
</value>
</entry>
<entry>
<key>Log prefix</key>
<value>
<name>Log prefix</name>
</value>
</entry>
</descriptors>
<executionNode>ALL</executionNode>
<lossTolerant>false</lossTolerant>
<penaltyDuration>30 sec</penaltyDuration>
<properties>
<entry>
<key>Log Level</key>
<value>info</value>
</entry>
<entry>
<key>Log Payload</key>
<value>true</value>
</entry>
<entry>
<key>Attributes to Log</key>
</entry>
<entry>
<key>Attributes to Ignore</key>
</entry>
<entry>
<key>Log prefix</key>
</entry>
</properties>
<runDurationMillis>0</runDurationMillis>
<schedulingPeriod>0 sec</schedulingPeriod>
<schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
<yieldDuration>1 sec</yieldDuration>
</config>
<name>LogAttribute</name>
<relationships>
<autoTerminate>true</autoTerminate>
<name>success</name>
</relationships>
<style></style>
<type>org.apache.nifi.processors.standard.LogAttribute</type>
</processors>
<processors>
<id>813c5eb7-015a-1000-0000-000000000000</id>
<parentGroupId>81363c71-015a-1000-0000-000000000000</parentGroupId>
<position>
<x>369.0</x>
<y>232.0</y>
</position>
<config>
<bulletinLevel>WARN</bulletinLevel>
<comments></comments>
<concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount>
<descriptors>
<entry>
<key>Command Arguments</key>
<value>
<name>Command Arguments</name>
</value>
</entry>
<entry>
<key>Command Path</key>
<value>
<name>Command Path</name>
</value>
</entry>
<entry>
<key>Ignore STDIN</key>
<value>
<name>Ignore STDIN</name>
</value>
</entry>
<entry>
<key>Working Directory</key>
<value>
<name>Working Directory</name>
</value>
</entry>
<entry>
<key>Argument Delimiter</key>
<value>
<name>Argument Delimiter</name>
</value>
</entry>
<entry>
<key>Output Destination Attribute</key>
<value>
<name>Output Destination Attribute</name>
</value>
</entry>
<entry>
<key>Max Attribute Length</key>
<value>
<name>Max Attribute Length</name>
</value>
</entry>
</descriptors>
<executionNode>ALL</executionNode>
<lossTolerant>false</lossTolerant>
<penaltyDuration>30 sec</penaltyDuration>
<properties>
<entry>
<key>Command Arguments</key>
<value>s/message/garbage/</value>
</entry>
<entry>
<key>Command Path</key>
<value>sed</value>
</entry>
<entry>
<key>Ignore STDIN</key>
<value>false</value>
</entry>
<entry>
<key>Working Directory</key>
</entry>
<entry>
<key>Argument Delimiter</key>
<value>;</value>
</entry>
<entry>
<key>Output Destination Attribute</key>
</entry>
<entry>
<key>Max Attribute Length</key>
<value>256</value>
</entry>
</properties>
<runDurationMillis>0</runDurationMillis>
<schedulingPeriod>0 sec</schedulingPeriod>
<schedulingStrategy>TIMER_DRIVEN</schedulingStrategy>
<yieldDuration>1 sec</yieldDuration>
</config>
<name>Modify With sed</name>
<relationships>
<autoTerminate>true</autoTerminate>
<name>original</name>
</relationships>
<relationships>
<autoTerminate>false</autoTerminate>
<name>output stream</name>
</relationships>
<style></style>
<type>org.apache.nifi.processors.standard.ExecuteStreamCommand</type>
</processors>
</snippet>
<timestamp>02/27/2017 15:27:35 EST</timestamp>
</template>
@vcovo
Copy link

vcovo commented Mar 25, 2018

Thanks for this. Just a quick note, as of now Nifi will throw an error as the nonzero status of each ExecuteStreamCommand is not auto terminated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment