| java.lang.Object org.griphyn.vdl.util.FileHelper org.griphyn.vdl.util.FcntlFileLock
FcntlFileLock | public class FcntlFileLock extends FileHelper (Code) | | This class implements file locking using system-provided lock
functions. On unix, these may most likely include POSIX fcntl locking
calls. While such lock may on some systems be NFS-safe, networked
file locking on Linux is notoriously broken, and cannot be assumed to
work as expected.
All access to the files must go through the respective open and close
methods provided by this class in order to guarantee proper locking!
author: Jens-S. Vöckler author: Yong Zhao version: $Revision: 50 $ See Also: FcntlLock See Also: java.io.File |
Constructor Summary | |
public | FcntlFileLock(String database) Primary ctor: obtain access to a database cycle via database.
Parameters: database - is the base name of the database without thedigit suffix. |
Method Summary | |
public synchronized boolean | closeReader(File r) Closes a previously obtained reader, and releases internal locking
resources.
Parameters: r - is the reader that was created by its open operation. | public synchronized boolean | closeWriter(File w) Closes a previously obtained writer, and releases internal
locking resources.
Parameters: w - is the instance that was returned by its open operation. | public synchronized File | openReader() Opens a reader for the database, adjusting the database cycles.
The access can be shared with other simultaneous readers. | public synchronized File | openWriter() Opens a writer for the database, adjusting the database cycles
The access is exclusive, and cannot be shared with readers nor
writers. |
FcntlFileLock | public FcntlFileLock(String database)(Code) | | Primary ctor: obtain access to a database cycle via database.
Parameters: database - is the base name of the database without thedigit suffix. |
closeReader | public synchronized boolean closeReader(File r)(Code) | | Closes a previously obtained reader, and releases internal locking
resources.
Parameters: r - is the reader that was created by its open operation. true, if unlocking went smoothly, or false in the presenceof an error. See Also: FcntlFileLock.openReader() |
closeWriter | public synchronized boolean closeWriter(File w)(Code) | | Closes a previously obtained writer, and releases internal
locking resources.
Parameters: w - is the instance that was returned by its open operation. true, if the closing went smoothly, false in the presenceof an error. See Also: FcntlFileLock.openWriter() |
openReader | public synchronized File openReader()(Code) | | Opens a reader for the database, adjusting the database cycles.
The access can be shared with other simultaneous readers. The
locks on number file and database are held shared. They are
released in the close operation.
a reader opened to the database, or null for failure. See Also: FcntlFileLock.closeReader(File) |
openWriter | public synchronized File openWriter()(Code) | | Opens a writer for the database, adjusting the database cycles
The access is exclusive, and cannot be shared with readers nor
writers. Both locks are exclusive, and held through the close
operation.
a writer opened for the database, or null for failure. See Also: FcntlFileLock.closeWriter(File) |
|
|