Conversation
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for introducing this new component @kulikg!
The general implementation looks good, I noted a few questions about property configuration and error handling.
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
| REL_FAILURE, | ||
| REL_INPUT_FAILURE | ||
| ))); | ||
| static final PropertyDescriptor RECORD_READER = new PropertyDescriptor.Builder() |
There was a problem hiding this comment.
This property descriptor declaration should be moved up in the file, following after the SMB_CLIENT_PROVIDER_SERVICE.
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
| } catch (Exception e) { | ||
| handleInputError(e, session, flowFile); | ||
| } finally { | ||
| session.remove(flowFile); |
There was a problem hiding this comment.
It seems like the original FlowFile should be routed on failures, instead of cloning and creating a new FlowFile. Following this approach, the input FlowFile would be removed only on a successful fetch.
| final SmbClientProviderService clientProviderService = | ||
| context.getProperty(SMB_CLIENT_PROVIDER_SERVICE).asControllerService(SmbClientProviderService.class); | ||
|
|
||
| try (SmbClientService client = clientProviderService.getClient()) { |
There was a problem hiding this comment.
The current implementation repeatedly calls getClient() when using record-oriented processing. It would be more efficient to move the retrieval of the SmbClientService out of this method.
| session.putAttribute(outFlowFile, ERROR_CODE_ATTRIBUTE, getErrorCode(e)); | ||
| session.putAttribute(outFlowFile, ERROR_MESSAGE_ATTRIBUTE, e.getMessage()); |
There was a problem hiding this comment.
The return value from putAttribute() needs to be assigned so that the session is working with the most recent FlowFile reference object.
In general, method arguments should be declared as final, but in this case, the outFlowFile variable could be reassigned:
| session.putAttribute(outFlowFile, ERROR_CODE_ATTRIBUTE, getErrorCode(e)); | |
| session.putAttribute(outFlowFile, ERROR_MESSAGE_ATTRIBUTE, e.getMessage()); | |
| outFlowFile = session.putAttribute(outFlowFile, ERROR_CODE_ATTRIBUTE, getErrorCode(e)); | |
| outFlowFile = session.putAttribute(outFlowFile, ERROR_MESSAGE_ATTRIBUTE, e.getMessage()); |
There was a problem hiding this comment.
I think the test framework should complain about this too.
There was a problem hiding this comment.
It might be difficult to implement this correctly, but it could be a useful addition under a separate issue.
|
|
||
| private void handleInputError(Exception exception, ProcessSession session, FlowFile flowFile) { | ||
| if (exception instanceof IOException || exception instanceof MalformedRecordException || exception instanceof SchemaNotFoundException) { | ||
| getLogger().error("Couldn't read file metadata content as records from incoming flowfile", exception); |
There was a problem hiding this comment.
Recommend adjusting the wording and including the FlowFile in the log for troubleshooting:
| getLogger().error("Couldn't read file metadata content as records from incoming flowfile", exception); | |
| getLogger().error("Failed to read input records {}", flowFile, exception); |
| if (exception instanceof IOException || exception instanceof MalformedRecordException || exception instanceof SchemaNotFoundException) { | ||
| getLogger().error("Couldn't read file metadata content as records from incoming flowfile", exception); | ||
| } else { | ||
| getLogger().error("Unexpected error while processing incoming flowfile", exception); |
There was a problem hiding this comment.
Recommend adjusting the wording and including the FlowFile:
| getLogger().error("Unexpected error while processing incoming flowfile", exception); | |
| getLogger().error("Failed to read input {}", flowFile, exception); |
| return Optional.ofNullable(exception instanceof SmbException ? (SmbException) exception : null) | ||
| .map(SmbException::getErrorCode) | ||
| .map(String::valueOf) | ||
| .orElse("N/A"); |
There was a problem hiding this comment.
The use of N/A as a placeholder does not seem like the best option. If -1 does not already have special meaning from the SmbException, that is one option. Otherwise, some other negative number seems best, or perhaps this method should return null instead.
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Show resolved
Hide resolved
...ifi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/ListSmb.java
Outdated
Show resolved
Hide resolved
...bundle/nifi-smb-client-api/src/main/java/org/apache/nifi/services/smb/SmbListableEntity.java
Outdated
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Show resolved
Hide resolved
|
@kulikg There are Checkstyle violations. Please always run |
turcsanyip
left a comment
There was a problem hiding this comment.
@kulikg Thanks for your latest changes! Please find my new comments below.
...undle/nifi-smb-smbj-client/src/main/java/org/apache/nifi/services/smb/SmbjClientService.java
Outdated
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...mb-bundle/nifi-smb-processors/src/test/java/org/apache/nifi/processors/smb/FetchSmbTest.java
Outdated
Show resolved
Hide resolved
...mb-bundle/nifi-smb-processors/src/test/java/org/apache/nifi/processors/smb/FetchSmbTest.java
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...bundle/nifi-smb-client-api/src/main/java/org/apache/nifi/services/smb/SmbListableEntity.java
Outdated
Show resolved
Hide resolved
...bundle/nifi-smb-client-api/src/main/java/org/apache/nifi/services/smb/SmbListableEntity.java
Outdated
Show resolved
Hide resolved
...ifi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/ListSmb.java
Show resolved
Hide resolved
...ifi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/ListSmb.java
Show resolved
Hide resolved
...ifi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/ListSmb.java
Outdated
Show resolved
Hide resolved
...ifi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/ListSmb.java
Outdated
Show resolved
Hide resolved
...ifi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/ListSmb.java
Outdated
Show resolved
Hide resolved
| <version>1.18.0-SNAPSHOT</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> |
There was a problem hiding this comment.
I think we no longer need this dependency.
| import org.apache.nifi.services.smb.SmbException; | ||
|
|
||
| @InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) | ||
| @Tags({"samba, smb, cifs, files", "fetch"}) |
There was a problem hiding this comment.
Not sure if this is an error - searching based on these tags still work on UI:
| @Tags({"samba, smb, cifs, files", "fetch"}) | |
| @Tags({"samba", "smb", "cifs", "files", "fetch"}) |
| sambaContainer.stop(); | ||
| } | ||
|
|
||
| protected SmbjClientProviderService configureTestRunnerForSambaDockerContainer(TestRunner testRunner) |
There was a problem hiding this comment.
| protected SmbjClientProviderService configureTestRunnerForSambaDockerContainer(TestRunner testRunner) | |
| protected SmbjClientProviderService configureSmbClient(TestRunner testRunner) |
| testRunner.setProperty(smbjClientProviderService, DOMAIN, "domain"); | ||
| return smbjClientProviderService; |
There was a problem hiding this comment.
I think it would make sense to enable the controller service here instead of all individual tests.
| testRunner.setProperty(smbjClientProviderService, DOMAIN, "domain"); | |
| return smbjClientProviderService; | |
| testRunner.setProperty(smbjClientProviderService, DOMAIN, "domain"); | |
| testRunner.enableControllerService(smbjClientProviderService); | |
| return smbjClientProviderService; |
| allAttributes.forEach(attribute -> assertEquals( | ||
| Stream.of(attribute.get("path"), attribute.get("filename")).filter(s -> !s.isEmpty()).collect( | ||
| Collectors.joining("/")), |
There was a problem hiding this comment.
absolute.path attribute is no longer available. This test currently fails. Should remove this assertion.
...bundle/nifi-smb-client-api/src/main/java/org/apache/nifi/services/smb/SmbListableEntity.java
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...fi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java
Outdated
Show resolved
Hide resolved
...ifi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/ListSmb.java
Outdated
Show resolved
Hide resolved
turcsanyip
left a comment
There was a problem hiding this comment.
@kulikg Thanks for the review changes!
+1 LGTM
|
LGTM. I think it's ready to be merged. |
|
Thanks for your work @kulikg! |
This closes apache#6279. Signed-off-by: Tamas Palfy <tpalfy@apache.org>
Summary
NIFI-00000
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000Pull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation