Package com.tangosol.io.bdb
Class DatabaseFactory.EnvironmentHolder.DirectoryLock
- java.lang.Object
-
- com.tangosol.io.bdb.DatabaseFactory.EnvironmentHolder.DirectoryLock
-
- Enclosing class:
- DatabaseFactory.EnvironmentHolder
protected static class DatabaseFactory.EnvironmentHolder.DirectoryLock extends Object
Directory based lock.A single instance of the DirectoryLock is not intended for inter thread locking. Multiple instance referring to the same File should be used instead.
-
-
Field Summary
Fields Modifier and Type Field Description static String
LOCK_FILE_NAME
Name of warning file.protected File
m_dir
Directory to lock.protected FileOutputStream
m_fstreamLocked
The FileStream which the actual lock is held on.protected FileLock
m_lockDir
The actual FileLock.protected String
m_sLockText
Text to include in the lock file.
-
Constructor Summary
Constructors Constructor Description DirectoryLock(File dir, String sLockText)
Create a DirectoryLock which can be used to try to lock a directory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
finalize()
Automatically release the lock on finalization.boolean
tryLock()
Try to lock the directory.boolean
tryUnlock()
Try to unlock the directory.
-
-
-
Field Detail
-
LOCK_FILE_NAME
public static final String LOCK_FILE_NAME
Name of warning file.- See Also:
- Constant Field Values
-
m_dir
protected File m_dir
Directory to lock.
-
m_fstreamLocked
protected FileOutputStream m_fstreamLocked
The FileStream which the actual lock is held on.
-
m_lockDir
protected FileLock m_lockDir
The actual FileLock.
-
m_sLockText
protected String m_sLockText
Text to include in the lock file.
-
-
Method Detail
-
tryLock
public boolean tryLock() throws IOException
Try to lock the directory.- Returns:
- true if a lock is obtained, false if it is locked by another DirectoryLock
- Throws:
IOException
- if an IO error occurs while creating the lock file
-
tryUnlock
public boolean tryUnlock() throws IOException
Try to unlock the directory.- Returns:
- true if a lock is released, false if the directory was not locked by this DirectoryLock
- Throws:
IOException
- if an IO error occurs while deleting the lock file, the lock may be left in an unlocked state
-
-