MediaWiki  1.34.0
ILBFactory.php
Go to the documentation of this file.
1 <?php
24 namespace Wikimedia\Rdbms;
25 
26 use InvalidArgumentException;
27 
33 interface ILBFactory {
35  const SHUTDOWN_NO_CHRONPROT = 0; // don't save DB positions at all
37  const SHUTDOWN_CHRONPROT_ASYNC = 1;
39  const SHUTDOWN_CHRONPROT_SYNC = 2;
40 
42  const CLUSTER_MAIN_DEFAULT = 'DEFAULT';
43 
69  public function __construct( array $conf );
70 
76  public function destroy();
77 
85  public function getLocalDomainID();
86 
92  public function resolveDomainID( $domain );
93 
100  public function redefineLocalDomain( $domain );
101 
115  public function newMainLB( $domain = false, $owner = null );
116 
123  public function getMainLB( $domain = false );
124 
138  public function newExternalLB( $cluster, $owner = null );
139 
146  public function getExternalLB( $cluster );
147 
156  public function getAllMainLBs();
157 
164  public function getAllExternalLBs();
165 
175  public function forEachLB( $callback, array $params = [] );
176 
185  public function shutdown(
186  $mode = self::SHUTDOWN_CHRONPROT_SYNC,
187  callable $workCallback = null,
188  &$cpIndex = null,
189  &$cpClientId = null
190  );
191 
199  public function flushReplicaSnapshots( $fname = __METHOD__ );
200 
209  public function commitAll( $fname = __METHOD__, array $options = [] );
210 
224  public function beginMasterChanges( $fname = __METHOD__ );
225 
233  public function commitMasterChanges( $fname = __METHOD__, array $options = [] );
234 
239  public function rollbackMasterChanges( $fname = __METHOD__ );
240 
246  public function hasTransactionRound();
247 
256  public function isReadyForRoundOperations();
257 
262  public function hasMasterChanges();
263 
268  public function laggedReplicaUsed();
269 
275  public function hasOrMadeRecentMasterChanges( $age = null );
276 
300  public function waitForReplication( array $opts = [] );
301 
310  public function setWaitForReplicationListener( $name, callable $callback = null );
311 
318  public function getEmptyTransactionTicket( $fname );
319 
330  public function commitAndWaitForReplication( $fname, $ticket, array $opts = [] );
331 
336  public function getChronologyProtectorTouched( $dbName );
337 
343  public function disableChronologyProtection();
344 
351  public function setLocalDomainPrefix( $prefix );
352 
356  public function closeAll();
357 
361  public function setAgentName( $agent );
362 
372  public function appendShutdownCPIndexAsQuery( $url, $index );
373 
380  public function getChronologyProtectorClientId();
381 
389  public function setRequestInfo( array $info );
390 
404  public function setTableAliases( array $aliases );
405 
418  public function setIndexAliases( array $aliases );
419 }
Wikimedia\Rdbms\ILBFactory\getLocalDomainID
getLocalDomainID()
Get the local (and default) database domain ID of connection handles.
Wikimedia\Rdbms\ILBFactory\setRequestInfo
setRequestInfo(array $info)
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 objects.
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\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 currently tracked (instantiated) load balancer.
Wikimedia\Rdbms\ILBFactory\getAllExternalLBs
getAllExternalLBs()
Get cached (tracked) load balancers for all external database 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 a cached (tracked) load balancer object.
Wikimedia\Rdbms\ILBFactory\getChronologyProtectorTouched
getChronologyProtectorTouched( $dbName)
Wikimedia\Rdbms\ILBFactory\getExternalLB
getExternalLB( $cluster)
Get a cached (tracked) load balancer for external storage.
Wikimedia\Rdbms\ILBFactory\newMainLB
newMainLB( $domain=false, $owner=null)
Create a new load balancer object.
Wikimedia\Rdbms\ILBFactory\disableChronologyProtection
disableChronologyProtection()
Disable the ChronologyProtector for all load balancers.
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 cached (tracked) load balancers for all main database clusters.
Wikimedia\Rdbms\ILBFactory\redefineLocalDomain
redefineLocalDomain( $domain)
Close all connection 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 open database connections on all open load balancers.
Wikimedia\Rdbms\ILBFactory\shutdown
shutdown( $mode=self::SHUTDOWN_CHRONPROT_SYNC, callable $workCallback=null, &$cpIndex=null, &$cpClientId=null)
Prepare all currently tracked (instantiated) load balancers for shutdown.
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=[])
Convenience method for safely running commitMasterChanges()/waitForReplication()
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\commitMasterChanges
commitMasterChanges( $fname=__METHOD__, array $options=[])
Commit changes and clear view snapshots on all master connections.
Wikimedia\Rdbms\ILBFactory\hasOrMadeRecentMasterChanges
hasOrMadeRecentMasterChanges( $age=null)
Determine if any master connection has pending/written changes from this request.
Wikimedia\Rdbms\ILBFactory\destroy
destroy()
Disables all load balancers.
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.
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 for external storage.
Wikimedia\Rdbms\ILBFactory\setIndexAliases
setIndexAliases(array $aliases)
Convert certain index names to alternative names before querying the DB.
Wikimedia\Rdbms\ILBFactory\setAgentName
setAgentName( $agent)