NIFI-5145 Made MockPropertyValue.evaluateExpressionLanguage(FlowFile able to accommodate null flowfiles the way live NiFi does.

NIFI-5145 Fixed a mistake with evaluateAttributeExpressions found in a code review.

NIFI-5145 Removed a property descriptor from GetHBase that was a duplication of the one in VisibilityFetchSupport.

NIFI-5145 Added comments in the code that were requested in the review.

NIFI-5145 Fixed check style issue.

NIFI-5145 Fixed a few improperly scoped items in ListFileTransfer that impacted the FTP processor(s).

NIFI-5145 Changed which override gets called based on code review feedback.

NIFI-5145: Reverted changes to ListFileTransfer re ExpressionLanguageScope

NIFI-5145: Removed TODO from MockPropertyValue javadoc

Signed-off-by: Matthew Burgess <mattyb149@apache.org>

This closes #2672
This commit is contained in:
Mike Thomsen 2018-05-03 06:28:45 -04:00 committed by Matthew Burgess
parent 0688363d87
commit ea41b41ede
5 changed files with 16 additions and 15 deletions

View File

@ -202,6 +202,15 @@ public class MockPropertyValue implements PropertyValue {
@Override @Override
public PropertyValue evaluateAttributeExpressions(final FlowFile flowFile) throws ProcessException { public PropertyValue evaluateAttributeExpressions(final FlowFile flowFile) throws ProcessException {
/*
* The reason for this null check is that somewhere in the test API, it automatically assumes that a null FlowFile
* should be treated as though it were evaluated with the VARIABLE_REGISTRY scope instead of the flowfile scope. When NiFi
* is running, it doesn't care when it's evaluating EL against a null flowfile. However, the testing framework currently
* raises an error which makes it not mimick real world behavior.
*/
if (flowFile == null) {
return evaluateAttributeExpressions();
}
return evaluateAttributeExpressions(flowFile, null, null); return evaluateAttributeExpressions(flowFile, null, null);
} }

View File

@ -54,7 +54,6 @@ import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext; import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult; import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.components.Validator;
import org.apache.nifi.components.state.Scope; import org.apache.nifi.components.state.Scope;
import org.apache.nifi.components.state.StateManager; import org.apache.nifi.components.state.StateManager;
import org.apache.nifi.components.state.StateMap; import org.apache.nifi.components.state.StateMap;
@ -147,14 +146,6 @@ public class GetHBase extends AbstractProcessor implements VisibilityFetchSuppor
.allowableValues(NONE, CURRENT_TIME) .allowableValues(NONE, CURRENT_TIME)
.defaultValue(NONE.getValue()) .defaultValue(NONE.getValue())
.build(); .build();
static final PropertyDescriptor AUTHORIZATIONS = new PropertyDescriptor.Builder()
.name("hbase-fetch-row-authorizations")
.displayName("Authorizations")
.description("The list of authorizations to pass to the scanner. This will be ignored if cell visibility labels are not in use.")
.required(false)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(Validator.VALID)
.build();
static final Relationship REL_SUCCESS = new Relationship.Builder() static final Relationship REL_SUCCESS = new Relationship.Builder()
.name("success") .name("success")

View File

@ -267,8 +267,7 @@ public abstract class AbstractMongoProcessor extends AbstractProcessor {
protected void writeBatch(String payload, FlowFile parent, ProcessContext context, ProcessSession session, protected void writeBatch(String payload, FlowFile parent, ProcessContext context, ProcessSession session,
Map<String, String> extraAttributes, Relationship rel) throws UnsupportedEncodingException { Map<String, String> extraAttributes, Relationship rel) throws UnsupportedEncodingException {
String charset = parent != null ? context.getProperty(CHARSET).evaluateAttributeExpressions(parent).getValue() String charset = context.getProperty(CHARSET).evaluateAttributeExpressions(parent).getValue();
: context.getProperty(CHARSET).evaluateAttributeExpressions().getValue();
FlowFile flowFile = parent != null ? session.create(parent) : session.create(); FlowFile flowFile = parent != null ? session.create(parent) : session.create();
flowFile = session.importFrom(new ByteArrayInputStream(payload.getBytes(charset)), flowFile); flowFile = session.importFrom(new ByteArrayInputStream(payload.getBytes(charset)), flowFile);

View File

@ -96,7 +96,7 @@ public class GetMongo extends AbstractMongoProcessor {
"the flowfile's body. If this field is left blank and a timer is enabled instead of an incoming connection, " + "the flowfile's body. If this field is left blank and a timer is enabled instead of an incoming connection, " +
"that will result in a full collection fetch using a \"{}\" query.") "that will result in a full collection fetch using a \"{}\" query.")
.required(false) .required(false)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
.addValidator(DOCUMENT_VALIDATOR) .addValidator(DOCUMENT_VALIDATOR)
.build(); .build();
@ -346,6 +346,7 @@ public class GetMongo extends AbstractMongoProcessor {
} }
} else { } else {
while (cursor.hasNext()) { while (cursor.hasNext()) {
final FlowFile ffPtr = input;
flowFile = session.create(); flowFile = session.create();
flowFile = session.write(flowFile, out -> { flowFile = session.write(flowFile, out -> {
String json; String json;
@ -354,7 +355,7 @@ public class GetMongo extends AbstractMongoProcessor {
} else { } else {
json = cursor.next().toJson(); json = cursor.next().toJson();
} }
out.write(json.getBytes(context.getProperty(CHARSET).evaluateAttributeExpressions().getValue())); out.write(json.getBytes(context.getProperty(CHARSET).evaluateAttributeExpressions(ffPtr).getValue()));
}); });
flowFile = session.putAllAttributes(flowFile, attributes); flowFile = session.putAllAttributes(flowFile, attributes);

View File

@ -32,6 +32,7 @@ import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext; import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult; import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.flowfile.FlowFile; import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.logging.ComponentLog; import org.apache.nifi.logging.ComponentLog;
import org.apache.nifi.processor.ProcessContext; import org.apache.nifi.processor.ProcessContext;
@ -92,7 +93,7 @@ public class PutMongo extends AbstractMongoProcessor {
+ "otherwise it is ignored. Example: _id") + "otherwise it is ignored. Example: _id")
.required(false) .required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR) .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.expressionLanguageSupported(true) .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
.build(); .build();
static final PropertyDescriptor UPDATE_QUERY = new PropertyDescriptor.Builder() static final PropertyDescriptor UPDATE_QUERY = new PropertyDescriptor.Builder()
.name("putmongo-update-query") .name("putmongo-update-query")
@ -100,7 +101,7 @@ public class PutMongo extends AbstractMongoProcessor {
.description("Specify a full MongoDB query to be used for the lookup query to do an update/upsert.") .description("Specify a full MongoDB query to be used for the lookup query to do an update/upsert.")
.required(false) .required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR) .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.expressionLanguageSupported(true) .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
.build(); .build();
static final PropertyDescriptor UPDATE_MODE = new PropertyDescriptor.Builder() static final PropertyDescriptor UPDATE_MODE = new PropertyDescriptor.Builder()