Member since
09-17-2016
4
Posts
0
Kudos Received
0
Solutions
09-17-2016
11:11 AM
Thanks Andy for your response .I did try above mentioned options but have doubt regarding npm modules and package.json are not working in InvokeScriptedProcessor Can you provide some implementation examples using javascript part from above mentioned links
... View more
09-17-2016
02:57 AM
I want to call javascript script from MyProcessor code in Apache Nifi. I am calling following binary parser written in javascript in java which is npm module .Can package.son and npm modules part of NAR Code: Calling following Javascript.js var Parser = require('binary-parser').Parser; // Build an IP packet header Parser var ipHeader = new Parser() .endianess('big') .bit4('version') .bit4('headerLength') .uint8('tos') .uint16('packetLength') .uint16('id') .bit3('offset') .bit13('fragOffset') .uint8('ttl') .uint8('protocol') .uint16('checksum') .array('src', { type: 'uint8', length: 4 }) .array('dst', { type: 'uint8', length: 4 }); // Prepare buffer to parse. var buf = new Buffer('450002c5939900002c06ef98adc24f6c850186d1', 'hex'); // Parse buffer and show result console.log(ipHeader.parse(buf)); MyProcessor Code: ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("JavaScript"); if (!(engine instanceof Invocable)) { System.out.println("Invoking methods is not supported."); return; } Invocable inv = (Invocable) engine; String scriptPath = "binaryParser.js";
... View more
Labels:
- Labels:
-
Apache NiFi