Hello all.
Will FileSystemWatcher (wrapped in the JNIWrapper) works as expected on a SMB shared drive on Windows box? I have a Java application that I want to be able to monitor a number of "watched" folders where some of which may be mapped drives (from SMB shares on linux boxes). Do I need to set something differently? My initial investigation seems to indicate that it doesn't work on that share.
Many thanks,
Ali.
Hi Ali,
By default on all NT systems FileSystemWatcher uses WinNTWatcherStrategy, which is specially designed for working on NTFS file system. This strategy also works if remote share is on NTFS file system, but it will not work for another file system. You can try another watcher strategy (for example Win9xWatcherStrategy) in your case, but this implementation is less effective.
-Serge
Thanks Serge. Do you happen to have a recommendation for monitoring a Samba share (of a Linux box) that is mounted locally on a Windows box? I can potentially use more advanced Linux kernel features such as INotify and create an event there but would rather keep my code self contained on the Windows and my Java code if possible, and still efficient, at least more than a simple periodic re-scan of the file system to find changes. I guess it all boils down to what event is triggered from the Windows OS when a Samba mounted filesystem changes. Not knowing much about the internals of Windows, I have no clue if there is such event. Do you happen to know?
Thanks
Ali.
Well, I know from our support history that it's possible to monitor file events on such Samba shares using the Win9xWatcherStrategy class. At least you can try the following code to verify that:
FileSystemWatcher watcher = new FileSystemWatcher(folder, true);
watcher.setStrategy(Win9xWatcherStrategy.class);
...
In fact this implementation (Win9xWatcherStrategy) is more efficient than the periodic re-scanning of the watched folders, because it's based on handling file system events. Though its performance greatly depends on the size of a watched folder. And you can always tune up the performance if necessary, because there are the sources of our implementation in WinPack library.
-Serge