<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: InvokeScriptedProcessor template for jython? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/InvokeScriptedProcessor-template-for-jython/m-p/182738#M70896</link>
    <description>&lt;P&gt;Thanks Matt, I'll be running tests today, thank you very much for your answer.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Nov 2017 18:19:59 GMT</pubDate>
    <dc:creator>xavwebmaster</dc:creator>
    <dc:date>2017-11-08T18:19:59Z</dc:date>
    <item>
      <title>InvokeScriptedProcessor template for jython?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/InvokeScriptedProcessor-template-for-jython/m-p/182736#M70894</link>
      <description>&lt;P&gt;Hello. &lt;/P&gt;&lt;P&gt;I have seen that for there is a way to get more speed from the script that we use in an executescript processor, Matt Burgess comments that it is possible to use the InvokeScriptedProcessor processor to get it. &lt;/P&gt;&lt;P&gt;In fact there is a template generated in groovy to be able to insert the imports and code of our script. &lt;/P&gt;&lt;PRE&gt;////////////////////////////////////////////////////////////
// imports go here
////////////////////////////////////////////////////////////


class E{ void executeScript(session, context, log, REL_SUCCESS, REL_FAILURE) 
    {
        ////////////////////////////////////////////////////////////
        // your code goes here
        ////////////////////////////////////////////////////////////
    }
}


class GroovyProcessor implements Processor {
    def REL_SUCCESS = new Relationship.Builder().name("success").description('FlowFiles that were successfully processed are routed here').build()
    def REL_FAILURE = new Relationship.Builder().name("failure").description('FlowFiles that were not successfully processed are routed here').build()
    def ComponentLog log
    def e = new E()   
    void initialize(ProcessorInitializationContext context) { log = context.logger }
    Set&amp;lt;Relationship&amp;gt; getRelationships() { return [REL_FAILURE, REL_SUCCESS] as Set }
    Collection&amp;lt;ValidationResult&amp;gt; validate(ValidationContext context) { null }
    PropertyDescriptor getPropertyDescriptor(String name) { null }
    void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { }
    List&amp;lt;PropertyDescriptor&amp;gt; getPropertyDescriptors() { null }
    String getIdentifier() { null }    
    void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException {
        def session = sessionFactory.createSession()
        try {
            e.executeScript(session, context, log, REL_SUCCESS, REL_FAILURE)
            session.commit()
        } catch (final Throwable t) {
            log.error('{} failed to process due to {}; rolling back session', [this, t] as Object[])
            session.rollback(true)
            throw t
}}}
processor = new GroovyProcessor()
&lt;/PRE&gt;&lt;P&gt;Unfortunately I haven't been able to find the same template but for jython. You know where the template is located or if possible someone could generate a template that can be used for jython code.&lt;/P&gt;&lt;P&gt;Thank you very much. &lt;/P&gt;&lt;P&gt;I enclose the link to Matt Burgess' article in case anyone would like to go into more detail.&lt;/P&gt;&lt;P&gt;&lt;A href="http://funnifi.blogspot.com.es/2017/06/invokescriptedprocessor-template-faster.html"&gt;Link&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 20:22:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/InvokeScriptedProcessor-template-for-jython/m-p/182736#M70894</guid>
      <dc:creator>xavwebmaster</dc:creator>
      <dc:date>2017-11-07T20:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: InvokeScriptedProcessor template for jython?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/InvokeScriptedProcessor-template-for-jython/m-p/182737#M70895</link>
      <description>&lt;P&gt;Although you may not see the same performance gains from ISP using Jython as you would by using Groovy (Jython is slower in general), this is still a good idea, so I revisited my blog post and created an &lt;A target="_blank" href="http://funnifi.blogspot.com/2017/11/invokescriptedprocessor-template.html"&gt;ISP template in Jython&lt;/A&gt;. Please let me know if it works for you!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 02:02:08 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/InvokeScriptedProcessor-template-for-jython/m-p/182737#M70895</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2017-11-08T02:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: InvokeScriptedProcessor template for jython?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/InvokeScriptedProcessor-template-for-jython/m-p/182738#M70896</link>
      <description>&lt;P&gt;Thanks Matt, I'll be running tests today, thank you very much for your answer.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 18:19:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/InvokeScriptedProcessor-template-for-jython/m-p/182738#M70896</guid>
      <dc:creator>xavwebmaster</dc:creator>
      <dc:date>2017-11-08T18:19:59Z</dc:date>
    </item>
  </channel>
</rss>

