-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NIFI-4184: PutHDFS Processor Expression language TRUE on REMOTE_GROUP & REMOTE_OWNER #2007
Conversation
…order to achieve it i put expressionLanguageSupported(true) on the PropertyDescriptor of REMOTE_GROUP and REMOTE_OWNER Signed-off-by: Davide <davidde85@hotmail.it>
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:
|
@ijokarumawak Thank you so much! I have a question. Why did not you enable the EL in PutHDFS REMOTE_OWNER and GROUP_OWNER? |
@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. |
…order to achieve it i put expressionLanguageSupported(true) on the PropertyDescriptor of REMOTE_GROUP and REMOTE_OWNER Signed-off-by: Davide <davidde85@hotmail.it>
Thank you so much! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@panelladavide Thanks for the updates! I tested with my Hadoop cluster, basically it works as expected, but I found minor issue with EL returning an empty string. Please update it once again, and it will be ready to be merged. Thanks a lot!
@@ -352,7 +354,7 @@ public void process(InputStream in) throws IOException { | |||
+ " to its final filename"); | |||
} | |||
|
|||
changeOwner(context, hdfs, copyFile); | |||
changeOwner(context, hdfs, copyFile,flowFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trivial, please add a whitespace between arguments.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove these old lines. We don't have to keep old code unless if there's a strong needs.
// 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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;
…order to achieve it i put expressionLanguageSupported(true) on the PropertyDescriptor of REMOTE_GROUP and REMOTE_OWNER Signed-off-by: Davide <davidde85@hotmail.it>
@panelladavide LGTM, +1. I'm going to merge. Thanks for your contribution! |
Thanks for your help and for your patience! Why AppVeyor build failed? When Nifi release a new release? |
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. |
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 davidde85@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:
For documentation related changes:
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.