MediaWiki  master
ILBFactory.php
Go to the documentation of this file.
1 <?php
24 namespace Wikimedia\Rdbms;
25 
26 use InvalidArgumentException;
27 
33 interface ILBFactory {
35  public const SHUTDOWN_NORMAL = 0;
37  public const SHUTDOWN_NO_CHRONPROT = 1;
38 
40  public const CLUSTER_MAIN_DEFAULT = 'DEFAULT';
41 
68  public function __construct( array $conf );
69 
77  public function destroy();
78 
86  public function getLocalDomainID();
87 
93  public function resolveDomainID( $domain );
94 
103  public function redefineLocalDomain( $domain );
104 
120  public function newMainLB( $domain = false, $owner = null );
121 
130  public function getMainLB( $domain = false );
131 
147  public function newExternalLB( $cluster, $owner = null );
148 
157  public function getExternalLB( $cluster );
158 
169  public function getAllMainLBs();
170 
179  public function getAllExternalLBs();
180 
190  public function forEachLB( $callback, array $params = [] );
191 
200  public function shutdown(
201  $flags = self::SHUTDOWN_NORMAL,
202  callable $workCallback = null,
203  &$cpIndex = null,
204  &$cpClientId = null
205  );
206 
216  public function flushReplicaSnapshots( $fname = __METHOD__ );
217 
231  public function commitAll( $fname = __METHOD__, array $options = [] );
232 
248  public function beginMasterChanges( $fname = __METHOD__ );
249 
260  public function commitMasterChanges( $fname = __METHOD__, array $options = [] );
261 
269  public function rollbackMasterChanges( $fname = __METHOD__ );
270 
277  public function hasTransactionRound();
278 
287  public function isReadyForRoundOperations();
288 
296  public function hasMasterChanges();
297 
305  public function laggedReplicaUsed();
306 
315  public function hasOrMadeRecentMasterChanges( $age = null );
316 
342  public function waitForReplication( array $opts = [] );
343 
352  public function setWaitForReplicationListener( $name, callable $callback = null );
353 
360  public function getEmptyTransactionTicket( $fname );
361 
376  public function commitAndWaitForReplication( $fname, $ticket, array $opts = [] );
377 
384  public function getChronologyProtectorTouched( $domain = false );
385 
391  public function disableChronologyProtection();
392 
399  public function setLocalDomainPrefix( $prefix );
400 
404  public function closeAll();
405 
409  public function setAgentName( $agent );
410 
420  public function appendShutdownCPIndexAsQuery( $url, $index );
421 
429 
439  public function setRequestInfo( array $info );
440 
448  public function setDefaultReplicationWaitTimeout( $seconds );
449 
463  public function setTableAliases( array $aliases );
464 
477  public function setIndexAliases( array $aliases );
478 
487  public function setDomainAliases( array $aliases );
488 
496 }
Wikimedia\Rdbms\ILBFactory\getLocalDomainID
getLocalDomainID()
Get the local (and default) database domain ID of connection handles.
Wikimedia\Rdbms\ILBFactory\setRequestInfo
setRequestInfo(array $info)
Inject HTTP request header/cookie information during setup of this instance.
Wikimedia\Rdbms\ILBFactory\setTableAliases
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
Wikimedia\Rdbms\ILBFactory\__construct
__construct(array $conf)
Construct a manager of ILoadBalancer instances.
Wikimedia\Rdbms\ILBFactory\waitForReplication
waitForReplication(array $opts=[])
Waits for the replica DBs to catch up to the current master position.
Wikimedia\Rdbms\ILBFactory\rollbackMasterChanges
rollbackMasterChanges( $fname=__METHOD__)
Rollback changes on all master connections.
Wikimedia\Rdbms\ILBFactory\shutdown
shutdown( $flags=self::SHUTDOWN_NORMAL, callable $workCallback=null, &$cpIndex=null, &$cpClientId=null)
Prepare all instantiated tracked load balancer instances for shutdown.
Wikimedia\Rdbms\ILBFactory\appendShutdownCPIndexAsQuery
appendShutdownCPIndexAsQuery( $url, $index)
Append ?cpPosIndex parameter to a URL for ChronologyProtector purposes if needed.
Wikimedia\Rdbms
Definition: ChronologyProtector.php:24
Wikimedia\Rdbms\ILBFactory\forEachLB
forEachLB( $callback, array $params=[])
Execute a function for each instantiated tracked load balancer instance.
Wikimedia\Rdbms\ILBFactory\getAllExternalLBs
getAllExternalLBs()
Get the tracked load balancer instances for all external clusters.
Wikimedia\Rdbms\ILBFactory\isReadyForRoundOperations
isReadyForRoundOperations()
Check if transaction rounds can be started, committed, or rolled back right now.
Wikimedia\Rdbms\ILBFactory\getMainLB
getMainLB( $domain=false)
Get the tracked load balancer instance for a main cluster.
Wikimedia\Rdbms\ILBFactory\getExternalLB
getExternalLB( $cluster)
Get the tracked load balancer instance for an external cluster.
Wikimedia\Rdbms\ILBFactory\newMainLB
newMainLB( $domain=false, $owner=null)
Create a new load balancer instance for a main cluster.
Wikimedia\Rdbms\ILBFactory\disableChronologyProtection
disableChronologyProtection()
Disable the ChronologyProtector on all instantiated tracked load balancer instances.
Wikimedia\Rdbms\ILBFactory\setWaitForReplicationListener
setWaitForReplicationListener( $name, callable $callback=null)
Add a callback to be run in every call to waitForReplication() before waiting.
Wikimedia\Rdbms\ILBFactory\getAllMainLBs
getAllMainLBs()
Get the tracked load balancer instances for all main clusters.
Wikimedia\Rdbms\ILBFactory\getChronologyProtectorTouched
getChronologyProtectorTouched( $domain=false)
Get the UNIX timestamp when the client last touched the DB, if they did so recently.
Wikimedia\Rdbms\ILBFactory\redefineLocalDomain
redefineLocalDomain( $domain)
Close all connections and redefine the local domain for testing or schema creation.
Wikimedia\Rdbms\ILBFactory\commitAll
commitAll( $fname=__METHOD__, array $options=[])
Commit open transactions on all connections.
Wikimedia\Rdbms\ILBFactory\closeAll
closeAll()
Close all connections on instantiated tracked load balancer instances.
Wikimedia\Rdbms\ILBFactory\hasTransactionRound
hasTransactionRound()
Check if an explicit transaction round is active.
Wikimedia\Rdbms\ILBFactory\getChronologyProtectorClientId
getChronologyProtectorClientId()
Get the client ID of the ChronologyProtector instance.
Wikimedia\Rdbms\ILBFactory\laggedReplicaUsed
laggedReplicaUsed()
Detemine if any lagged replica DB connection was used.
Wikimedia\Rdbms\ILBFactory\commitAndWaitForReplication
commitAndWaitForReplication( $fname, $ticket, array $opts=[])
Call commitMasterChanges() and waitForReplication() if $ticket indicates it is safe.
Wikimedia\Rdbms\ILBFactory\setLocalDomainPrefix
setLocalDomainPrefix( $prefix)
Set a new table prefix for the existing local domain ID for testing.
Wikimedia\Rdbms\ILBFactory\beginMasterChanges
beginMasterChanges( $fname=__METHOD__)
Flush any master transaction snapshots and set DBO_TRX (if DBO_DEFAULT is set)
Wikimedia\Rdbms\ILBFactory\setDomainAliases
setDomainAliases(array $aliases)
Convert certain database domains to alternative ones.
Wikimedia\Rdbms\ILBFactory\SHUTDOWN_NO_CHRONPROT
const SHUTDOWN_NO_CHRONPROT
Do not save "session consistency" DB replication positions.
Definition: ILBFactory.php:37
Wikimedia\Rdbms\ILBFactory\SHUTDOWN_NORMAL
const SHUTDOWN_NORMAL
Idion for "no special shutdown flags".
Definition: ILBFactory.php:35
Wikimedia\Rdbms\ILBFactory\commitMasterChanges
commitMasterChanges( $fname=__METHOD__, array $options=[])
Commit changes and clear view snapshots on all master connections.
Wikimedia\Rdbms\ILBFactory\setDefaultReplicationWaitTimeout
setDefaultReplicationWaitTimeout( $seconds)
Set the default timeout for replication wait checks.
Wikimedia\Rdbms\ILBFactory\hasOrMadeRecentMasterChanges
hasOrMadeRecentMasterChanges( $age=null)
Determine if any master connection has pending/written changes from this request.
Wikimedia\Rdbms\TransactionProfiler
Detect high-contention DB queries via profiling calls.
Definition: TransactionProfiler.php:40
Wikimedia\Rdbms\ILBFactory\destroy
destroy()
Close all connections and make further attempts to open connections result in DBAccessError.
Wikimedia\Rdbms\ILBFactory\flushReplicaSnapshots
flushReplicaSnapshots( $fname=__METHOD__)
Commit all replica DB transactions so as to flush any REPEATABLE-READ or SSI snapshot.
Wikimedia\Rdbms\ILBFactory\getEmptyTransactionTicket
getEmptyTransactionTicket( $fname)
Get a token asserting that no transaction writes are active on tracked load balancers.
Wikimedia\Rdbms\ILBFactory\getTransactionProfiler
getTransactionProfiler()
Get the TransactionProfiler used by this instance.
Wikimedia\Rdbms\ILBFactory\hasMasterChanges
hasMasterChanges()
Determine if any master connection has pending changes.
Wikimedia\Rdbms\ILBFactory\resolveDomainID
resolveDomainID( $domain)
Wikimedia\Rdbms\ILBFactory
An interface for generating database load balancers.
Definition: ILBFactory.php:33
Wikimedia\Rdbms\ILBFactory\newExternalLB
newExternalLB( $cluster, $owner=null)
Create a new load balancer instance for an external cluster.
Wikimedia\Rdbms\ILBFactory\setIndexAliases
setIndexAliases(array $aliases)
Convert certain index names to alternative names before querying the DB.
Wikimedia\Rdbms\ILBFactory\setAgentName
setAgentName( $agent)