BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
Wikimedia\Rdbms\ChronologyProtector Class Reference
Inheritance diagram for Wikimedia\Rdbms\ChronologyProtector:
Collaboration diagram for Wikimedia\Rdbms\ChronologyProtector:

Public Member Functions

 __construct (BagOStuff $store, array $client, $posIndex=null)
 
 setLogger (LoggerInterface $logger)
 
 setEnabled ($enabled)
 
 setWaitEnabled ($enabled)
 
 initLB (ILoadBalancer $lb)
 
 shutdownLB (ILoadBalancer $lb)
 
 shutdown (callable $workCallback=null, $mode= 'sync', &$cpIndex=null)
 
 getTouched ($dbName)
 

Public Attributes

const POSITION_TTL = 60
 
const POS_STORE_WAIT_TIMEOUT = 5
 

Protected Member Functions

 initPositions ()
 

Protected Attributes

 $store
 
 $logger
 
 $key
 
 $clientId
 
 $waitForPosIndex
 
 $waitForPosStoreTimeout = self::POS_STORE_WAIT_TIMEOUT
 
 $enabled = true
 
 $wait = true
 
 $initialized = false
 
 $startupPositions = []
 
 $shutdownPositions = []
 
 $shutdownTouchDBs = []
 

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]].

Constructor & Destructor Documentation

Wikimedia\Rdbms\ChronologyProtector::__construct ( BagOStuff  $store,
array  $client,
  $posIndex = null 
)
Parameters
BagOStuff$store
array[]$client Map of (ip: <IP>, agent: <user-agent>)
int | null$posIndexWrite counter index [optional]
Since
1.27

Member Function Documentation

Wikimedia\Rdbms\ChronologyProtector::getTouched (   $dbName)
Parameters
string$dbNameDB master name (e.g. "db1052")
Returns
float|bool UNIX timestamp when client last touched the DB; false if not on record
Since
1.28
Wikimedia\Rdbms\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.

Parameters
ILoadBalancer$lb
Returns
void
Wikimedia\Rdbms\ChronologyProtector::initPositions ( )
protected

Load in previous master positions for the client

Wikimedia\Rdbms\ChronologyProtector::setEnabled (   $enabled)
Parameters
bool$enabledWhether to no-op all method calls
Since
1.27
Wikimedia\Rdbms\ChronologyProtector::setLogger ( LoggerInterface  $logger)

Sets a logger instance on the object.

Parameters
LoggerInterface$logger
Returns
void

Implements Psr\Log\LoggerAwareInterface.

Wikimedia\Rdbms\ChronologyProtector::setWaitEnabled (   $enabled)
Parameters
bool$enabledWhether to check and wait on positions
Since
1.27
Wikimedia\Rdbms\ChronologyProtector::shutdown ( callable  $workCallback = null,
  $mode = 'sync',
$cpIndex = null 
)

Notify the ChronologyProtector that the LBFactory is done calling shutdownLB() for now. May commit chronology data to persistent storage.

Parameters
callable | null$workCallbackWork to do instead of waiting on syncing positions
string$modeOne of (sync, async); whether to wait on remote datacenters
int | null&$cpIndexDB position key write counter; incremented on update
Returns
DBMasterPos[] Empty on success; returns the (db name => position) map on failure
Wikimedia\Rdbms\ChronologyProtector::shutdownLB ( ILoadBalancer  $lb)

Notify the ChronologyProtector that the ILoadBalancer is about to shut down. Saves replication positions.

Parameters
ILoadBalancer$lb
Returns
void

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