You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by brosander <gi...@git.apache.org> on 2016/12/22 18:58:27 UTC

[GitHub] nifi pull request #1356: NIFI-3249 - UpdateAttribute performance improvement...

GitHub user brosander opened a pull request:

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

    NIFI-3249 - UpdateAttribute performance improvements

    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?
    - [X] - N/A - Functionality already tested - Have you written or updated unit tests to verify your changes?
    - [X] - N/A - 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)? 
    - [X] - N/A - If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
    - [X] - N/A - If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
    - [X] - N/A - If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
    
    ### For documentation related changes:
    - [X] - N/A - 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/brosander/nifi NIFI-3249

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

    https://github.com/apache/nifi/pull/1356.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 #1356
    
----
commit 6f8e13768400a4bf04836b90ea855ed5d138db4a
Author: Bryan Rosander <br...@apache.org>
Date:   2016-12-22T17:02:31Z

    NIFI-3249 - UpdateAttribute performance improvements

----


---
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 #1356: NIFI-3249 - UpdateAttribute performance improvement...

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

    https://github.com/apache/nifi/pull/1356#discussion_r93950599
  
    --- Diff: nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java ---
    @@ -143,9 +144,10 @@ public ValidationResult validate(String subject, String input, ValidationContext
             }
         };
     
    +    public static final String DELETE_ATTRIBUTES_EXPRESSION_NAME = "Delete Attributes Expression";
         // static properties
         public static final PropertyDescriptor DELETE_ATTRIBUTES = new PropertyDescriptor.Builder()
    -            .name("Delete Attributes Expression")
    +            .name(DELETE_ATTRIBUTES_EXPRESSION_NAME)
                 .description("Regular expression for attributes to be deleted from FlowFiles.")
    --- End diff --
    
    I wanted to double check that the ordering of the delete vs update logic was preserved with what was documented but it doesn't appear to be at all. Your updates do seem to preserve the ordering as it was coded before (delete supersedes everything) but could you add a note either here or in the additional docs stating the intended order?


---
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 #1356: NIFI-3249 - UpdateAttribute performance improvement...

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

    https://github.com/apache/nifi/pull/1356#discussion_r93949217
  
    --- Diff: nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java ---
    @@ -259,6 +264,14 @@ public void onScheduled(final ProcessContext context) throws IOException {
     
                 context.getStateManager().setState(tempMap, Scope.LOCAL);
             }
    +
    +        defaultActions = getDefaultActions(context.getProperties());
    --- End diff --
    
    Unless I'm missing something, moving this initialize step to the onScheduled wouldn't affect anything regarding attribute evaluation since the evaluation of the EL isn't done until here[1]. This is just moving the iteration over all the properties values[2] from the ontrigger to onScheduled.
    
    
    [1] https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java#L608
    [2] https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java#L660


---
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 #1356: NIFI-3249 - UpdateAttribute performance improvement...

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

    https://github.com/apache/nifi/pull/1356#discussion_r93952555
  
    --- Diff: nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java ---
    @@ -259,6 +264,14 @@ public void onScheduled(final ProcessContext context) throws IOException {
     
                 context.getStateManager().setState(tempMap, Scope.LOCAL);
             }
    +
    +        defaultActions = getDefaultActions(context.getProperties());
    --- End diff --
    
    @JPercivall I think you're correct, this shouldn't impact EL evaluation.


---
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 #1356: NIFI-3249 - UpdateAttribute performance improvements

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

    https://github.com/apache/nifi/pull/1356
  
    +1
    
    Visually verified code and did a contrib-check build. In standalone tested many different updateAttribute configurations hitting: regular update, delete, stateful update, and stateful update with advanced rule. All worked as expected. Thanks @brosander I will merge it in.


---
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 #1356: NIFI-3249 - UpdateAttribute performance improvements

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

    https://github.com/apache/nifi/pull/1356
  
    Sorry @brosander but I was a bit wrong when talking about the ordering of the Delete; I should have tested first. 
    
    It appears that instead of deleting both attributes that were initially there and new attributes, it only deletes already present attributes. That is because, although it does the delete after the addAttribute, the regex is only run on the attributes that already existed[1]. So again it does keep the same ordering as before but it's contrary to what we though.
    
    Everything else looks good though. If you could change the documentation (and maybe throw in a unit test) for the delete ordering I will +1 and merge.
    
    [1] https://github.com/apache/nifi/blob/b519204602a5bd40f219f77ac556563010eca4c1/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java#L601-L601


---
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 #1356: NIFI-3249 - UpdateAttribute performance improvement...

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

    https://github.com/apache/nifi/pull/1356#discussion_r93952571
  
    --- Diff: nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java ---
    @@ -143,9 +144,10 @@ public ValidationResult validate(String subject, String input, ValidationContext
             }
         };
     
    +    public static final String DELETE_ATTRIBUTES_EXPRESSION_NAME = "Delete Attributes Expression";
         // static properties
         public static final PropertyDescriptor DELETE_ATTRIBUTES = new PropertyDescriptor.Builder()
    -            .name("Delete Attributes Expression")
    +            .name(DELETE_ATTRIBUTES_EXPRESSION_NAME)
    --- End diff --
    
    +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 #1356: NIFI-3249 - UpdateAttribute performance improvement...

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

    https://github.com/apache/nifi/pull/1356#discussion_r93956103
  
    --- Diff: nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java ---
    @@ -259,6 +264,14 @@ public void onScheduled(final ProcessContext context) throws IOException {
     
                 context.getStateManager().setState(tempMap, Scope.LOCAL);
             }
    +
    +        defaultActions = getDefaultActions(context.getProperties());
    --- End diff --
    
    Withdrawn, I hadn't followed the logic far enough, my bad


---
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 #1356: NIFI-3249 - UpdateAttribute performance improvements

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

    https://github.com/apache/nifi/pull/1356
  
    @JPercivall @mattyb149 I think I've incorporated your feedback


---
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 #1356: NIFI-3249 - UpdateAttribute performance improvement...

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

    https://github.com/apache/nifi/pull/1356#discussion_r93943395
  
    --- Diff: nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java ---
    @@ -143,9 +144,10 @@ public ValidationResult validate(String subject, String input, ValidationContext
             }
         };
     
    +    public static final String DELETE_ATTRIBUTES_EXPRESSION_NAME = "Delete Attributes Expression";
         // static properties
         public static final PropertyDescriptor DELETE_ATTRIBUTES = new PropertyDescriptor.Builder()
    -            .name("Delete Attributes Expression")
    +            .name(DELETE_ATTRIBUTES_EXPRESSION_NAME)
    --- End diff --
    
    Since you're touching this anyway, perhaps add a `.displayName(DELETE_ATTRIBUTES_EXPRESSION_NAME)` as well (if it doesn't affect existing flows, that is)


---
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 #1356: NIFI-3249 - UpdateAttribute performance improvement...

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

    https://github.com/apache/nifi/pull/1356#discussion_r94050652
  
    --- Diff: nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java ---
    @@ -259,6 +270,14 @@ public void onScheduled(final ProcessContext context) throws IOException {
     
                 context.getStateManager().setState(tempMap, Scope.LOCAL);
             }
    +
    +        defaultActions = getDefaultActions(context.getProperties());
    +        debugEnabled = getLogger().isDebugEnabled();
    +    }
    +
    +    @OnUnscheduled
    +    public void onUnScheduled() {
    +        defaultActions = null;
    --- End diff --
    
    This needs to be in the "OnStopped", not the "OnUnscheduled". "OnUnscheduled" will get executed once the user hits the "stop" button and there could still be threads running, leading to the NPE below. ("OnStopped" runs once all threads running the ontrigger have stopped)
    
    ![screen shot 2016-12-28 at 11 28 11 am](https://cloud.githubusercontent.com/assets/11302527/21526179/39ea5e8c-ccf0-11e6-8653-a3d8e7e02f04.png)



---
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 #1356: NIFI-3249 - UpdateAttribute performance improvement...

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

    https://github.com/apache/nifi/pull/1356#discussion_r93943294
  
    --- Diff: nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java ---
    @@ -259,6 +264,14 @@ public void onScheduled(final ProcessContext context) throws IOException {
     
                 context.getStateManager().setState(tempMap, Scope.LOCAL);
             }
    +
    +        defaultActions = getDefaultActions(context.getProperties());
    --- End diff --
    
    This is probably a crazy edge case, but what if the regex for Delete Attributes Expression is defined by [Expression Language using flow file attributes](https://issues.apache.org/jira/browse/NIFI-1123)? 


---
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 #1356: NIFI-3249 - UpdateAttribute performance improvement...

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

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


---
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 #1356: NIFI-3249 - UpdateAttribute performance improvement...

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

    https://github.com/apache/nifi/pull/1356#discussion_r93952654
  
    --- Diff: nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java ---
    @@ -143,9 +144,10 @@ public ValidationResult validate(String subject, String input, ValidationContext
             }
         };
     
    +    public static final String DELETE_ATTRIBUTES_EXPRESSION_NAME = "Delete Attributes Expression";
         // static properties
         public static final PropertyDescriptor DELETE_ATTRIBUTES = new PropertyDescriptor.Builder()
    -            .name("Delete Attributes Expression")
    +            .name(DELETE_ATTRIBUTES_EXPRESSION_NAME)
                 .description("Regular expression for attributes to be deleted from FlowFiles.")
    --- End diff --
    
    @JPercivall my goal was to preserve existing behavior, I was looking at what the code does, not the documentation.  I'll try to clarify both here and in the doc.


---
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 #1356: NIFI-3249 - UpdateAttribute performance improvement...

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

    https://github.com/apache/nifi/pull/1356#discussion_r94056185
  
    --- Diff: nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java ---
    @@ -259,6 +270,14 @@ public void onScheduled(final ProcessContext context) throws IOException {
     
                 context.getStateManager().setState(tempMap, Scope.LOCAL);
             }
    +
    +        defaultActions = getDefaultActions(context.getProperties());
    +        debugEnabled = getLogger().isDebugEnabled();
    +    }
    +
    +    @OnUnscheduled
    +    public void onUnScheduled() {
    +        defaultActions = null;
    --- End diff --
    
    good catch


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