You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by mosermw <gi...@git.apache.org> on 2017/03/30 15:04:11 UTC

[GitHub] nifi pull request #1637: NIFI-3648 removed cluster message copying when not ...

GitHub user mosermw opened a pull request:

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

    NIFI-3648 removed cluster message copying when not in debug mode

    I expect NIFI-3648 could have several PRs, and that they will not be included in 1.2.0 release, so review of this can be delayed until the rest of that ticket is PRed and reviewed.  I just wanted to get this in so I don't forget.
    
    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:
    - [x] Is there a JIRA ticket associated with this PR? Is it referenced 
         in the commit message?
    
    - [x] 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.
    
    - [x] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    - [x] Is your initial contribution a single, squashed commit?
    
    ### For code changes:
    - [x] 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/mosermw/nifi nifi-3648-1

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

    https://github.com/apache/nifi/pull/1637.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 #1637
    
----
commit 55d93ccbec8fd7eaede0759e7abb550c75d36a63
Author: Mike Moser <mo...@apache.org>
Date:   2017-03-30T14:34:26Z

    NIFI-3648 removed message copying when not in debug mode

----


---
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 #1637: NIFI-3648 removed cluster message copying when not in debu...

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

    https://github.com/apache/nifi/pull/1637
  
    Bump.  I had forgotten about this, but it looks like it can still merge cleanly.


---

[GitHub] nifi issue #1637: NIFI-3648 removed cluster message copying when not in debu...

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

    https://github.com/apache/nifi/pull/1637
  
    @mosermw sorry about the delay. The changes do look good... it looks like I'd reviewed on Mar. 30 and then must have forgotten it. But was able to cleanly rebase against master and verify that all looks good. Definitely a nice improvement. +1 merged to master.


---

[GitHub] nifi issue #1637: NIFI-3648 removed cluster message copying when not in debu...

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

    https://github.com/apache/nifi/pull/1637
  
    @markap14 looks like the adjustment was made.  Is this good to go?


---
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 #1637: NIFI-3648 removed cluster message copying when not in debu...

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

    https://github.com/apache/nifi/pull/1637
  
    @mosermw good catch. This should definitely be cleaned up as well!


---
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 #1637: NIFI-3648 removed cluster message copying when not ...

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

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


---

[GitHub] nifi pull request #1637: NIFI-3648 removed cluster message copying when not ...

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

    https://github.com/apache/nifi/pull/1637#discussion_r109018746
  
    --- Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java ---
    @@ -134,15 +132,21 @@ public void dispatchRequest(final Socket socket) {
     
                 // unmarshall message
                 final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller();
    -            final InputStream inStream = socket.getInputStream();
    -            final CopyingInputStream copyingInputStream = new CopyingInputStream(inStream, maxMsgBuffer); // don't copy more than 1 MB
    +            final ByteCountingInputStream countingIn = new ByteCountingInputStream(socket.getInputStream());
    +            InputStream wrappedInStream = countingIn;
    +            if (logger.isDebugEnabled()) {
    +                final int maxMsgBuffer = 1024 * 1024;   // don't buffer more than 1 MB of the message
    +                final CopyingInputStream copyingInputStream = new CopyingInputStream(wrappedInStream, maxMsgBuffer);
    +                wrappedInStream = copyingInputStream;
    +            }
     
                 final ProtocolMessage request;
                 try {
    -                request = unmarshaller.unmarshal(copyingInputStream);
    +                request = unmarshaller.unmarshal(wrappedInStream);
                 } finally {
    -                receivedMessage = copyingInputStream.getBytesRead();
                     if (logger.isDebugEnabled()) {
    --- End diff --
    
    Excellent!  I thought of using instanceof CopyingInputStream but didn't think it would help.  The potential race condition makes it useful and necessary.  I pushed a fix, will squash if needed.


---
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 #1637: NIFI-3648 removed cluster message copying when not ...

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

    https://github.com/apache/nifi/pull/1637#discussion_r108993347
  
    --- Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/main/java/org/apache/nifi/cluster/protocol/impl/SocketProtocolListener.java ---
    @@ -134,15 +132,21 @@ public void dispatchRequest(final Socket socket) {
     
                 // unmarshall message
                 final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller();
    -            final InputStream inStream = socket.getInputStream();
    -            final CopyingInputStream copyingInputStream = new CopyingInputStream(inStream, maxMsgBuffer); // don't copy more than 1 MB
    +            final ByteCountingInputStream countingIn = new ByteCountingInputStream(socket.getInputStream());
    +            InputStream wrappedInStream = countingIn;
    +            if (logger.isDebugEnabled()) {
    +                final int maxMsgBuffer = 1024 * 1024;   // don't buffer more than 1 MB of the message
    +                final CopyingInputStream copyingInputStream = new CopyingInputStream(wrappedInStream, maxMsgBuffer);
    +                wrappedInStream = copyingInputStream;
    +            }
     
                 final ProtocolMessage request;
                 try {
    -                request = unmarshaller.unmarshal(copyingInputStream);
    +                request = unmarshaller.unmarshal(wrappedInStream);
                 } finally {
    -                receivedMessage = copyingInputStream.getBytesRead();
                     if (logger.isDebugEnabled()) {
    --- End diff --
    
    We should probably update this to be:
    `if (logger.isDebugEnabled() && wrappedInStream instanceof CopyingInputStream) {`
    
    As is, if a user changes logback.xml to set the logger to debug while this code is executing, it could result in the first call to logger.isDebugEnabled() returning false, in which case wrappedInStream would be a ByteCountingInputStream. then, at this point, it checks if logger.isDebugEnabled() and now it's true. As a result we try to cast ByteCountingInputStream to CopyingInputStream, so it would throw a ClassCastException.


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