I want to use the Java WatchService
to listen for changes on a big number of directories (many hundreds of thousands) but I don't know if it is appropriate for such numbers of watched directories.
Does anyone have experience with WatchService
with such numbers of directories?
If it helps, the WatchService
will be used on CentOS 6.5 with an EXT4 file system.
Thanks, Mickael
This situation is fairly common for IDEs. They often use directory watching for complex directory structures and many 10s of thousands of files.
There is two things to note:
This example tunes the system to monitor 512k files.
Like many IO operations in Java, it is wrapper around a facility which is actually implemented by the OS.