MediaWiki REL1_28
|
Class for ensuring a consistent ordering of events as seen by the user, despite replication. More...
Public Member Functions | |
__construct (BagOStuff $store, array $client, $posTime=null) | |
getTouched ( $dbName) | |
initLB (ILoadBalancer $lb) | |
Initialise a ILoadBalancer to give it appropriate chronology protection. | |
setEnabled ( $enabled) | |
setLogger (LoggerInterface $logger) | |
setWaitEnabled ( $enabled) | |
shutdown (callable $workCallback=null, $mode='sync') | |
Notify the ChronologyProtector that the LBFactory is done calling shutdownLB() for now. | |
shutdownLB (ILoadBalancer $lb) | |
Notify the ChronologyProtector that the ILoadBalancer is about to shut down. | |
Protected Member Functions | |
initPositions () | |
Load in previous master positions for the client. | |
Protected Attributes | |
string | $clientId |
Hash of client parameters. | |
bool | $enabled = true |
Whether to no-op all method calls. | |
bool | $initialized = false |
Whether the client data was loaded. | |
string | $key |
Storage key name. | |
LoggerInterface | $logger |
DBMasterPos[] | $shutdownPositions = [] |
Map of (DB master name => position) | |
float[] | $shutdownTouchDBs = [] |
Map of (DB master name => 1) | |
DBMasterPos[] | $startupPositions = [] |
Map of (DB master name => position) | |
BagOStuff | $store |
bool | $wait = true |
Whether to check and wait on positions. | |
float null | $waitForPosTime |
Minimum UNIX timestamp of 1+ expected startup positions. | |
int | $waitForPosTimeout = self::POS_WAIT_TIMEOUT |
Max seconds to wait on positions to appear. | |
Private Member Functions | |
getTouchedKey (BagOStuff $store, $dbName) | |
Static Private Member Functions | |
static | mergePositions ( $curValue, array $shutdownPositions) |
static | minPosTime ( $data) |
Class for ensuring a consistent ordering of events as seen by the user, despite replication.
Kind of like Hawking's [[Chronology Protection Agency]].
Definition at line 31 of file ChronologyProtector.php.
BagOStuff | $store | |
array | $client | Map of (ip: <IP>, agent: <user-agent>) |
float | $posTime | UNIX timestamp |
Definition at line 70 of file ChronologyProtector.php.
References $store, key, BagOStuff\makeGlobalKey(), and store.
ChronologyProtector::getTouched | ( | $dbName | ) |
string | $dbName | DB master name (e.g. "db1052") |
Definition at line 226 of file ChronologyProtector.php.
References getTouchedKey(), and store.
|
private |
BagOStuff | $store | |
string | $dbName |
Definition at line 235 of file ChronologyProtector.php.
References $store, and BagOStuff\makeGlobalKey().
Referenced by getTouched(), and shutdown().
ChronologyProtector::initLB | ( | ILoadBalancer | $lb | ) |
Initialise a ILoadBalancer to give it appropriate chronology protection.
If the stash has a previous master position recorded, this will try to make sure that the next query to a replica DB of that master will see changes up to that position by delaying execution. The delay may timeout and allow stale data if no non-lagged replica DBs are available.
ILoadBalancer | $lb |
Definition at line 109 of file ChronologyProtector.php.
References ILoadBalancer\getServerCount(), ILoadBalancer\getServerName(), ILoadBalancer\getWriterIndex(), initPositions(), and ILoadBalancer\waitFor().
|
protected |
Load in previous master positions for the client.
Definition at line 242 of file ChronologyProtector.php.
References $waitForPosTimeout, key, store, and use.
Referenced by initLB().
|
staticprivate |
array | bool | $curValue | |
DBMasterPos[] | $shutdownPositions |
Definition at line 308 of file ChronologyProtector.php.
References $shutdownPositions, as, and false.
|
staticprivate |
array | bool | $data |
Definition at line 289 of file ChronologyProtector.php.
References as.
ChronologyProtector::setEnabled | ( | $enabled | ) |
bool | $enabled | Whether to no-op all method calls |
Definition at line 86 of file ChronologyProtector.php.
References $enabled.
ChronologyProtector::setLogger | ( | LoggerInterface | $logger | ) |
Definition at line 78 of file ChronologyProtector.php.
References $logger.
Referenced by LBFactory\getChronologyProtector().
ChronologyProtector::setWaitEnabled | ( | $enabled | ) |
bool | $enabled | Whether to check and wait on positions |
Definition at line 94 of file ChronologyProtector.php.
References $enabled.
ChronologyProtector::shutdown | ( | callable | $workCallback = null , |
$mode = 'sync' |
|||
) |
Notify the ChronologyProtector that the LBFactory is done calling shutdownLB() for now.
May commit chronology data to persistent storage.
callable | null | $workCallback | Work to do instead of waiting on syncing positions |
string | $mode | One of (sync, async); whether to wait on remote datacenters |
Definition at line 158 of file ChronologyProtector.php.
References $shutdownPositions, $store, BagOStuff\addBusyCallback(), as, BagOStuff\get(), BagOStuff\getQoS(), getTouchedKey(), key, BagOStuff\lock(), BagOStuff\set(), store, and BagOStuff\unlock().
Referenced by LBFactory\shutdownChronologyProtector().
ChronologyProtector::shutdownLB | ( | ILoadBalancer | $lb | ) |
Notify the ChronologyProtector that the ILoadBalancer is about to shut down.
Saves replication positions.
ILoadBalancer | $lb |
Definition at line 131 of file ChronologyProtector.php.
References ILoadBalancer\getMasterPos(), ILoadBalancer\getServerCount(), ILoadBalancer\getServerName(), ILoadBalancer\getWriterIndex(), and ILoadBalancer\hasOrMadeRecentMasterChanges().
Referenced by LBFactory\shutdownChronologyProtector().
|
protected |
Hash of client parameters.
Definition at line 40 of file ChronologyProtector.php.
|
protected |
Whether to no-op all method calls.
Definition at line 46 of file ChronologyProtector.php.
Referenced by setEnabled(), and setWaitEnabled().
|
protected |
Whether the client data was loaded.
Definition at line 51 of file ChronologyProtector.php.
|
protected |
Storage key name.
Definition at line 38 of file ChronologyProtector.php.
|
protected |
Definition at line 35 of file ChronologyProtector.php.
Referenced by setLogger().
|
protected |
Map of (DB master name => position)
Definition at line 55 of file ChronologyProtector.php.
Referenced by mergePositions(), and shutdown().
|
protected |
Map of (DB master name => 1)
Definition at line 57 of file ChronologyProtector.php.
|
protected |
Map of (DB master name => position)
Definition at line 53 of file ChronologyProtector.php.
|
protected |
Definition at line 33 of file ChronologyProtector.php.
Referenced by __construct(), getTouchedKey(), and shutdown().
|
protected |
Whether to check and wait on positions.
Definition at line 48 of file ChronologyProtector.php.
|
protected |
Minimum UNIX timestamp of 1+ expected startup positions.
Definition at line 42 of file ChronologyProtector.php.
|
protected |
Max seconds to wait on positions to appear.
Definition at line 44 of file ChronologyProtector.php.
Referenced by initPositions().