LockManager
in package
This is an utility class which provides index locks processing functionality
Tags
Table of Contents
Constants
- OPTIMIZATION_LOCK_FILE = 'optimization.lock.file'
- READ_LOCK_FILE = 'read.lock.file'
- READ_LOCK_PROCESSING_LOCK_FILE = 'read-lock-processing.lock.file'
- WRITE_LOCK_FILE = 'write.lock.file'
- consts for name of file to show lock status
Methods
- deEscalateReadLock() : void
- De-escalate Read lock to shared level
- escalateReadLock() : bool
- Escalate Read lock to exclusive level
- obtainOptimizationLock() : mixed
- Obtain exclusive optimization lock on the index
- obtainReadLock() : FileInterface
- Obtain shared read lock on the index
- obtainWriteLock() : FileInterface
- Obtain exclusive write lock on the index
- releaseOptimizationLock() : void
- Release exclusive optimization lock
- releaseReadLock() : void
- Release shared read lock
- releaseWriteLock() : void
- Release exclusive write lock
- _startReadLockProcessing() : FileInterface
- Obtain the exclusive "read escalation/de-escalation" lock
- _stopReadLockProcessing() : void
- Release the exclusive "read escalation/de-escalation" lock
Constants
OPTIMIZATION_LOCK_FILE
public
mixed
OPTIMIZATION_LOCK_FILE
= 'optimization.lock.file'
READ_LOCK_FILE
public
mixed
READ_LOCK_FILE
= 'read.lock.file'
READ_LOCK_PROCESSING_LOCK_FILE
public
mixed
READ_LOCK_PROCESSING_LOCK_FILE
= 'read-lock-processing.lock.file'
WRITE_LOCK_FILE
consts for name of file to show lock status
public
mixed
WRITE_LOCK_FILE
= 'write.lock.file'
Methods
deEscalateReadLock()
De-escalate Read lock to shared level
public
static deEscalateReadLock(Directory $lockDirectory) : void
Parameters
- $lockDirectory : Directory
escalateReadLock()
Escalate Read lock to exclusive level
public
static escalateReadLock(Directory $lockDirectory) : bool
Parameters
- $lockDirectory : Directory
Return values
boolobtainOptimizationLock()
Obtain exclusive optimization lock on the index
public
static obtainOptimizationLock(Directory $lockDirectory) : mixed
Returns lock object on success and false otherwise (doesn't block execution)
Parameters
- $lockDirectory : Directory
obtainReadLock()
Obtain shared read lock on the index
public
static obtainReadLock(DirectoryInterface $lockDirectory) : FileInterface
It doesn't block other read or update processes, but prevent index from the premature cleaning-up
Parameters
- $lockDirectory : DirectoryInterface
Tags
Return values
FileInterfaceobtainWriteLock()
Obtain exclusive write lock on the index
public
static obtainWriteLock(Directory $lockDirectory) : FileInterface
Parameters
- $lockDirectory : Directory
Tags
Return values
FileInterfacereleaseOptimizationLock()
Release exclusive optimization lock
public
static releaseOptimizationLock(Directory $lockDirectory) : void
Parameters
- $lockDirectory : Directory
releaseReadLock()
Release shared read lock
public
static releaseReadLock(Directory $lockDirectory) : void
Parameters
- $lockDirectory : Directory
releaseWriteLock()
Release exclusive write lock
public
static releaseWriteLock(Directory $lockDirectory) : void
Parameters
- $lockDirectory : Directory
_startReadLockProcessing()
Obtain the exclusive "read escalation/de-escalation" lock
private
static _startReadLockProcessing(Directory $lockDirectory) : FileInterface
Required to protect the escalate/de-escalate read lock process on GFS (and potentially other) mounted filesystems.
Why we need this: While GFS supports cluster-wide locking via flock(), it's implementation isn't quite what it should be. The locking semantics that work consistently on a local filesystem tend to fail on GFS mounted filesystems. This appears to be a design defect in the implementation of GFS. How this manifests itself is that conditional promotion of a shared lock to exclusive will always fail, lock release requests are honored but not immediately processed (causing erratic failures of subsequent conditional requests) and the releasing of the exclusive lock before the shared lock is set when a lock is demoted (which can open a window of opportunity for another process to gain an exclusive lock when it shoudln't be allowed to).
Parameters
- $lockDirectory : Directory
Tags
Return values
FileInterface_stopReadLockProcessing()
Release the exclusive "read escalation/de-escalation" lock
private
static _stopReadLockProcessing(Directory $lockDirectory) : void
Required to protect the escalate/de-escalate read lock process on GFS (and potentially other) mounted filesystems.
Parameters
- $lockDirectory : Directory