You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by rkarthik29 <gi...@git.apache.org> on 2016/12/28 17:48:53 UTC

[GitHub] nifi pull request #1364: NIFI-1856 ExecuteStreamCommand Needs to Consume Sta...

GitHub user rkarthik29 opened a pull request:

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

    NIFI-1856 ExecuteStreamCommand Needs to Consume Standard Error

    Thank you for submitting a contribution to Apache NiFi.
    
    In order to streamline the review of the contribution we ask you
    to ensure the following steps have been taken:
    
    ### For all changes:
    - [ ] Is there a JIRA ticket associated with this PR? Is it referenced 
         in the commit message?
    
    - [ ] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
    
    - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    - [ ] Is your initial contribution a single, squashed commit?
    
    ### For code changes:
    - [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
    - [ ] Have you written or updated unit tests to verify your changes?
    - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
    - [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
    - [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
    - [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
    
    ### For documentation related changes:
    - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
    
    ### Note:
    Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.


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

    $ git pull https://github.com/rkarthik29/nifi-1 1856

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

    https://github.com/apache/nifi/pull/1364.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 #1364
    
----
commit 963651d094153d3b03e1e9b5ae333189683c5ed6
Author: Kathik Narayanan <kn...@hortonworks.com>
Date:   2016-12-28T17:47:44Z

    NIFI-1856 ExecuteStreamCommand Needs to Consume Standard Error

----


---
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 issue #1364: NIFI-1856 ExecuteStreamCommand Needs to Consume Standard E...

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on the issue:

    https://github.com/apache/nifi/pull/1364
  
    @trixpan or @danoyoung if you can help review it and provide feedback that would be great. This processor is always a tough one to test well.


---

[GitHub] nifi pull request #1364: NIFI-1856 ExecuteStreamCommand Needs to Consume Sta...

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

    https://github.com/apache/nifi/pull/1364#discussion_r101328875
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteStreamCommand.java ---
    @@ -342,16 +393,45 @@ public void onTrigger(ProcessContext context, final ProcessSession session) thro
                     final InputStream pis = process.getInputStream();
                     final InputStream pes = process.getErrorStream();
                     final BufferedInputStream bis = new BufferedInputStream(pis);
    +                final BufferedInputStream bes = new BufferedInputStream(pes);
                     final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(pes))) {
                 int exitCode = -1;
                 final BufferedOutputStream bos = new BufferedOutputStream(pos);
    +            final StringBuilder strBldr = new StringBuilder();
                 FlowFile outputFlowFile = putToAttribute ? inputFlowFile : session.create(inputFlowFile);
    +            FlowFile errorFlowFile=null;
    +            FlowWriterThread flowWriter = null;
    +            if (REDIRECT_ERROR_ERROR_STREAM.equals(redirectErrorStream)) {
    +                 errorFlowFile = session.create(inputFlowFile);
    +                flowWriter = new FlowWriterThread(errorFlowFile, session, bes);
    +                this.executor.submit(flowWriter);
    +            }
    +            //if redirect error stream is set to log, then write the error to nifi component log.
    +            if (REDIRECT_ERROR_LOG.equals(redirectErrorStream)) {
    +                this.executor.submit(new Runnable() {
    +                    @Override
    +                    public void run() {
    +                       try (final BufferedReader reader = new BufferedReader(new InputStreamReader(pes))) {
    +                            String line;
    +                            while ((line = bufferedReader.readLine()) != null) {
    +                                 logger.warn("ExecuteStreamCommand :"+line);
    +                                 strBldr.append(line).append("\n");
    --- End diff --
    
    I think this probably warrants its own jira as it was existing behavior, I'm going to write it up separately


---
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 #1364: NIFI-1856 ExecuteStreamCommand Needs to Consume Sta...

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

    https://github.com/apache/nifi/pull/1364#discussion_r101158900
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteStreamCommand.java ---
    @@ -287,6 +311,32 @@ protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String
             .build();
         }
     
    +    @OnScheduled
    +    public void setupExecutor(final ProcessContext context) {
    +        executor = Executors.newFixedThreadPool(context.getMaxConcurrentTasks() * 2, new ThreadFactory() {
    +            private final ThreadFactory defaultFactory = Executors.defaultThreadFactory();
    +
    +            @Override
    +            public Thread newThread(final Runnable r) {
    +                final Thread t = defaultFactory.newThread(r);
    +                t.setName("ExecuteStreamCommand " + getIdentifier() + " Task");
    +                return t;
    +            }
    +        });
    +    }
    +
    +    @OnUnscheduled
    --- End diff --
    
    @rkarthik29 
    
    OnUnscheduled runs before all the executing threads are complete, I think it would be safer to use OnStopped to shutdown the executor


---
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 issue #1364: NIFI-1856 ExecuteStreamCommand Needs to Consume Standard E...

Posted by danoyoung <gi...@git.apache.org>.
Github user danoyoung commented on the issue:

    https://github.com/apache/nifi/pull/1364
  
    Any updates on the PR?  we see the same described activity with ExecuteStreamCommand, and this would be a nice addition in the next release.


---

[GitHub] nifi pull request #1364: NIFI-1856 ExecuteStreamCommand Needs to Consume Sta...

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

    https://github.com/apache/nifi/pull/1364#discussion_r101160112
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteStreamCommand.java ---
    @@ -342,16 +393,45 @@ public void onTrigger(ProcessContext context, final ProcessSession session) thro
                     final InputStream pis = process.getInputStream();
                     final InputStream pes = process.getErrorStream();
                     final BufferedInputStream bis = new BufferedInputStream(pis);
    +                final BufferedInputStream bes = new BufferedInputStream(pes);
                     final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(pes))) {
                 int exitCode = -1;
                 final BufferedOutputStream bos = new BufferedOutputStream(pos);
    +            final StringBuilder strBldr = new StringBuilder();
                 FlowFile outputFlowFile = putToAttribute ? inputFlowFile : session.create(inputFlowFile);
    +            FlowFile errorFlowFile=null;
    +            FlowWriterThread flowWriter = null;
    +            if (REDIRECT_ERROR_ERROR_STREAM.equals(redirectErrorStream)) {
    +                 errorFlowFile = session.create(inputFlowFile);
    +                flowWriter = new FlowWriterThread(errorFlowFile, session, bes);
    +                this.executor.submit(flowWriter);
    +            }
    +            //if redirect error stream is set to log, then write the error to nifi component log.
    +            if (REDIRECT_ERROR_LOG.equals(redirectErrorStream)) {
    +                this.executor.submit(new Runnable() {
    +                    @Override
    +                    public void run() {
    +                       try (final BufferedReader reader = new BufferedReader(new InputStreamReader(pes))) {
    +                            String line;
    +                            while ((line = bufferedReader.readLine()) != null) {
    +                                 logger.warn("ExecuteStreamCommand :"+line);
    +                                 strBldr.append(line).append("\n");
    --- End diff --
    
    It looks like we're only going to use the first 4000 characters of strBldr, we might want to preemptively throw away anything before that so we don't have to store all the output in memory


---
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 #1364: NIFI-1856 ExecuteStreamCommand Needs to Consume Sta...

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

    https://github.com/apache/nifi/pull/1364#discussion_r104979167
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteStreamCommand.java ---
    @@ -287,6 +311,32 @@ protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String
             .build();
         }
     
    +    @OnScheduled
    +    public void setupExecutor(final ProcessContext context) {
    +        executor = Executors.newFixedThreadPool(context.getMaxConcurrentTasks() * 2, new ThreadFactory() {
    +            private final ThreadFactory defaultFactory = Executors.defaultThreadFactory();
    +
    +            @Override
    +            public Thread newThread(final Runnable r) {
    +                final Thread t = defaultFactory.newThread(r);
    +                t.setName("ExecuteStreamCommand " + getIdentifier() + " Task");
    +                return t;
    +            }
    +        });
    +    }
    +
    +    @OnUnscheduled
    --- End diff --
    
    change has been done and submitted to git.


---
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 #1364: NIFI-1856 ExecuteStreamCommand Needs to Consume Sta...

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

    https://github.com/apache/nifi/pull/1364#discussion_r101690678
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteStreamCommand.java ---
    @@ -287,6 +311,32 @@ protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String
             .build();
         }
     
    +    @OnScheduled
    +    public void setupExecutor(final ProcessContext context) {
    +        executor = Executors.newFixedThreadPool(context.getMaxConcurrentTasks() * 2, new ThreadFactory() {
    +            private final ThreadFactory defaultFactory = Executors.defaultThreadFactory();
    +
    +            @Override
    +            public Thread newThread(final Runnable r) {
    +                final Thread t = defaultFactory.newThread(r);
    +                t.setName("ExecuteStreamCommand " + getIdentifier() + " Task");
    +                return t;
    +            }
    +        });
    +    }
    +
    +    @OnUnscheduled
    --- End diff --
    
    will do the change and submit.


---
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 issue #1364: NIFI-1856 ExecuteStreamCommand Needs to Consume Standard E...

Posted by joewitt <gi...@git.apache.org>.
Github user joewitt commented on the issue:

    https://github.com/apache/nifi/pull/1364
  
    @mattyb149 any chance you'll have time to look through this ?  It looks like a great contrib.  Enough shell/bashness that I'm not entirely confident in validating it.


---
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 issue #1364: NIFI-1856 ExecuteStreamCommand Needs to Consume Standard E...

Posted by trixpan <gi...@git.apache.org>.
Github user trixpan commented on the issue:

    https://github.com/apache/nifi/pull/1364
  
    @brosander are you still planning to review this at some stage? Happy to try to help if needed.
    
    Cheers!


---
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 issue #1364: NIFI-1856 ExecuteStreamCommand Needs to Consume Standard E...

Posted by brosander <gi...@git.apache.org>.
Github user brosander commented on the issue:

    https://github.com/apache/nifi/pull/1364
  
    Reviewing


---
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.
---