-
Notifications
You must be signed in to change notification settings - Fork 0
Improved overflow support #20
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
Merged
Merged
Changes from 116 commits
Commits
Show all changes
136 commits
Select commit
Hold shift + click to select a range
c1d3622
Simplify `JDKFileWatch` by moving the creation (but not start) of its…
sungshik 27cad30
Update workflow trigger for target branch `improved-overflow-support-…
sungshik 9fe5be0
Simplify class `WatchEvent` by adding a 2-arg constructor (instead of…
sungshik f559c1c
Rename method to more clearly convey what it does
sungshik a00cc9a
Reduce diff of `JDKFileWatch` simplifications
sungshik bead33e
Reduce diff of `JDKFileWatch` simplifications
sungshik 6b92693
Fix Checker Framework issue in `JDKFileWatch`
sungshik eab398f
Fix Checker Framework issue in `JDKBaseWatch`
sungshik ff91702
Remove unused fields in `JDKFileWatch`
sungshik 0185e2d
Add method `relativize` to `ActiveWatch` interface
sungshik a78409f
Add method `handleEvent` to `ActiveWatch` interface
sungshik 9607285
Add `ActiveWatch` as event handler arg to `JDK...Watch` classes
sungshik 4fb69dc
Add `ActiveWatch` as event handler arg to `Watcher`
sungshik c365b4a
Move null preprocessing of relative path back to the constructor of `…
sungshik 61c82c1
Merge branch 'improved-overflow-support/scaffolding' into improved-ov…
sungshik 53f3038
Merge pull request #18 from SWAT-engineering/improved-overflow-suppor…
sungshik 6cd7a59
Merge branch 'improved-overflow-support-main' into improved-overflow-…
sungshik 2fbabb8
Rename local variable for consistency
sungshik 340a39b
Extract internal API out of `ActiveWatch` into new `impl.EventHandlin…
sungshik 9807fdb
Add test for `relativize`
sungshik 8a43b87
Merge branch 'improved-overflow-support/richer-active-watch' into imp…
sungshik 9ef704f
Use `EventHandlingWatch` instead of `ActiveWatch` internally
sungshik 8d4dd06
Merge pull request #19 from SWAT-engineering/improved-overflow-suppor…
sungshik d52cfeb
Merge branch 'improved-overflow-support-main' into improved-overflow-…
sungshik a712a3a
Merge pull request #21 from SWAT-engineering/improved-overflow-suppor…
sungshik 04bfe11
Add `getScope` method to `ActiveWatch` interface
sungshik bcfa0dd
Add `getScope` method to `ActiveWatch` interface
sungshik c8ed7a8
Add `OverflowPolicy` enum to configure how overflow events should be …
sungshik 89e1b5f
Add overflow policy to watcher constructor
sungshik 2ff52a7
Add license
sungshik 15f8313
Add implementation of the `MEMORYLESS_RESCANS` overflow policy
sungshik bab08c0
Add auto-handling using the `MEMORYLESS_RESCANS` overflow policy to (…
sungshik a28ac94
Add function to ignore overflow events in the user-defined event hand…
sungshik 8d59be4
Fix comment
sungshik df81ecb
Improve test
sungshik d77f7b5
Add support for propagation of overflow events from a parent dir to a…
sungshik 5d6e32f
Move configuration of overflow policy to separate method
sungshik ac2e212
Remove auto-gobbling of overflow events for all overflow policies
sungshik ec79d61
Update test
sungshik 96f4f5b
Use `walkFileTree` instead of `walk` to avoid redundant retrieval of …
sungshik 67ca923
Update test
sungshik 9744874
Fix test
sungshik 4beb950
Fix issue that `MODIFIED` events were issued for directories when aut…
sungshik f7a7a34
Rename overflow auto-handling approach constants
sungshik b874834
Merge branch 'improved-overflow-support/first-overflow-policy' into i…
sungshik 1f7e366
Update test after merge
sungshik 9437eec
Add `IndexingRescanner`
sungshik b85b7bb
Add test for `IndexingRescanner`
sungshik 8ffde3b
Fix typo
sungshik 9e71ad7
Switch order of overflow auto-handler and user-defined event handler
sungshik 546fbe8
Merge pull request #24 from SWAT-engineering/improved-overflow-suppor…
sungshik 698767e
Merge branch 'improved-overflow-support-main' into improved-overflow-…
sungshik fd70359
Switch order of overflow auto-handler and user-defined event handler
sungshik b673d2a
Merge branch 'improved-overflow-support/overflow-policies-for-file-wa…
sungshik 767972d
Improve test code
sungshik c92d17f
Remove debug println
sungshik a826e44
Improve comments
sungshik d832746
Improve comments
sungshik 2aa7db2
Merge pull request #25 from SWAT-engineering/improved-overflow-suppor…
sungshik 696c3a0
Merge branch 'improved-overflow-support-main' into improved-overflow-…
sungshik d5192e7
Improve comments and rename method
sungshik eb13d91
Extract a base file visitor from the visitor in `MemorylessRescanner`
sungshik 285d92a
Integrate the usage of the base file visitor in `IndexingRescanner`
sungshik 3581cb6
Simplify generation of DELETED events
sungshik 5b94225
Extend `indexingRescanOnOverflow` test
sungshik 94c3aee
Increase sleep time in test
sungshik d51d88f
Update torture test to ignore overflows (they're auto-handled)
sungshik 671d5eb
Add `JDKFileTreeWatch`
sungshik 62f4b1c
Move `updateChildWatches` to inner class
sungshik 25d5eb7
Add comment to explain why `events` is thread-safe
sungshik b19cdaf
Improve event handler of `IndexingRescanner` (avoid double map lookup)
sungshik 924492d
Fix test: don't rely on exact numbers of events
sungshik 493165d
Fix `indexingRescanOnOverflow` test
sungshik d569c50
Merge pull request #26 from SWAT-engineering/improved-overflow-suppor…
sungshik 36c4299
Merge branch 'improved-overflow-support-main' into improved-overflow-…
sungshik 47b8a10
Use `computeIfAbsent` instead of `putIfAbsent`
sungshik 500e238
Update `JDKRecursiveDirectoryWatch`
sungshik 6a328bf
Add import
sungshik 4aed091
Improve code quality of `JDKFileTreeWatch`
sungshik 71ac833
Improve code quality of `JDKFileTreeWatch`
sungshik fa65b30
Add mechanism to avoid relativization in `JDKFileTreeWatch`
sungshik fdd24f8
Simplify relativization of paths in `JDKFileTreeWatch`
sungshik 3bdafe6
Change order of closing internal/child watches in `JDKFileTreeWatch`
sungshik 4582d23
Simplify relativization of paths in `JDKFileTreeWatch`
sungshik 6a7df86
Use file names to store child watches (instead of full paths)
sungshik e676b5f
Use `JDKFileTreeWatch`
sungshik 387e7c3
Add asynchronous bookkeeping of `CREATED` and `OVERFLOW` events
sungshik 748e8ac
Fix issue that `JDKFileTreeWatch` relied on overflow handling to pres…
sungshik 4a1423b
Add license
sungshik 1ab8f29
Make the child watches updater asynchronous
sungshik 385db76
Add code to close child watches when their directories no longer exis…
sungshik 58d9561
Remove `JDKRecursiveDirectoryWatch` (replaced by `JDKFileTreeWatch`)
sungshik c96c943
Add filtering mechanism to `Watcher` and `JDK...` classes
sungshik eca305b
Move method implementation from base class to subclass (was already o…
sungshik 408c9d7
Improve logic to close `JDK...Watch` classes (avoid event handling o…
sungshik e0f039d
Fix a few relativization issues in `JDKFileTreeWatch` and `IndexingRe…
sungshik b8adb45
Add event filter to test
sungshik bbd1d39
Add test to check if overflows are recoverd from
sungshik 02b10b7
Fix JavaDoc
sungshik 76ec380
Remove old test
sungshik 2cc3c66
Remove `trySleep` helpers
sungshik b760db9
Rename method to better convey intent
sungshik 9b58bc4
Revert change to `relativize` in `JDKFileTreeWatch` (and add comment …
sungshik 84b627b
Move closed check to `handleEvent`
sungshik e53569a
Add general `handleEvent` implementation back to the base watch
sungshik 6feac60
Fix race in closing child watches
sungshik f81df21
Add test to expose bug that `IndexingRescanner` generates events outs…
sungshik 5f7329d
Fix bug that `IndexingRescanner` generates events outside the watch s…
sungshik ecc8ee6
Remove redundant initialization statement
sungshik 214d0ac
Make a few minor improvements to improve code quality, comments, and …
sungshik 5893890
Fix initialization of `IndexingRescanner.Generator`
sungshik 98225e3
Fix initialization of `IndexingRescanner.Generator`
sungshik 79312db
Make field final
sungshik 9b0ba39
Merge pull request #28 from SWAT-engineering/improved-overflow-suppor…
sungshik 3f80e77
Merge branch 'improved-overflow-support-main' into improved-overflow-…
sungshik fd68764
Merge pull request #27 from SWAT-engineering/improved-overflow-suppor…
sungshik f5bb9a3
Fix issue in `IndexingRescanner` that `DELETED` events were sometimes…
sungshik 0979b15
Add parameterization to torture tests
sungshik 634aad3
Add extra check to let `IndexingRescanner` report failures to get las…
sungshik 4cad3cb
Replace 1-level index with 2-level index in `IndexingRescanner` to im…
sungshik 9eea3e0
Fix Checker Framework error
sungshik f84f842
Remove parameterization from test that has a non-recursive watch
sungshik ba4b7dc
Merge branch 'improved-overflow-support/parameterized-torture-tests' …
sungshik 532ff11
Make the index generic and thread-safe
sungshik 5209921
Fix Checker Framework errors
sungshik 3b9efdd
Improve comments about thread-safety of concurrent puts/removes in th…
sungshik 86d7f5e
Reduce diff
sungshik 23506ae
Improve a few comments
sungshik 61ebbb8
Merge pull request #29 from SWAT-engineering/improved-overflow-suppor…
DavyLandman 7b26f57
Update README to mention auto-handlers for overflows
sungshik 12d3154
Clarify wording about overflows in README
sungshik 6a2ff16
Rename OnOverflow.java to Approximation.java
sungshik 28420e0
Rename `OnOverflow` to `Approximation`
sungshik 58472c5
Rename `DIRTY` to `DIFF`
sungshik 6f436a8
Merge pull request #30 from SWAT-engineering/improved-overflow-suppor…
DavyLandman 3afc76f
Rename `DIRTY` to `DIFF` in README
sungshik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ on: | |
| pull_request: | ||
| branches: | ||
| - main | ||
| - improved-overflow-support-main | ||
|
|
||
| jobs: | ||
| test: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| /* | ||
| * BSD 2-Clause License | ||
| * | ||
| * Copyright (c) 2023, Swat.engineering | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright notice, this | ||
| * list of conditions and the following disclaimer. | ||
| * | ||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| * this list of conditions and the following disclaimer in the documentation | ||
| * and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
| package engineering.swat.watch; | ||
|
|
||
| /** | ||
| * Constants to indicate for which regular files/directories in the scope of the | ||
| * watch an <i>approximation</i> of synthetic events (of kinds | ||
| * {@link WatchEvent.Kind#CREATED}, {@link WatchEvent.Kind#MODIFIED}, and/or | ||
| * {@link WatchEvent.Kind#DELETED}) should be issued when an overflow event | ||
| * happens. These synthetic events, as well as the overflow event itself, are | ||
| * subsequently passed to the user-defined event handler of the watch. | ||
| * Typically, the user-defined event handler can ignore the original overflow | ||
| * event (i.e., handling the synthetic events is sufficient to address the | ||
| * overflow issue), but it doesn't have to (e.g., it may carry out additional | ||
| * overflow bookkeeping). | ||
| */ | ||
| public enum OnOverflow { | ||
|
|
||
| /** | ||
| * Synthetic events are issued for <b>no regular files/directories</b> in | ||
| * the scope of the watch. Thus, the user-defined event handler is fully | ||
| * responsible to handle overflow events. | ||
| */ | ||
| NONE, | ||
|
|
||
| /** | ||
| * <p> | ||
| * Synthetic events of kinds {@link WatchEvent.Kind#CREATED} and | ||
| * {@link WatchEvent.Kind#MODIFIED}, but not | ||
| * {@link WatchEvent.Kind#DELETED}, are issued for all regular | ||
| * files/directories in the scope of the watch. Specifically, when an | ||
| * overflow event happens: | ||
| * | ||
| * <ul> | ||
| * <li>CREATED events are issued for all regular files/directories | ||
| * (overapproximation). | ||
| * <li>MODIFIED events are issued for all non-empty, regular files | ||
| * (overapproximation) but for no directories (underapproximation). | ||
| * <li>DELETED events are issued for no regular files/directories | ||
| * (underapproximation). | ||
| * </ul> | ||
| * | ||
| * <p> | ||
| * This approach is relatively cheap in terms of memory usage (cf. | ||
| * {@link #DIRTY}), but it results in a large over/underapproximation of the | ||
| * actual events (cf. DIRTY). | ||
| */ | ||
| ALL, | ||
|
|
||
|
|
||
| /** | ||
| * <p> | ||
| * Synthetic events of kinds {@link WatchEvent.Kind#CREATED}, | ||
| * {@link WatchEvent.Kind#MODIFIED}, and {@link WatchEvent.Kind#DELETED} are | ||
| * issued for dirty regular files/directories in the scope of the watch, as | ||
| * determined using <i>last-modified-times</i>. Specifically, when an | ||
| * overflow event happens: | ||
| * | ||
| * <ul> | ||
| * <li>CREATED events are issued for all regular files/directories when the | ||
| * previous last-modified-time is unknown, but the current | ||
| * last-modified-time is known (i.e., the file started existing). | ||
| * <li>MODIFIED events are issued for all regular files/directories when the | ||
| * previous last-modified-time is before the current last-modified-time. | ||
| * <li>DELETED events are issued for all regular files/directories when the | ||
| * previous last-modified-time is known, but the current | ||
| * last-modified-time is unknown (i.e., the file stopped existing). | ||
| * </ul> | ||
| * | ||
| * <p> | ||
| * To keep track of last-modified-times, an internal <i>index</i> is | ||
| * populated with last-modified-times of all regular files/directories in | ||
| * the scope of the watch when the watch is started. Each time when any | ||
| * event happens, the index is updated accordingly, so when an overflow | ||
| * event happens, last-modified-times can be compared as described above. | ||
| * | ||
| * <p> | ||
| * This approach results in a small overapproximation (cf. {@link #ALL}), | ||
| * but it is relatively expensive in terms of memory usage (cf. ALL), as the | ||
| * watch needs to keep track of last-modified-times. | ||
| */ | ||
| DIRTY | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.