Class FileLockHolder
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.persistence.FileLockHolder
-
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
CdcFileLockHolder,GridCacheDatabaseSharedManager.NodeFileLockHolder
public abstract class FileLockHolder extends Object implements AutoCloseable
Abstract file lock holder. Implementations should providelockInfo()that will appear in error message for concurrent processes that will try to lock the same file andwarningMessage(String)to print on each lock try.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFileLockHolder(String rootDir, IgniteLogger log)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Closes file channelbooleanisLocked()Locked or not.abstract StringlockInfo()This info will appear in error message of concurrent processes that will try to lock on the same file.StringlockPath()voidrelease()Releases file lockvoidtryLock(long lockWaitTimeMillis)protected abstract StringwarningMessage(String lockInfo)
-
-
-
Constructor Detail
-
FileLockHolder
protected FileLockHolder(String rootDir, IgniteLogger log)
- Parameters:
rootDir- Root directory for lock file.log- Log.
-
-
Method Detail
-
lockInfo
public abstract String lockInfo()
This info will appear in error message of concurrent processes that will try to lock on the same file.- Returns:
- Lock info to store in the file.
-
warningMessage
protected abstract String warningMessage(String lockInfo)
- Parameters:
lockInfo- Existing lock info.- Returns:
- Warning message.
-
tryLock
public void tryLock(long lockWaitTimeMillis) throws IgniteCheckedException- Parameters:
lockWaitTimeMillis- During which time thread will try capture file lock.- Throws:
IgniteCheckedException- If failed to capture file lock.
-
isLocked
public boolean isLocked()
Locked or not.
-
release
public void release()
Releases file lock
-
close
public void close()
Closes file channel- Specified by:
closein interfaceAutoCloseable
-
lockPath
public String lockPath()
- Returns:
- Absolute path to lock file.
-
-