Giovanni, A lot of great questions here. I’ll try to go through them but I hope Matt weighs in as well (he is on vacation for the next few days though).
* The only time I am aware the Jars are reloaded is at processor restart (I believe this is the same for the script content if defined by a referenced file as well). The scriptingComponentHelper setup*() methods execute inside ExecuteScript#setup(), which has @OnScheduled annotation [1]. * I’m not sure how other users bundle their dependencies, but shadow Jars would be fine for this use case, and Matt has referenced using them in his script-tester article [2]. * Yes, while there are small idiosyncrasies with each language flavor, the NiFi-related domain is fairly consistent. In this case, iterating over a number of flowfiles for processing in a single Groovy script is fine. Session.get(int) [3] is delegated to ProcessSession and returns List<FlowFile>, so you can use any of the Groovy collections methods over it. Hopefully this helps you and if Matt or anyone else sees a mistake, they correct it and add their thoughts. Thanks. [1] https://nifi.apache.org/docs/nifi-docs/html/developer-guide.html#onscheduled [2] https://funnifi.blogspot.com/2016/06/testing-executescript-processor-scripts.html <https://funnifi.blogspot.com/2016/06/testing-executescript-processor-scripts.html> [3] https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/StandardProcessSession.java#L1520 <https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/StandardProcessSession.java#L1520> Andy LoPresto [email protected] [email protected] PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69 > On Oct 3, 2017, at 1:09 PM, Giovanni Lanzani > <[email protected]> wrote: > > I apologize if this is specified elsewhere, but I couldn't find it. > > I was wondering when the jars, used by a particular Groovy script (in the > ExecuteScript processor), are reloaded. I.e. if one jar is updated, when will > the script pick up the new version? I know that upon restarting the > processor, the updated jar is considered, but I was wondering in which other > occasions that happens; > Do people tend to use fat (shadow) jars for this sort of jars referenced by > groovy scripts? I don't think it makes sense to keep track of all the > dependencies manually otherwise; > When using the {P,J}ython processor, I read Matt advice to use the following > construct in the script: > for flowFile in session.get(N): > if flowFile: > # do your thing here > Does the same hold for Groovy, i.e. should someone do > > session.get(N).each{ flowFile -> > // do your thing here > if(condition) { > session.transfer(flowFile, REL_SUCCESS) > } else { > session.transfer(flowFile, REL_FAILURE)} > > } > Is this approach safe in groovy inside a each? Or is this approach not needed > at all in Groovy, while it is needed in {P,J}ython? > > Thanks in advance! > > Giovanni >
signature.asc
Description: Message signed with OpenPGP using GPGMail
