Package com.tangosol.io.bdb
Class DatabaseFactory.EnvironmentHolder.DirectoryLock
java.lang.Object
com.tangosol.io.bdb.DatabaseFactory.EnvironmentHolder.DirectoryLock
- Enclosing class:
DatabaseFactory.EnvironmentHolder
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
Modifier and TypeFieldDescriptionstatic final String
Name of warning file.protected File
Directory to lock.protected FileOutputStream
The FileStream which the actual lock is held on.protected FileLock
The actual FileLock.protected String
Text to include in the lock file. -
Constructor Summary
ConstructorDescriptionDirectoryLock
(File dir, String sLockText) Create a DirectoryLock which can be used to try to lock a directory. -
Method Summary
-
Field Details
-
LOCK_FILE_NAME
Name of warning file.- See Also:
-
m_dir
Directory to lock. -
m_fstreamLocked
The FileStream which the actual lock is held on. -
m_lockDir
The actual FileLock. -
m_sLockText
Text to include in the lock file.
-
-
Constructor Details
-
DirectoryLock
Create a DirectoryLock which can be used to try to lock a directory. The object is created in an unlocked state.- Parameters:
dir
- the directory to locksLockText
- the text to include in the lock file
-
-
Method Details
-
tryLock
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
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
-
finalize
Automatically release the lock on finalization.The OS will ensure that the lock is released regardless but this allows the lock file to be deleted as well.
-