MediaWiki
REL1_19
|
Manage locks using a lock daemon server. More...
Public Member Functions | |
__construct (array $config) | |
Construct a new instance from configuration. | |
__destruct () | |
Make sure remaining locks get cleared for sanity. | |
Protected Member Functions | |
doLock (array $paths, $type) | |
Lock resources with the given keys and lock type. | |
doLockingRequest ($lockSrv, array $paths, $type) | |
Get a connection to a lock server and acquire locks on $paths. | |
doLockingRequestAll ($bucket, array $paths, $type) | |
Attempt to acquire locks with the peers for a bucket. | |
doUnlock (array $paths, $type) | |
Unlock resources with the given keys and lock type. | |
getBucketFromKey ($path) | |
Get the bucket for resource path. | |
getConnection ($lockSrv) | |
Get (or reuse) a connection to a lock server. | |
releaseLocks () | |
Release all locks that this session is holding. | |
sendCommand ($lockSrv, $action, $type, $values) | |
Send a command and get back the response. | |
Protected Attributes | |
$conns = array() | |
$connTimeout | |
$lockServers | |
$lockTypeMap | |
$session = '' | |
$srvsByBucket |
Manage locks using a lock daemon server.
Version of LockManager based on using lock daemon servers. This is meant for multi-wiki systems that may share files. All locks are non-blocking, which avoids deadlocks.
All lock requests for a resource, identified by a hash string, will map to one bucket. Each bucket maps to one or several peer servers, each running LockServerDaemon.php, listening on a designated TCP port. A majority of peers must agree for a lock to be acquired.
Definition at line 18 of file LSLockManager.php.
LSLockManager::__construct | ( | array $ | config | ) |
Construct a new instance from configuration.
$config paramaters include: 'lockServers' : Associative array of server names to configuration. Configuration is an associative array that includes: 'host' - IP address/hostname 'port' - TCP port 'authKey' - Secret string the lock server uses 'srvsByBucket' : Array of 1-16 consecutive integer keys, starting from 0, each having an odd-numbered list of server names (peers) as values. 'connTimeout' : Lock server connection attempt timeout. [optional]
Array | $config |
Reimplemented from LockManager.
Definition at line 52 of file LSLockManager.php.
References wfBaseConvert().
Make sure remaining locks get cleared for sanity.
Definition at line 289 of file LSLockManager.php.
References releaseLocks().
LSLockManager::doLock | ( | array $ | paths, |
$ | type | ||
) | [protected] |
Lock resources with the given keys and lock type.
$paths | Array List of storage paths |
$type | integer LockManager::LOCK_* constant |
Reimplemented from LockManager.
Definition at line 71 of file LSLockManager.php.
References $path, $res, doLockingRequestAll(), doUnlock(), getBucketFromKey(), and Status\newGood().
LSLockManager::doLockingRequest | ( | $ | lockSrv, |
array $ | paths, | ||
$ | type | ||
) | [protected] |
Get a connection to a lock server and acquire locks on $paths.
$lockSrv | string |
$paths | Array |
$type | integer LockManager::LOCK_EX or LockManager::LOCK_SH |
Definition at line 155 of file LSLockManager.php.
References $keys, and sendCommand().
Referenced by doLockingRequestAll().
LSLockManager::doLockingRequestAll | ( | $ | bucket, |
array $ | paths, | ||
$ | type | ||
) | [protected] |
Attempt to acquire locks with the peers for a bucket.
$bucket | integer |
$paths | Array List of resource keys to lock |
$type | integer LockManager::LOCK_EX or LockManager::LOCK_SH |
Definition at line 209 of file LSLockManager.php.
References doLockingRequest().
Referenced by doLock().
LSLockManager::doUnlock | ( | array $ | paths, |
$ | type | ||
) | [protected] |
Unlock resources with the given keys and lock type.
$paths | Array List of storage paths |
$type | integer LockManager::LOCK_* constant |
Reimplemented from LockManager.
Definition at line 120 of file LSLockManager.php.
References $path, Status\newGood(), and releaseLocks().
Referenced by doLock().
LSLockManager::getBucketFromKey | ( | $ | path | ) | [protected] |
Get the bucket for resource path.
This should avoid throwing any exceptions.
$path | string |
Definition at line 281 of file LSLockManager.php.
References $path.
Referenced by doLock().
LSLockManager::getConnection | ( | $ | lockSrv | ) | [protected] |
Get (or reuse) a connection to a lock server.
$lockSrv | string |
Definition at line 240 of file LSLockManager.php.
References wfRestoreWarnings(), and wfSuppressWarnings().
Referenced by sendCommand().
LSLockManager::releaseLocks | ( | ) | [protected] |
Release all locks that this session is holding.
Definition at line 263 of file LSLockManager.php.
References Status\newGood(), and sendCommand().
Referenced by __destruct(), and doUnlock().
LSLockManager::sendCommand | ( | $ | lockSrv, |
$ | action, | ||
$ | type, | ||
$ | values | ||
) | [protected] |
Send a command and get back the response.
$lockSrv | string |
$action | string |
$type | string |
$values | Array |
Definition at line 180 of file LSLockManager.php.
References getConnection().
Referenced by doLockingRequest(), and releaseLocks().
LSLockManager::$conns = array() [protected] |
Definition at line 32 of file LSLockManager.php.
LSLockManager::$connTimeout [protected] |
Definition at line 34 of file LSLockManager.php.
LSLockManager::$lockServers [protected] |
Definition at line 27 of file LSLockManager.php.
LSLockManager::$lockTypeMap [protected] |
array( self::LOCK_SH => self::LOCK_SH, self::LOCK_UW => self::LOCK_SH, self::LOCK_EX => self::LOCK_EX )
Reimplemented from LockManager.
Definition at line 20 of file LSLockManager.php.
LSLockManager::$session = '' [protected] |
Definition at line 35 of file LSLockManager.php.
LSLockManager::$srvsByBucket [protected] |
Definition at line 29 of file LSLockManager.php.