|
Tripal
|


Public Member Functions | |
| __construct (\Drupal\Core\Database\Connection $database, ?\Drupal\Core\Lock\LockBackendInterface $locker=NULL, ?\Drupal\Core\State\StateInterface $state=NULL) | |
| acquire ( $name, $timeout=self::DEFAULT_LOCK_TIMEOUT, string $owner='', ?int $pid=NULL) | |
| acquireShared (string $name, float $timeout=self::DEFAULT_LOCK_TIMEOUT, string $owner='', ?int $pid=NULL) | |
| release ($name) | |
| releaseShared ($name, $owner) | |
| lockMayBeAvailable ($name) | |
| releaseAll ($lock_id=NULL) | |
| cleanUnusedSharedLocks () | |
| getOwner (string $name) | |
| getOwners (string $name) | |
| getStartTime (string $name, ?string $owner=NULL) | |
| getCurrentExpirationTime (string $name) | |
| getCurrentExpirationDelay (string $name) | |
| getOwnerPid (string $name, ?string $owner=NULL) | |
Public Member Functions inherited from Drupal\tripal_biodb\Lock\SharedLockBackendInterface | |
| releaseShared (string $name, string $owner) | |
Public Member Functions inherited from Drupal\tripal_biodb\Lock\LockInfoInterface | |
| getStartTime (string $name) | |
| getOwnerPid (string $name) | |
Public Attributes | |
| const | STATE_KEY_SHARED = 'tripal_shared_lock_shared' |
| const | STATE_KEY_EXCLUSIVE = 'tripal_shared_lock_exclusive' |
| const | LOCK_ID = '_persistent_shared' |
| const | DEFAULT_LOCK_TIMEOUT = 43200. |
Protected Attributes | |
| $modLocker | |
| $state | |
| $shared_locks = [] | |
Defines the persistent database lock backend.
This backend is global for this Drupal installation. See tests for usage examples.
In case of remaining locks that should be removed manually:
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::__construct | ( | \Drupal\Core\Database\Connection | $database, |
| ?\Drupal\Core\Lock\LockBackendInterface | $locker = NULL, |
||
| ?\Drupal\Core\State\StateInterface | $state = NULL |
||
| ) |
Constructs a new PersistentDatabaseSharedLockBackend.
| \Drupal\Core\Database\Connection | $database | The database connection. |
| \Drupal\Core\Lock\LockBackendInterface | $locker | (optional) A lock backend used to lock modifications on shared locks. Default: if NULL, Drupal lock service is used. will be used. |
| \Drupal\Core\State\StateInterface | $state | Drupal state service. |
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::acquire | ( | $name, | |
$timeout = self::DEFAULT_LOCK_TIMEOUT, |
|||
| string | $owner = '', |
||
| ?int | $pid = NULL |
||
| ) |
{Acquires a lock.
| string | $name | Lock name. Limit of name's length is 255 characters. |
| float | $timeout | (optional) Lock lifetime in seconds. Defaults to 30.0. |
| string | $owner | (optional) Name of the (exclusive) lock owner. |
| ?int | $pid (optional) An operating system process ID owning the lock. It may be used to release the lock if the given PID becomes unused. A value of 0 will prevent the share to be released based on a PID. Default: if NULL, the current process ID (getmypid()) will be used. |
Implements Drupal\tripal_biodb\Lock\SharedLockBackendInterface.
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::acquireShared | ( | string | $name, |
| float | $timeout = self::DEFAULT_LOCK_TIMEOUT, |
||
| string | $owner = '', |
||
| ?int | $pid = NULL |
||
| ) |
Acquires a shared lock.
Shared locks relies on a regular lock as defined in the \Drupal\Core\Lock\PersistentDatabaseLockBackend class plus a list of lock share owners stored by the Drupal State API key static::STATE_KEY_SHARED. In order to avoid race conditions on the state key value modification, a lock backend provided to the constructor is used to manage modifications.
| string | $name | Shared lock name. Limit of name's length is 255 characters. |
| float | $timeout | (optional) Shared lock lifetime in seconds. Defaults to self::DEFAULT_LOCK_TIMEOUT. |
| string | $owner | Identifier of operation willing to own a share on the lock. |
| ?int | $pid (optional) An operating system process ID owning the share. It may be used to release the lock if the given PID becomes unused. A value of 0 will prevent the share to be released based on a PID. Default: if NULL, the current process ID (getmypid()) will be used. |
Implements Drupal\tripal_biodb\Lock\SharedLockBackendInterface.
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::cleanUnusedSharedLocks | ( | ) |
Removes expired or unused shared locks.
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::getCurrentExpirationDelay | ( | string | $name | ) |
{Returns the lock time remaining in seconds.Note: this delay may be extended by the lock owner.
| string | $name | Name of the lock. |
Implements Drupal\tripal_biodb\Lock\LockInfoInterface.
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::getCurrentExpirationTime | ( | string | $name | ) |
{Returns the lock expiration time in seconds.Note: this time may be extended by the lock owner.
| string | $name | Name of the lock. |
Implements Drupal\tripal_biodb\Lock\LockInfoInterface.
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::getOwner | ( | string | $name | ) |
{Returns the lock owner name.
| string | $name | Name of the lock. |
Implements Drupal\tripal_biodb\Lock\LockInfoInterface.
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::getOwnerPid | ( | string | $name, |
| ?string | $owner = NULL |
||
| ) |
{Returns the system process identifier using the shared or exclusive lock.If no owner is specified, the lock is assumed to be exclusive and 0 will be returned in case of a sheared lock. If an owner is specified, the PID of the owner is returned.
| string | $name | Name of the lock. |
| ?string | $owner Name of the owner of the share of a shared lock. |
Implements Drupal\tripal_biodb\Lock\SharedLockBackendInterface.
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::getOwners | ( | string | $name | ) |
{Returns the list of shared lock owners.
| string | $name | Name of the shared lock. |
Implements Drupal\tripal_biodb\Lock\SharedLockBackendInterface.
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::getStartTime | ( | string | $name, |
| ?string | $owner = NULL |
||
| ) |
{Returns the time in seconds when the lock started.If no owner is specified, the lock is assumed to be exclusive and 0 will be returned in case of a shared lock. If an owner is specified, the starting time of the lock share of the specified owner is returned.
| string | $name | Name of the lock. |
| ?string | $owner Name of the owner of the share of a shared lock. |
Implements Drupal\tripal_biodb\Lock\SharedLockBackendInterface.
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::lockMayBeAvailable | ( | $name | ) |
{}
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::release | ( | $name | ) |
{}
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::releaseAll | ( | $lock_id = NULL | ) |
{}
| Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::releaseShared | ( | $name, | |
| $owner | |||
| ) |
{}
| const Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::DEFAULT_LOCK_TIMEOUT = 43200. |
Default timeout for both exclusive and shared locks.
43200 seconds = 2 hours
| const Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::LOCK_ID = '_persistent_shared' |
Lock identifier used by all persistent shared locks.
| const Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::STATE_KEY_EXCLUSIVE = 'tripal_shared_lock_exclusive' |
The Drupal State API state key used to store exclusive lock details.
| const Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend::STATE_KEY_SHARED = 'tripal_shared_lock_shared' |
The Drupal State API state key used to store shared lock details.