MediaWiki  REL1_19
LSLockManager Class Reference

Manage locks using a lock daemon server. More...

Inheritance diagram for LSLockManager:
Collaboration diagram for LSLockManager:

List of all members.

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

Detailed Description

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.

Since:
1.19

Definition at line 18 of file LSLockManager.php.


Constructor & Destructor Documentation

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]

Parameters:
Array$config

Reimplemented from LockManager.

Definition at line 52 of file LSLockManager.php.

References wfBaseConvert().

Here is the call graph for this function:

Make sure remaining locks get cleared for sanity.

Definition at line 289 of file LSLockManager.php.

References releaseLocks().

Here is the call graph for this function:


Member Function Documentation

LSLockManager::doLock ( array $  paths,
type 
) [protected]

Lock resources with the given keys and lock type.

Parameters:
$pathsArray List of storage paths
$typeinteger LockManager::LOCK_* constant
Returns:
string

Reimplemented from LockManager.

Definition at line 71 of file LSLockManager.php.

References $path, $res, doLockingRequestAll(), doUnlock(), getBucketFromKey(), and Status\newGood().

Here is the call graph for this function:

LSLockManager::doLockingRequest ( lockSrv,
array $  paths,
type 
) [protected]

Get a connection to a lock server and acquire locks on $paths.

Parameters:
$lockSrvstring
$pathsArray
$typeinteger LockManager::LOCK_EX or LockManager::LOCK_SH
Returns:
bool Resources able to be locked

Definition at line 155 of file LSLockManager.php.

References $keys, and sendCommand().

Referenced by doLockingRequestAll().

Here is the call graph for this function:

Here is the caller graph for this function:

LSLockManager::doLockingRequestAll ( bucket,
array $  paths,
type 
) [protected]

Attempt to acquire locks with the peers for a bucket.

Parameters:
$bucketinteger
$pathsArray List of resource keys to lock
$typeinteger LockManager::LOCK_EX or LockManager::LOCK_SH
Returns:
bool|string One of (true, 'cantacquire', 'srverrors')

Definition at line 209 of file LSLockManager.php.

References doLockingRequest().

Referenced by doLock().

Here is the call graph for this function:

Here is the caller graph for this function:

LSLockManager::doUnlock ( array $  paths,
type 
) [protected]

Unlock resources with the given keys and lock type.

Parameters:
$pathsArray List of storage paths
$typeinteger LockManager::LOCK_* constant
Returns:
string

Reimplemented from LockManager.

Definition at line 120 of file LSLockManager.php.

References $path, Status\newGood(), and releaseLocks().

Referenced by doLock().

Here is the call graph for this function:

Here is the caller graph for this function:

LSLockManager::getBucketFromKey ( path) [protected]

Get the bucket for resource path.

This should avoid throwing any exceptions.

Parameters:
$pathstring
Returns:
integer

Definition at line 281 of file LSLockManager.php.

References $path.

Referenced by doLock().

Here is the caller graph for this function:

LSLockManager::getConnection ( lockSrv) [protected]

Get (or reuse) a connection to a lock server.

Parameters:
$lockSrvstring
Returns:
resource

Definition at line 240 of file LSLockManager.php.

References wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by sendCommand().

Here is the call graph for this function:

Here is the caller graph for this function:

LSLockManager::releaseLocks ( ) [protected]

Release all locks that this session is holding.

Returns:
Status

Definition at line 263 of file LSLockManager.php.

References Status\newGood(), and sendCommand().

Referenced by __destruct(), and doUnlock().

Here is the call graph for this function:

Here is the caller graph for this function:

LSLockManager::sendCommand ( lockSrv,
action,
type,
values 
) [protected]

Send a command and get back the response.

Parameters:
$lockSrvstring
$actionstring
$typestring
$valuesArray
Returns:
string|false

Definition at line 180 of file LSLockManager.php.

References getConnection().

Referenced by doLockingRequest(), and releaseLocks().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

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]
Initial value:
 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.


The documentation for this class was generated from the following file: