-
Notifications
You must be signed in to change notification settings - Fork 1.1k
INT-3989: Add FileReadingMessageSource.WatchServiceDirectoryScanner
#1774
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
Conversation
Pushed some optimization and testing. |
Pushed the |
*/ | ||
public void setWatchEvents(WatchEventType... watchEvents) { | ||
Assert.notEmpty(watchEvents, "'watchEvents' must not be empty."); | ||
this.watchEvents = watchEvents; |
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.
Arrays.copyOf(watchEvents, watchEvents.length)
Pushed.
See commit comments. |
else { | ||
files.remove(file); | ||
files.add(file); | ||
} | ||
} |
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.
We should probably add a debug log here "File removed since watch event received".
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.
Indeed! 👍
JIRA: https://jira.spring.io/browse/INT-3989, https://jira.spring.io/browse/INT-3990, https://jira.spring.io/browse/INT-3988 * Deprecate top-level `WatchServiceDirectoryScanner` because of inconsistency around `Lifecycle` and shared `directory` property * Copy/paste its logic into the `FileReadingMessageSource.WatchServiceDirectoryScanner` to hide that inconsistency, but still get a gain from the `WatchService` benefits * Add support for the `StandardWatchEventKinds.ENTRY_MODIFY` and `StandardWatchEventKinds.ENTRY_DELETE` events in the `FileReadingMessageSource.WatchServiceDirectoryScanner` * Introduce `useWatchService` option to switch to the internal `FileReadingMessageSource.WatchServiceDirectoryScanner` * Make `CompositeFileListFilter` also as `ResettableFileListFilter` * Deprecate weird `FileReadingMessageSource.onSend()` method and remove its usage from tests * Modify `WatchServiceDirectoryScannerTests` for the new logic * Document changes
Optimize the `filesFromEvents()` logic replacing item with the fresh event sources. Remove the item from the result set in case of `DELETE` event, because file removal generates both `MODIFY` and `DELETE` events.
… the specific events, not only `CREATE` or all of them. * Modify tests and docs to reflect the new API
* Improve `FileReadingMessageSource.setWatchEvents()` * Add `file.exists()` before adding file from event.
With the fact of those logs provide more optimizations: * Don't register the same directory for watching: - use the `ConcurrentMap<Path, WatchKey> pathKeys` to track registrations - any modification within the directory causes the `ENTRY_MODIFY` for the directory as well. So, skip such an event exactly for the directory during `walkDirectory` * Add debug logs in case of `ENTRY_DELETE`
Pushed. |
Merged as 7b1f77a |
JIRA: https://jira.spring.io/browse/INT-3989,
https://jira.spring.io/browse/INT-3990,
https://jira.spring.io/browse/INT-3988
WatchServiceDirectoryScanner
because of inconsistency aroundLifecycle
and shareddirectory
propertyFileReadingMessageSource.WatchServiceDirectoryScanner
to hide that inconsistency, but still get a gain from theWatchService
benefitsStandardWatchEventKinds.ENTRY_MODIFY
andStandardWatchEventKinds.ENTRY_DELETE
events in theFileReadingMessageSource.WatchServiceDirectoryScanner
useWatchService
option to switch to the internalFileReadingMessageSource.WatchServiceDirectoryScanner
CompositeFileListFilter
also asResettableFileListFilter
FileReadingMessageSource.onSend()
method and remove its usage from testsWatchServiceDirectoryScannerTests
for the new logic