MediaWiki  1.27.2
ChronologyProtector Class Reference

Class for ensuring a consistent ordering of events as seen by the user, despite replication. More...

Collaboration diagram for ChronologyProtector:

Public Member Functions

 __construct (BagOStuff $store, array $client)
 
 initLB (LoadBalancer $lb)
 Initialise a LoadBalancer to give it appropriate chronology protection. More...
 
 setEnabled ($enabled)
 
 setWaitEnabled ($enabled)
 
 shutdown ()
 Notify the ChronologyProtector that the LBFactory is done calling shutdownLB() for now. More...
 
 shutdownLB (LoadBalancer $lb)
 Notify the ChronologyProtector that the LoadBalancer is about to shut down. More...
 

Protected Member Functions

 initPositions ()
 Load in previous master positions for the client. More...
 

Protected Attributes

array $client
 Map of (ip: <IP>, agent: <user-agent>) More...
 
bool $enabled = true
 Whether to no-op all method calls. More...
 
bool $initialized = false
 Whether the client data was loaded. More...
 
string $key
 Storage key name. More...
 
DBMasterPos[] $shutdownPositions = []
 Map of (DB master name => position) More...
 
DBMasterPos[] $startupPositions = []
 Map of (DB master name => position) More...
 
BagOStuff $store
 
bool $wait = true
 Whether to check and wait on positions. More...
 

Detailed Description

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 28 of file ChronologyProtector.php.

Constructor & Destructor Documentation

ChronologyProtector::__construct ( BagOStuff  $store,
array  $client 
)
Parameters
BagOStuff$store
array$clientMap of (ip: <IP>, agent: <user-agent>)
Since
1.27

Definition at line 53 of file ChronologyProtector.php.

References $client, $store, key, BagOStuff\makeGlobalKey(), and store.

Member Function Documentation

ChronologyProtector::initLB ( LoadBalancer  $lb)

Initialise a LoadBalancer 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 slave 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 slaves are available.

Parameters
LoadBalancer$lb
Returns
void

Definition at line 89 of file ChronologyProtector.php.

References LoadBalancer\getServerCount(), LoadBalancer\getServerName(), LoadBalancer\getWriterIndex(), initPositions(), LoadBalancer\parentInfo(), LoadBalancer\waitFor(), and wfDebugLog().

ChronologyProtector::initPositions ( )
protected

Load in previous master positions for the client.

Definition at line 192 of file ChronologyProtector.php.

References key, store, and wfDebugLog().

Referenced by initLB().

ChronologyProtector::setEnabled (   $enabled)
Parameters
bool$enabledWhether to no-op all method calls
Since
1.27

Definition at line 66 of file ChronologyProtector.php.

References $enabled.

Referenced by LBFactory\newChronologyProtector().

ChronologyProtector::setWaitEnabled (   $enabled)
Parameters
bool$enabledWhether to check and wait on positions
Since
1.27

Definition at line 74 of file ChronologyProtector.php.

References $enabled.

Referenced by LBFactory\newChronologyProtector().

ChronologyProtector::shutdown ( )

Notify the ChronologyProtector that the LBFactory is done calling shutdownLB() for now.

May commit chronology data to persistent storage.

Returns
array Empty on success; returns the (db name => position) map on failure

Definition at line 140 of file ChronologyProtector.php.

References $shutdownPositions, as, false, key, store, IExpiringStore\TTL_MINUTE, use, wfDebugLog(), and BagOStuff\WRITE_SYNC.

Referenced by LBFactory\shutdownChronologyProtector().

ChronologyProtector::shutdownLB ( LoadBalancer  $lb)

Member Data Documentation

array ChronologyProtector::$client
protected

Map of (ip: <IP>, agent: <user-agent>)

Definition at line 35 of file ChronologyProtector.php.

Referenced by __construct().

bool ChronologyProtector::$enabled = true
protected

Whether to no-op all method calls.

Definition at line 37 of file ChronologyProtector.php.

Referenced by setEnabled(), and setWaitEnabled().

bool ChronologyProtector::$initialized = false
protected

Whether the client data was loaded.

Definition at line 42 of file ChronologyProtector.php.

string ChronologyProtector::$key
protected

Storage key name.

Definition at line 33 of file ChronologyProtector.php.

DBMasterPos [] ChronologyProtector::$shutdownPositions = []
protected

Map of (DB master name => position)

Definition at line 46 of file ChronologyProtector.php.

Referenced by shutdown().

DBMasterPos [] ChronologyProtector::$startupPositions = []
protected

Map of (DB master name => position)

Definition at line 44 of file ChronologyProtector.php.

BagOStuff ChronologyProtector::$store
protected

Definition at line 30 of file ChronologyProtector.php.

Referenced by __construct().

bool ChronologyProtector::$wait = true
protected

Whether to check and wait on positions.

Definition at line 39 of file ChronologyProtector.php.


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