You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Matt Burgess (Jira)" <ji...@apache.org> on 2020/01/09 18:08:00 UTC

[jira] [Commented] (NIFI-6543) Add onUnscheduled support for ExecuteGroovyScript Processor

    [ https://issues.apache.org/jira/browse/NIFI-6543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17012090#comment-17012090 ] 

Matt Burgess commented on NIFI-6543:
------------------------------------

Linked to PR that incorporates the original

> Add onUnscheduled support for ExecuteGroovyScript Processor
> -----------------------------------------------------------
>
>                 Key: NIFI-6543
>                 URL: https://issues.apache.org/jira/browse/NIFI-6543
>             Project: Apache NiFi
>          Issue Type: Improvement
>          Components: Extensions
>            Reporter: Michael Wagner
>            Assignee: Matt Burgess
>            Priority: Trivial
>   Original Estimate: 2h
>          Time Spent: 0.5h
>  Remaining Estimate: 1.5h
>
> The ExecuteGroovyScript processor is great, and it is great to have the support for onStart and onStop methods.  However, I often find myself wishing there were also a way to take some action when the processor is _unscheduled_.  That would let the groovy code to make decisions about whether or not to get() another flowfile.  
>  
> I think it should be as easy as 
> {code:java}
> diff --git a/nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/main/java/org/apache/nifi/processors/groovyx/ExecuteGroovyScript.java b/nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/main/java/org/apache/nifi/processors/groovyx/ExecuteGroovyScript.java
> index c35ab392d..eead4bc07 100644
> --- a/nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/main/java/org/apache/nifi/processors/groovyx/ExecuteGroovyScript.java
> +++ b/nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/main/java/org/apache/nifi/processors/groovyx/ExecuteGroovyScript.java
> @@ -27,6 +27,7 @@ import org.apache.nifi.annotation.documentation.CapabilityDescription;
>  import org.apache.nifi.annotation.documentation.SeeAlso;
>  import org.apache.nifi.annotation.documentation.Tags;
>  import org.apache.nifi.annotation.lifecycle.OnScheduled;
> +import org.apache.nifi.annotation.lifecycle.OnUnscheduled;
>  import org.apache.nifi.annotation.lifecycle.OnStopped;
>  import org.apache.nifi.components.PropertyDescriptor;
>  import org.apache.nifi.components.RequiredPermission;
> @@ -264,6 +265,14 @@ public class ExecuteGroovyScript extends AbstractProcessor {
>              throw new ProcessException("onStart failed: " + t, t);
>          }
>      }
> +    @OnUnscheduled
> +    public void onUnscheduled(final ProcessContext context) {
> +        try {
> +            callScriptStatic("onUnscheduled", context);
> +        } catch (Throwable t) {
> +            throw new ProcessException("onUnscheduled failed: " + t, t);
> +        }
> +    }
>  
>      @OnStopped
>      public void onStopped(final ProcessContext context) {
>  {code}
> But this is my first attempt to change Nifi; I defer to others.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)