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 SummaryFieldsModifier and TypeFieldDescriptionstatic final StringName of warning file.protected FileDirectory to lock.protected FileOutputStreamThe FileStream which the actual lock is held on.protected FileLockThe actual FileLock.protected StringText to include in the lock file.
- 
Constructor SummaryConstructorsConstructorDescriptionDirectoryLock(File dir, String sLockText) Create a DirectoryLock which can be used to try to lock a directory.
- 
Method Summary
- 
Field Details- 
LOCK_FILE_NAMEName of warning file.- See Also:
 
- 
m_dirDirectory to lock.
- 
m_fstreamLockedThe FileStream which the actual lock is held on.
- 
m_lockDirThe actual FileLock.
- 
m_sLockTextText to include in the lock file.
 
- 
- 
Constructor Details- 
DirectoryLockCreate 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 lock
- sLockText- the text to include in the lock file
 
 
- 
- 
Method Details- 
tryLockTry 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
 
- 
tryUnlockTry 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
 
- 
finalizeAutomatically 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. 
 
-