You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by panelladavide <gi...@git.apache.org> on 2017/07/13 14:44:04 UTC

[GitHub] nifi pull request #2007: I needed to put some attributes on REMOTE_GROUP and...

GitHub user panelladavide opened a pull request:

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

    I needed to put some attributes on REMOTE_GROUP and REMOTE_OWNER, in …

    …order to achieve it i put expressionLanguageSupported(true) on the PropertyDescriptor of REMOTE_GROUP and REMOTE_OWNER
    
    Signed-off-by: Davide <da...@hotmail.it>
    
    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/panelladavide/nifi master

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

    https://github.com/apache/nifi/pull/2007.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 #2007
    
----
commit 38e8de070ef4ae263983e6556e3f8775aa8c6746
Author: Davide <da...@hotmail.it>
Date:   2017-07-13T14:03:54Z

    I needed to put some attributes on REMOTE_GROUP and REMOTE_OWNER, in order to achieve it i put expressionLanguageSupported(true) on the PropertyDescriptor of REMOTE_GROUP and REMOTE_OWNER
    
    Signed-off-by: Davide <da...@hotmail.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 pull request #2007: NIFI-4184: PutHDFS Processor Expression language TR...

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

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


---
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 #2007: NIFI-4184: PutHDFS Processor Expression language TRUE on R...

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

    https://github.com/apache/nifi/pull/2007
  
    AppVeyor build has been failing. There are many unit tests those are not working well on Windows. We've been trying to improve it but not completed.


---
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 #2007: NIFI-4184: PutHDFS Processor Expression language TR...

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

    https://github.com/apache/nifi/pull/2007#discussion_r128689940
  
    --- Diff: nifi-nar-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/PutHDFS.java ---
    @@ -386,11 +388,14 @@ public void process(InputStream in) throws IOException {
             });
         }
     
    -    protected void changeOwner(final ProcessContext context, final FileSystem hdfs, final Path name) {
    +    protected void changeOwner(final ProcessContext context, final FileSystem hdfs, final Path name, final FlowFile flowFile) {
             try {
                 // Change owner and group of file if configured to do so
    -            String owner = context.getProperty(REMOTE_OWNER).getValue();
    -            String group = context.getProperty(REMOTE_GROUP).getValue();
    +//            String owner = context.getProperty(REMOTE_OWNER).getValue();
    +//            String group = context.getProperty(REMOTE_GROUP).getValue();
    +            String owner = context.getProperty(REMOTE_OWNER).evaluateAttributeExpressions(flowFile).getValue();
    +            String group = context.getProperty(REMOTE_GROUP).evaluateAttributeExpressions(flowFile).getValue();
    +
                 if (owner != null || group != null) {
    --- End diff --
    
    When I tested with an expression that returns no value, e.g. specify an attribute name which does not exist, then the group string became an Empty string. And the file was updated with an empty group. To avoid that, Could you add following code before this if statement? to make empty string into null:
    
    ```
                owner = owner == null || owner.isEmpty() ? null : owner;
                group = group == null || group.isEmpty() ? null : group;
    ```
    
    ![image](https://user-images.githubusercontent.com/1107620/28451433-3b1718a2-6e28-11e7-9473-282bbfcdd881.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 issue #2007: NIFI-4184: PutHDFS Processor Expression language TRUE on R...

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

    https://github.com/apache/nifi/pull/2007
  
    Thanks for your help and for your patience! Why AppVeyor build failed? When Nifi release a new release?


---
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 #2007: NIFI-4184: PutHDFS Processor Expression language TRUE on R...

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

    https://github.com/apache/nifi/pull/2007
  
    @panelladavide LGTM, +1. I'm going to merge. Thanks for your contribution!


---
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 #2007: NIFI-4184: PutHDFS Processor Expression language TRUE on R...

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

    https://github.com/apache/nifi/pull/2007
  
    @panelladavide I don't know any reason for not supporting EL with REMOTE_OWNER/GROUP. I think applying EL at incoming FlowFile level is safe, and wouldn't break anything because it just sets owner for a specific path.
    
    It would be problematic if it changes FileSystem or HdfsResources instance state those are reused from every onTrigger call. But again, setting owner should just affect the specified path, so it should be fine.
    
    I guess it's just written that way at the initial contribution and haven't been requested until now. 


---
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 #2007: NIFI-4184: PutHDFS Processor Expression language TRUE on R...

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

    https://github.com/apache/nifi/pull/2007
  
    @ijokarumawak Thank you so much! 
    As soon as I have time to code I will update my branch. 
    
    I have a question. Why did not you enable the LE in PutHDFS REMOTE_OWNER and GROUP_OWNER? 
    Is there a specific reason? 


---
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 #2007: NIFI-4184: PutHDFS Processor Expression language TR...

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

    https://github.com/apache/nifi/pull/2007#discussion_r128684359
  
    --- Diff: nifi-nar-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/PutHDFS.java ---
    @@ -352,7 +354,7 @@ public void process(InputStream in) throws IOException {
                                         + " to its final filename");
                             }
     
    -                        changeOwner(context, hdfs, copyFile);
    +                        changeOwner(context, hdfs, copyFile,flowFile);
    --- End diff --
    
    I just added a whitespace between arguments.


---
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 #2007: NIFI-4184: PutHDFS Processor Expression language TRUE on R...

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

    https://github.com/apache/nifi/pull/2007
  
    Hi @panelladavide thanks for your contribution!
    
    In order to enable Expression Language, setting expressionLanguageSupported to true is not enough. You also need to evaluate the configured EL. Plus, if you need to support EL to use FlowFile attribute, you need to pass a FlowFile (the incoming FlowFile in most cases) when EL is evaluated.
    
    Specifically, you need to modify changeOwner method:
    - Add EL evaluation like:
         ```
         String owner = context.getProperty(REMOTE_OWNER).evaluateAttributeExpressions(flowFile).getValue();
         ```
    - Add FlowFile argument, so that it can be passed to `evaluateAttributeExpressions(flowFile)`
    
    https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/PutHDFS.java#L389


---
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 #2007: NIFI-4184: PutHDFS Processor Expression language TR...

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

    https://github.com/apache/nifi/pull/2007#discussion_r128684447
  
    --- Diff: nifi-nar-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/PutHDFS.java ---
    @@ -386,11 +388,14 @@ public void process(InputStream in) throws IOException {
             });
         }
     
    -    protected void changeOwner(final ProcessContext context, final FileSystem hdfs, final Path name) {
    +    protected void changeOwner(final ProcessContext context, final FileSystem hdfs, final Path name, final FlowFile flowFile) {
             try {
                 // Change owner and group of file if configured to do so
    -            String owner = context.getProperty(REMOTE_OWNER).getValue();
    -            String group = context.getProperty(REMOTE_GROUP).getValue();
    +//            String owner = context.getProperty(REMOTE_OWNER).getValue();
    +//            String group = context.getProperty(REMOTE_GROUP).getValue();
    --- End diff --
    
    Please removed these old lines. We don't have to keep old code unless if there's a strong needs.


---
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 #2007: NIFI-4184: PutHDFS Processor Expression language TRUE on R...

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

    https://github.com/apache/nifi/pull/2007
  
    Thank you so much!


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