- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.9k
NIFI-15077 : Added conflict resolution strategies for file move operations in FetchFileTransfer #10405
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
base: main
Are you sure you want to change the base?
Conversation
…ons in FetchFileTransfer - Introduced MOVE_CONFLICT_RESOLUTION property to handle filename collisions during file move - Implemented logic for conflict resolution strategies (REPLACE, RENAME, IGNORE, etc.) - Refactored filename normalization and path handling utilities - Updated FetchFTP and FetchSFTP processors for enhanced conflict resolution support - Added corresponding unit tests and utility methods for unique filename generation in conflicts
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.
Thanks for proposing this improvement @ravinarayansingh. The concept makes sense, and the basic approach looks good. I noted some recommendations on a few implementation and logging details.
| .description(String.format("Determines how to handle filename collisions when '%s' is '%s'. " + | ||
| "This setting controls behavior when the target file exists in the %s.", | 
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.
A multiline string with """description""".formatted()  can also work and make this a bit easier to read.
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.
This description can be reformatted as mentioned.
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.
@exceptionfactory code already has been updated. i do not know why it's not showing here
        
          
                ...fer/src/main/java/org/apache/nifi/processor/util/file/transfer/FileTransferConflictUtil.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...e-transfer/src/main/java/org/apache/nifi/processor/util/file/transfer/FetchFileTransfer.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...e-transfer/src/main/java/org/apache/nifi/processor/util/file/transfer/FetchFileTransfer.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...e-transfer/src/main/java/org/apache/nifi/processor/util/file/transfer/FetchFileTransfer.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
      …/src/main/java/org/apache/nifi/processor/util/file/transfer/FetchFileTransfer.java Co-authored-by: David Handermann <[email protected]>
…lictUtil - Replaced incrementing prefix-based approach with UUID prefix for unique filename generation - Simplified conflict resolution logic in FetchFileTransfer during file move operations - Improved logging consistency and updated descriptions for MOVE_DESTINATION_DIR property
| 
 Thanks for review, @exceptionfactory. | 
- Adjusted indentation for property description for better readability
- Adjusted indentation for property description for better readability
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.
Thanks for updates @ravinarayansingh, there was one previous comment remaining on description formatting, and I recommended some adjustments to the logging messages, then this should be ready to go.
        
          
                ...fer/src/main/java/org/apache/nifi/processor/util/file/transfer/FileTransferConflictUtil.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | .description(String.format("Determines how to handle filename collisions when '%s' is '%s'. " + | ||
| "This setting controls behavior when the target file exists in the %s.", | 
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.
This description can be reformatted as mentioned.
        
          
                ...e-transfer/src/main/java/org/apache/nifi/processor/util/file/transfer/FetchFileTransfer.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...e-transfer/src/main/java/org/apache/nifi/processor/util/file/transfer/FetchFileTransfer.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...e-transfer/src/main/java/org/apache/nifi/processor/util/file/transfer/FetchFileTransfer.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...e-transfer/src/main/java/org/apache/nifi/processor/util/file/transfer/FetchFileTransfer.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | getLogger().warn("Configured to {} on move conflict for {}. Original remote file will be left in place.", strategy, flowFile); | ||
| return; | 
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.
This appears to behave the same as the ignore strategy, does it fail elsewhere during processing despite the return?
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.
@exceptionfactory i have updated the code please have a look
…/src/main/java/org/apache/nifi/processor/util/file/transfer/FetchFileTransfer.java Co-authored-by: David Handermann <[email protected]>
…/src/main/java/org/apache/nifi/processor/util/file/transfer/FetchFileTransfer.java Co-authored-by: David Handermann <[email protected]>
…/src/main/java/org/apache/nifi/processor/util/file/transfer/FetchFileTransfer.java Co-authored-by: David Handermann <[email protected]>
…/src/main/java/org/apache/nifi/processor/util/file/transfer/FetchFileTransfer.java Co-authored-by: David Handermann <[email protected]>
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.
Thanks for the incremental adjustments @ravinarayansingh, it looks like just accepting the proposed changes resulted in compilation issues, and a few comments are still unaddressed. If you can work through the remaining items and update the pull request, that would be helpful.
- Moved unique filename generation method from FileTransferConflictUtil to FetchFileTransfer - Simplified conflict resolution logic by removing unused utility class
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.
Thanks for the updates @ravinarayansingh. This looks better, but handling IGNORE, REJECT, and FAIL with the same case does not seem correct. The IGNORE and NONE options should not log a warning as previously mentioned, and the other two options require routing to a different location.
| private static String generateUniqueFilename(final FileTransfer transfer, | ||
| final String path, | ||
| final String baseFileName, | ||
| final FlowFile flowFile, | ||
| final ComponentLog logger) throws IOException { | 
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.
With the log message where this is called, most of these arguments are no longer needed. On review, I recommend removing this method completely and building the filename inside the case statement block.
| 
 Thanks for the feedback, @exceptionfactory. For the other two options — REJECT and FAIL — should these also log a warning, or should they additionally route the FlowFile to a different relationship (for example, failure or reject)? | 
| 
 Yes, for IGNORE and NONE, and INFO log looks good. 
 Those options should log a warning, and route to the appropriate relationship, based on the description for each value. | 
…TE and adjusted pre-commit handling for MOVE - Centralized MOVE and DELETE completion handling with pre-commit routing for MOVE conflicts and post-commit actions for DELETE. - Introduced detailed failure reasons for enhanced debugging. - Added REL_REJECT and REL_FAILURE relationships for comprehensive failure management. - Updated unit tests to reflect the new process flow and relationships.
| Hi @exceptionfactory | 
Summary
NIFI-15077
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
./mvnw clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation