Add DirectoryListener - #764
Conversation
|
functional review: @TobiasNx (and maybe @fsteeg as this PR is supposed to be part of a workflow in the RPB context). |
|
@fsteeg and I tested it. I followed your example: Your example flux with When changing What I currently also do not understand is how I am able to recognize the filenames to further process the changed or created files. What is the output of |
Is there something missing in the description, something unclear? Did you read it? It begins with:
Did you initialize |
|
I added my test as runner example, so that you can check this: 759ce79 By the way, if the intended directory is a file instead the listener seems also to run. I am not sure if that is intended. Documentation is fine. +1 for this. |
759ce79 to
83ffeee
Compare
|
@TobiasNx can you add your test again - I've force pushed over it.
I don't understand this. Do you mean, you create a directory and it's passed to receiver? That shouldn't happen! |
- improve doc - test removing a file
83ffeee to
87f9be4
Compare
|
If you use instead |
That's the expected behaviour - if you mean that this filename is passed. Because it is a filename, isnt' it? |
| @@ -0,0 +1,5 @@ | |||
| default infile = FLUX_DIR + "tmp"; | |||
There was a problem hiding this comment.
This path should point to a directory but it seems that it does not through an error if it points to a file instead of a directory.
I thought that this should be tmp/ and breaks if it points to a file.
There was a problem hiding this comment.
#775 this pr shows the scenario when the input is a file-path instead of an directory path
| default infile = FLUX_DIR + "tmp"; | ||
| infile| | ||
| listen-directory| | ||
| write (FLUX_DIR + "result.txt") |
There was a problem hiding this comment.
I would change this to print before merging. write is currently only used to highlight issue with the directory listener mentioned here: #764 (comment)
There was a problem hiding this comment.
This example should highlight the problem with the writing that I reported mentioned here: #764 (comment)
@dr0i see my inline comment and the upbranched PR #775 I would expect that if the input is a filepath instead of an directory path that an exception is thrown. Also see my inline comment with regard to the problem when writing. |
|
In order to reduce the noise, I provide a structured list of all of my findings:
Logging
Exceptiontobias@hbz-hp:~/temp$ '/home/tobias/git/metafacture-core/metafacture-runner/build/install/metafacture-core/flux.sh' directoryListener.flux
|
See #702.
This PR works in principle.
Be aware that there is a bug regarding the WatchService that can result in a loss of awareness of created files, e.g. if these files are created too fast in a row, or e.g. by moving a whole directory with files in it to the directory which is listened to: that directory would be watched, but the files in there won't be recognized. So it's not as
inotifyin unix contexts - it only comes close to it.You may want to test it like this:
./gradlew assembleDist(in the root of this branch to build the runner)cd ./metafacture-runner/build/distributions/tar xfz metafacture-core-702-addDirectoryListener-SNAPSHOT-dist.tar.gzmkdir tmp(creates the directory to listen to)metafacture-core-702-addDirectoryListener-SNAPSHOT-dist/flux.sh directoryListener.fluxto execute the FLUXtouch 1 2 3 4 5 6 7 tmp/to create some filesYou should see as output the names of the files with absolute path (which could be given in the FLUX to
open-file) and some logs (which are not going to the piped flux-command (as e.g.open-file)) are printed to stdout.(Interestingly , you see that even "touch"ing 7 files consecutively the WatchService is fast enough to observe the creation of these files.)
If you want the listener to go down: trigger it with the specially named file:
touch shutdownEtlNowWe may want to discuss if it's necessary to improve the behaviour by building some workarounds. One idea would be to just traverse the given directory every n-th second and notate the filenames, if any new appear, to a Map and push these down the pipe. This would guarantee to not miss one file (at the cost of not instantly getting the filename if one was created.)