You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by mattyb149 <gi...@git.apache.org> on 2016/04/28 15:56:33 UTC

[GitHub] nifi pull request: NIFI-1822: Allow concurrent execution in Execut...

GitHub user mattyb149 opened a pull request:

    https://github.com/apache/nifi/pull/387

    NIFI-1822: Allow concurrent execution in ExecuteScript

    Added a ScriptEngine pool for use by ExecuteScript, to enable it to run with multiple concurrent tasks.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mattyb149/nifi NIFI-1822

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/387.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #387
    
----
commit 0d3aac1cdb5d6d2ed2779ade8b3b48169ccf6f21
Author: Matt Burgess <ma...@apache.org>
Date:   2016-04-28T13:53:16Z

    NIFI-1822: Allow concurrent execution in ExecuteScript

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1822: Allow concurrent execution in Execut...

Posted by alopresto <gi...@git.apache.org>.
Github user alopresto commented on the pull request:

    https://github.com/apache/nifi/pull/387#issuecomment-219194190
  
    I also updated `MockProcessorContext` to allow for a configurable `maxConcurrentTasks` value, as it was previously hard-coded to 1. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1822: Allow concurrent execution in Execut...

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/387#discussion_r63269288
  
    --- Diff: nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/AbstractScriptProcessor.java ---
    @@ -248,11 +253,13 @@ protected void setupEngine() {
                     Thread.currentThread().setContextClassLoader(scriptEngineModuleClassLoader);
                 }
     
    -            scriptEngine = createScriptEngine();
    +            ScriptEngine scriptEngine = createScriptEngine();
    --- End diff --
    
    D'oh! will fix


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1822: Allow concurrent execution in Execut...

Posted by alopresto <gi...@git.apache.org>.
Github user alopresto commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/387#discussion_r63269277
  
    --- Diff: nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/AbstractScriptProcessor.java ---
    @@ -248,11 +253,13 @@ protected void setupEngine() {
                     Thread.currentThread().setContextClassLoader(scriptEngineModuleClassLoader);
                 }
     
    -            scriptEngine = createScriptEngine();
    +            ScriptEngine scriptEngine = createScriptEngine();
    --- End diff --
    
    Obviously you moved the declaration to be locally scoped because you intended to add a for loop here. But as of right now, it only populates the queue with a single engine instance, so despite having multiple threads consume and re-populate it, the queue will only ever contain 1 or 0 engines for use. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1822: Allow concurrent execution in Execut...

Posted by alopresto <gi...@git.apache.org>.
Github user alopresto commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/387#discussion_r63269309
  
    --- Diff: nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/AbstractScriptProcessor.java ---
    @@ -216,7 +220,8 @@ public void setup() {
          *
          * @see org.apache.nifi.processors.script.ScriptEngineConfigurator
          */
    -    protected void setupEngine() {
    +    protected void setupEngines(int numberOfScriptEngines) {
    +        engineQ = new LinkedBlockingQueue<>(numberOfScriptEngines);
             ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
             try {
                 ProcessorLog log = getLogger();
    --- End diff --
    
    GitHub won't let me put the line comment on 229, but that can throw an NPE if the `scriptEngineName` is not defined when this method is run. In normal execution, that won't occur, but during test configuration, the `setup` method can be called before the `context` is defined and provided. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1822: Allow concurrent execution in Execut...

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on the pull request:

    https://github.com/apache/nifi/pull/387#issuecomment-219265046
  
    Thanks much for the corrections/improvements/additions!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1822: Allow concurrent execution in Execut...

Posted by alopresto <gi...@git.apache.org>.
Github user alopresto commented on the pull request:

    https://github.com/apache/nifi/pull/387#issuecomment-219264620
  
    I have opened a new [PR 443](https://github.com/apache/nifi/pull/443) with unit tests, fixes for the above issues, and additional changes.  


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1822: Allow concurrent execution in Execut...

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 closed the pull request at:

    https://github.com/apache/nifi/pull/387


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request: NIFI-1822: Allow concurrent execution in Execut...

Posted by alopresto <gi...@git.apache.org>.
Github user alopresto commented on the pull request:

    https://github.com/apache/nifi/pull/387#issuecomment-219195734
  
    I added some unit tests (not yet complete) and made the changes referenced above in a branch here: https://github.com/apache/nifi/compare/master...alopresto:pr387?expand=1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---