MediaWiki  master
ILBFactory.php
Go to the documentation of this file.
1 <?php
24 namespace Wikimedia\Rdbms;
25 
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 }
beginMasterChanges( $fname=__METHOD__)
Flush any master transaction snapshots and set DBO_TRX (if DBO_DEFAULT is set)
commitAll( $fname=__METHOD__, array $options=[])
Commit open transactions on all connections.
closeAll()
Close all open database connections on all open load balancers.
rollbackMasterChanges( $fname=__METHOD__)
Rollback changes on all master connections.
disableChronologyProtection()
Disable the ChronologyProtector for all load balancers.
hasOrMadeRecentMasterChanges( $age=null)
Determine if any master connection has pending/written changes from this request. ...
getAllMainLBs()
Get cached (tracked) load balancers for all main database clusters.
waitForReplication(array $opts=[])
Waits for the replica DBs to catch up to the current master position.
getChronologyProtectorClientId()
Get the client ID of the ChronologyProtector instance.
__construct(array $conf)
Construct a manager of ILoadBalancer objects.
getEmptyTransactionTicket( $fname)
Get a token asserting that no transaction writes are active.
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
shutdown( $mode=self::SHUTDOWN_CHRONPROT_SYNC, callable $workCallback=null, &$cpIndex=null, &$cpClientId=null)
Prepare all currently tracked (instantiated) load balancers for shutdown.
laggedReplicaUsed()
Detemine if any lagged replica DB connection was used.
forEachLB( $callback, array $params=[])
Execute a function for each currently tracked (instantiated) load balancer.
newMainLB( $domain=false, $owner=null)
Create a new load balancer object.
setIndexAliases(array $aliases)
Convert certain index names to alternative names before querying the DB.
flushReplicaSnapshots( $fname=__METHOD__)
Commit all replica DB transactions so as to flush any REPEATABLE-READ or SSI snapshot.
getLocalDomainID()
Get the local (and default) database domain ID of connection handles.
hasTransactionRound()
Check if an explicit transaction round is active.
redefineLocalDomain( $domain)
Close all connection and redefine the local domain for testing or schema creation.
commitAndWaitForReplication( $fname, $ticket, array $opts=[])
Convenience method for safely running commitMasterChanges()/waitForReplication()
commitMasterChanges( $fname=__METHOD__, array $options=[])
Commit changes and clear view snapshots on all master connections.
hasMasterChanges()
Determine if any master connection has pending changes.
appendShutdownCPIndexAsQuery( $url, $index)
Append ?cpPosIndex parameter to a URL for ChronologyProtector purposes if needed. ...
setWaitForReplicationListener( $name, callable $callback=null)
Add a callback to be run in every call to waitForReplication() before waiting.
getMainLB( $domain=false)
Get a cached (tracked) load balancer object.
isReadyForRoundOperations()
Check if transaction rounds can be started, committed, or rolled back right now.
An interface for generating database load balancers.
Definition: ILBFactory.php:33
getExternalLB( $cluster)
Get a cached (tracked) load balancer for external storage.
destroy()
Disables all load balancers.
setLocalDomainPrefix( $prefix)
Set a new table prefix for the existing local domain ID for testing.
newExternalLB( $cluster, $owner=null)
Create a new load balancer for external storage.
getAllExternalLBs()
Get cached (tracked) load balancers for all external database clusters.
getChronologyProtectorTouched( $dbName)