| java.lang.Object org.griphyn.vdl.util.FileHelper org.griphyn.vdl.util.LockFileLock
LockFileLock | public class LockFileLock extends FileHelper (Code) | | This class implements file locking using explicit lock files. Some
effort was taken to permit some NFS alleviation of problems. However,
all locking is exclusive, and may result in termination for failure
to obtain a lock due to the presence of a lock file.
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: java.io.File See Also: LockHelper |
Constructor Summary | |
public | LockFileLock(String basename) Primary ctor: obtain access to a database cycle via basename. |
Method Summary | |
public synchronized boolean | closeReader(File r) Closes a previously obtained reader, and releases internal
locking resources. | public synchronized boolean | closeWriter(File w) Closes a previously obtained writer, and releases internal
locking resources. | public synchronized File | openReader() Opens a reader for the basename, adjusting the database cycles. | public synchronized File | openWriter() Opens a writer for the basename, adjusting the database cycles
The access is exclusive, and cannot be shared with readers nor
writers. |
LockFileLock | public LockFileLock(String basename)(Code) | | Primary ctor: obtain access to a database cycle via basename.
Parameters: basename - is the name of the database without digit suffix. |
closeReader | public synchronized boolean closeReader(File r)(Code) | | Closes a previously obtained reader, and releases internal
locking resources. Only if the reader was found in the internal
state, any closing of the stream will be attempted.
Parameters: r - is the reader that was created by LockFileLock.openReader(). true, if unlocking went smoothly, or false in the presenceof an error. The only error that can happen it to use a Fileinstance which was not returned by this instance. See Also: LockFileLock.openReader() |
closeWriter | public synchronized boolean closeWriter(File w)(Code) | | Closes a previously obtained writer, and releases internal
locking resources. Error conditions can be either a missing
instance that passed, or the inability to update the cursor file.
Parameters: w - is the instance that was returned by LockFileLock.openWriter(). true, if the closing went smoothly, false in the presenceof an error. See Also: LockFileLock.openWriter() |
openReader | public synchronized File openReader()(Code) | | Opens a reader for the basename, adjusting the database cycles.
The access can be shared with other simultaneous readers.
a reader opened to the basename, or null for failure. See Also: LockFileLock.closeReader(File) |
openWriter | public synchronized File openWriter()(Code) | | Opens a writer for the basename, adjusting the database cycles
The access is exclusive, and cannot be shared with readers nor
writers.
a writer opened for the basename, or null for failure. See Also: LockFileLock.closeWriter(File) |
|
|