org.apache.ignite.internal.processors.cache.persistence

## 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 provide `lockInfo()` that will appear in error message for concurrent processes that will try to lock the same file and `warningMessage(String)` to print on each lock try.

See Also:
  `GridCacheDatabaseSharedManager.NodeFileLockHolder`

### Constructor Summary

Constructors
`protected` `FileLockHolder(String rootDir, IgniteLogger log)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`void` `close()` Closes file channel
`boolean` `isLocked()` Locked or not.
`abstract String` `lockInfo()` This info will appear in error message of concurrent processes that will try to lock on the same file.
`String` `lockPath()`
`void` `release()` Releases file lock
`void` `tryLock(long lockWaitTimeMillis)`
`protected abstract String` `warningMessage(String lockInfo)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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:
  `close` in interface `AutoCloseable`

#### lockPath

    public String lockPath()

Returns:
  Absolute path to lock file.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022