Well... there is one thing with my solution. I implemented it using native
code since I found no way to do it in Java :(

Here is an excerpt from 'man 2 creat':

...O_EXCL is broken on  NFS  file systems, programs which rely on it for
performing locking tasks will contain a race condition.  The solution for
performing atomic file locking using a lockfile is to create a unique file
on the same fs  (e.g.,  incorporating  hostname and pid), use link(2) to
make a link to the lockfile. If link() returns 0, the lock is successful.
Otherwise, use stat(2) on the unique file to check if its  link count has
increased to 2, in which case the lock is also successful....

This is exactly what I did for locking. I am attaching code that solved the
problem for me (my OS is Linux).

By the way, maybe somebody knows why almost all classes / methods in Lucene
are final? I would surely prefer to inherit from FSDirectory instead of
writing a wrapper around it.

Cheers,
Stas.

----- Original Message -----
From: "Terry Steichen" <[EMAIL PROTECTED]>
To: "Lucene Users List" <[EMAIL PROTECTED]>
Sent: Friday, October 11, 2002 8:42 PM
Subject: Re: FileNotFoundException while indexing


> Stas,
>
> Would you be able/willing to share that improved Directory with the list?
>
> Regards,
>
> Terry
>

Attachment: FSLockService.java
Description: Binary data

Attachment: LockingFSDirectory.java
Description: Binary data

Attachment: FSLockService_NativeLockService.h
Description: Binary data

Attachment: LockService.c
Description: Binary data

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to