SQL based implementation of ChangeDispatchCoordinator;.
More...
SQL based implementation of ChangeDispatchCoordinator;.
- Copyright
- GPL-2.0-or-later
- Author
- Daniel Kinzler
◆ __construct()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::__construct |
( |
|
$repoDB, |
|
|
string |
$repoSiteId, |
|
|
ILBFactory |
$LBFactory, |
|
|
LoggerInterface |
$logger |
|
) |
| |
- Parameters
-
string | false | $repoDB | |
string | $repoSiteId | The repo's global wiki ID |
ILBFactory | $LBFactory | |
LoggerInterface | $logger | |
◆ engageClientLock()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::engageClientLock |
( |
string |
$lock | ) |
|
|
protected |
◆ getCandidateClients()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::getCandidateClients |
( |
| ) |
|
|
private |
Returns a list of possible client for the next pass.
If no suitable clients are found, the resulting list will be empty.
- Returns
- array
- See also
- selectClient()
◆ getClientLockName()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::getClientLockName |
( |
string |
$siteID | ) |
|
|
private |
Determines the name of the global lock that should be used to lock the given client.
- Parameters
-
string | $siteID | The site ID of the wiki to lock |
- Returns
- string the lock name to use.
◆ getMessageReportString()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::getMessageReportString |
( |
string |
$message, |
|
|
array |
$context |
|
) |
| |
|
private |
- Parameters
-
string | $message | |
array | $context | |
- Returns
- string
◆ getRepoLB()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::getRepoLB |
( |
| ) |
|
|
private |
- Returns
- ILoadBalancer the repo's database load balancer.
◆ getRepoMaster()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::getRepoMaster |
( |
| ) |
|
|
private |
- Returns
- IDatabase A connection to the repo's master database
◆ getRepoReplica()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::getRepoReplica |
( |
| ) |
|
|
private |
- Returns
- IDatabase A connection to the repo's replica database
◆ initState()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::initState |
( |
array |
$clientWikiDBs | ) |
|
Initializes the dispatch table by injecting dummy records for all target wikis that are in the configuration but not yet in the dispatch table.
- Parameters
-
string[] | $clientWikiDBs | Associative array mapping client wiki IDs to client wiki (logical) database names. |
- Exceptions
-
Implements Wikibase\Repo\Store\ChangeDispatchCoordinator.
◆ isClientLockUsed()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::isClientLockUsed |
( |
IDatabase |
$db, |
|
|
string |
$lock |
|
) |
| |
|
protected |
Checks the given global lock on the given client wiki.
- Parameters
-
IDatabase | $db | The database connection to work on. |
string | $lock | The name of the lock to check. |
- Returns
- bool true if the given lock is currently held by another process, false otherwise.
Reimplemented in Wikibase\Repo\Store\Sql\LockManagerSqlChangeDispatchCoordinator.
◆ lockClient()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::lockClient |
( |
string |
$siteID | ) |
|
Attempt to lock the given target wiki.
If it can't be locked because another dispatch process is working on it, this method returns false.
- Parameters
-
string | $siteID | The ID of the client wiki to lock. |
- Exceptions
-
MWException | if there are no client wikis to chose from. |
Exception | |
- Returns
- bool|array An associative array containing the state of the selected client wiki (see selectClient()) or false if the client wiki could not be locked.
- See also
- selectClient()
Implements Wikibase\Repo\Store\ChangeDispatchCoordinator.
◆ log()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::log |
( |
string |
$message, |
|
|
array |
$context |
|
) |
| |
|
private |
◆ now()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::now |
( |
| ) |
|
|
private |
- Returns
- int The current time as a timestamp, in seconds since Epoch.
◆ releaseClient()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::releaseClient |
( |
array |
$state | ) |
|
Updates the given client wiki's entry in the dispatch table and releases the global lock on that wiki.
- Parameters
-
array | $state | Associative array representing the client wiki's state before the update pass, as returned by selectWiki(). |
- Exceptions
-
- See also
- selectWiki()
Implements Wikibase\Repo\Store\ChangeDispatchCoordinator.
◆ releaseClientLock()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::releaseClientLock |
( |
IDatabase |
$db, |
|
|
string |
$lock |
|
) |
| |
|
protected |
◆ selectClient()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::selectClient |
( |
| ) |
|
Selects a client wiki and locks it.
If no suitable client wiki can be found, this method returns null.
Note: this implementation will try a wiki from the list returned by getCandidateClients() at random. If all have been tried and failed, it returns null.
- Returns
- array|null An associative array containing the state of the selected client wiki (or null, if no target could be locked). Fields are:
- chd_site: the client wiki's global site ID
- chd_db: the client wiki's logical database name
- chd_seen: the last change ID processed for that client wiki
- chd_touched: timestamp giving the last time that client wiki was updated
- chd_lock: the name of a global lock currently active for that client wiki
- Exceptions
-
MWException | if no available client wiki could be found. |
- See also
- releaseWiki()
Implements Wikibase\Repo\Store\ChangeDispatchCoordinator.
◆ setArrayRandOverride()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::setArrayRandOverride |
( |
callable |
$array_rand | ) |
|
Set override for array_rand(), for testing.
- Parameters
-
◆ setBatchSize()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::setBatchSize |
( |
int |
$batchSize | ) |
|
Sets the number of changes we would prefer to process in one go.
Clients that are lagged by fewer changes than this may be skipped by selectClient().
- Parameters
-
◆ setChangesTable()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::setChangesTable |
( |
string |
$changesTable | ) |
|
◆ setDispatchInterval()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::setDispatchInterval |
( |
int |
$dispatchInterval | ) |
|
Sets the number of seconds we would prefer to let a client "rest" before dispatching to it again.
Clients that have received updates less than $dispatchInterval seconds ago may be skipped by selectClient().
- Parameters
-
◆ setEngageClientLockOverride()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::setEngageClientLockOverride |
( |
callable |
$engageClientLockOverride | ) |
|
Set override for $db->lock, for testing.
- Parameters
-
callable | $engageClientLockOverride | |
◆ setIsClientLockUsedOverride()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::setIsClientLockUsedOverride |
( |
callable |
$isClientLockUsedOverride | ) |
|
Set override for !$db->lockIsFree, for testing.
- Parameters
-
callable | $isClientLockUsedOverride | |
◆ setMessageReporter()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::setMessageReporter |
( |
MessageReporter |
$messageReporter | ) |
|
◆ setRandomness()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::setRandomness |
( |
int |
$randomness | ) |
|
Sets the randomness level: selectClient() will randomly pick one of the $randomness most lagged eligible client wikis.
- Parameters
-
◆ setReleaseClientLockOverride()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::setReleaseClientLockOverride |
( |
callable |
$releaseClientLockOverride | ) |
|
Set override for $db->unlock, for testing.
- Parameters
-
callable | $releaseClientLockOverride | |
◆ setStateTable()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::setStateTable |
( |
string |
$stateTable | ) |
|
◆ setTimeOverride()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::setTimeOverride |
( |
callable |
$time | ) |
|
Set override for time(), for testing.
- Parameters
-
◆ trace()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::trace |
( |
string |
$message | ) |
|
|
private |
◆ warn()
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::warn |
( |
string |
$message | ) |
|
|
private |
◆ $array_rand
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$array_rand = 'array_rand' |
|
private |
◆ $batchSize
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$batchSize = 1000 |
|
private |
◆ $changesTable
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$changesTable = 'wb_changes' |
|
private |
◆ $dispatchInterval
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$dispatchInterval = 60 |
|
private |
◆ $engageClientLockOverride
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$engageClientLockOverride = null |
|
private |
◆ $isClientLockUsedOverride
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$isClientLockUsedOverride = null |
|
private |
◆ $LBFactory
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$LBFactory |
|
private |
◆ $logger
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$logger |
|
private |
◆ $messageReporter
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$messageReporter |
|
private |
◆ $randomness
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$randomness = 15 |
|
private |
◆ $releaseClientLockOverride
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$releaseClientLockOverride = null |
|
private |
◆ $repoDB
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$repoDB |
|
private |
◆ $repoSiteId
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$repoSiteId |
|
private |
◆ $stateTable
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$stateTable = 'wb_changes_dispatch' |
|
private |
◆ $stats
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$stats |
|
private |
◆ $time
Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::$time = 'time' |
|
private |
The documentation for this class was generated from the following file: