Created on 11-19-2015 09:40 PM
Getting started with Nifi expression language and custom Nifi processors on HDP sandbox
This tutorial is part of a webinar for partners on Hortonworks DataFlow. The recording will be made available at
192.168.191.241 sandbox.hortonworks.com sandbox
ssh root@sandbox.hortonworks.com
VERSION=`hdp-select status hadoop-client | sed 's/hadoop-client - \([0-9]\.[0-9]\).*/\1/'` sudo git clone https://github.com/abajwa-hw/ambari-nifi-service.git /var/lib/ambari-server/resources/stacks/HDP/$VERSION/services/NIFI #sandbox service ambari restart #non sandbox service ambari-server restart
yum install -y tcpdump
tcpdump -n -nn
08:16:15.878652 IP 192.168.191.1.49270 > 192.168.191.144.9090: Flags [.], ack 2255, win 8174, options [nop,nop,TS val 1176961367 ecr 32747195], length 0
Build tcpdump flow using ExecuteProcess and EL
tcpdump -n -nn
>
: (\d+\.\d+\.\d+\.\d+\.\d+)\s+>
<
: >\s+(\d+\.\d+\.\d+\.\d+\.\d+)
web.server.dest
= ${dest.socket:endsWith(".9090")}
by component type
: LogAttribute
and click on 'Show lineage' icon of first record (near top right) Route
> View details
. Content
tab and click View
Build custom processor for tcpdump
VERSION=`hdp-select status hadoop-client | sed 's/hadoop-client - \([0-9]\.[0-9]\).*/\1/'` sudo git clone https://github.com/hortonworks-gallery/ambari-vnc-service.git /var/lib/ambari-server/resources/stacks/HDP/$VERSION/services/VNCSERVER service ambari restart
curl -o /etc/yum.repos.d/epel-apache-maven.repo https://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo yum -y install apache-maven-3.2*
cd /tmp mvn archetype:generate -DarchetypeGroupId=org.apache.nifi -DarchetypeArtifactId=nifi-processor-bundle-archetype -DarchetypeVersion=0.2.1 -DnifiVersion=0.2.1
Define value for property 'groupId': : com.hortonworks Define value for property 'artifactId': : nifi-network-processors Define value for property 'version': 1.0-SNAPSHOT: : Define value for property 'artifactBaseName': : network Define value for property 'package': com.hortonworks.processors.network: :
cd sudo git clone https://github.com/abajwa-hw/nifi-network-processor.git
tags
and description
using @Tags
and @CapabilityDescription
here e.g.//Define the processor tags and description which will be displayed on Nifi UI @Tags({"fetch","tcpdump","tcp", "network"}) @CapabilityDescription("Reads output of tcpdump and outputs the results as a Flowfile")
These would get displayed on the 'Add processor' screen of Nifi UI
properties
for the processor here e.g.//Define properties for the processor public static final PropertyDescriptor MY_PROPERTY = new PropertyDescriptor .Builder().name("My Property") .description("Example Property") .required(true) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .build();
These would get displayed on the 'Properties' tab of the GetTcpDumpAttributes processor:
relationships
for the processor here e.g.//Define relationships for the processor public static final Relationship SUCCESS_RELATIONSHIP = new Relationship.Builder() .name("success") .description("Success relationship") .build();
These would get displayed on the 'Settings' tab of the GetTcpDumpAttributes processor:
nifi-network
/root/nifi-network-processor
clean package
Package Explorer
select nifi-network-processors
and then click:
ls -la ~/nifi-network-processor/nifi-network-nar/target/nifi-network-nar-1.0-SNAPSHOT.nar
cp ~/nifi-network-processor/nifi-network-nar/target/nifi-network-nar-1.0-SNAPSHOT.nar /opt/nifi-1.0.0.0-7/lib/ chown nifi:hadoop /opt/nifi-1.0.0.0-7/lib/nifi-network-nar-1.0-SNAPSHOT.nar
tcpdump -n -nn
>
: (\d+\.\d+\.\d+\.\d+\.\d+)\s+>
<
: >\s+(\d+\.\d+\.\d+\.\d+\.\d+)
web.server.dest
= ${dest.socket:endsWith(".9090")}
Created on 03-01-2016 04:28 PM
hello nice tutorial 🙂
deploying on nifi 0.4.1 or 0.5.0, the maven target nar file result (ie nifi-network-nar-1.0-SNAPSHOT.nar )
nifi starts but i cannot instantiate the processor from the IHM
i have the following trace in the logs with a WARN
nifi-app.log:2016-03-01 16:12:26,797 WARN [main] org.apache.nifi.nar.NarClassLoader ./work/nar/extensions/nifi-network-nar-1.0-SNAPSHOT.nar-unpacked does not contain META-INF/bundled-dependencies!
nifi-app.log:2016-03-01 16:12:26,797 INFO [main] org.apache.nifi.nar.NarClassLoaders Loaded NAR file: /home/cloud/fxd/Nifi/nifi-0.5.0/./work/nar/extensions/nifi-network-nar-1.0-SNAPSHOT.nar-unpacked as class loader org.apache.nifi.nar.NarClassLoader[./work/nar/extensions/nifi-network-nar-1.0-SNAPSHOT.nar-unpacked]
phil
best regards