6

We are using [WatchService][1] API (JDK 7) to track files created in my system. And up till now, it worked ok. Every file created on my system tracked by my program.

But we have trouble when we use NFS (the directory we track actually exist on another computer in LAN).

WatchService does not work.

Can anyone tell me how to work around this situation? How can I setup NFS to support Java 7 WatchService API or can anyone tell me a better library.

Thanks all

Sergey
  • 3,253
  • 2
  • 33
  • 55
tnk_peka
  • 1,525
  • 2
  • 15
  • 25
  • NFS is actually very problematic. Same applies to Lucene indexes on NFS mounts. You are probably out of luck here. – Michael-O Jul 24 '12 at 10:10
  • 2
    The underlying file system doesn't support it. http://stackoverflow.com/a/4231277/184998 Is there a way to force the Watch Service to fall back to polling for changes? – Adrian Cox Jul 24 '12 at 12:51
  • 1
    My advice to you is never to design or write an application that relies on shared file systems. These are for users, not code. There is just too much to deal with in the way of failure modes, and as @Michael-O says, NFS is one of the most problematic of them. – user207421 Jul 25 '12 at 00:50

1 Answers1

2

You can mix your code with Polling Watcher from OpenJDK (Polish text)

Sources

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
m1k0
  • 81
  • 1
  • 4