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 ): ILoadBalancer;
121 
130  public function getMainLB( $domain = false ): ILoadBalancer;
131 
147  public function newExternalLB( $cluster, $owner = null ): ILoadBalancer;
148 
157  public function getExternalLB( $cluster ): ILoadBalancer;
158 
169  public function getAllMainLBs(): array;
170 
179  public function getAllExternalLBs(): array;
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 
249  public function beginPrimaryChanges( $fname = __METHOD__ );
250 
256  public function beginMasterChanges( $fname = __METHOD__ );
257 
269  public function commitPrimaryChanges( $fname = __METHOD__, array $options = [] );
270 
278  public function commitMasterChanges( $fname = __METHOD__, array $options = [] );
279 
288  public function rollbackPrimaryChanges( $fname = __METHOD__ );
289 
294  public function rollbackMasterChanges( $fname = __METHOD__ );
295 
302  public function hasTransactionRound();
303 
312  public function isReadyForRoundOperations();
313 
322  public function hasPrimaryChanges();
323 
328  public function hasMasterChanges();
329 
337  public function laggedReplicaUsed();
338 
347  public function hasOrMadeRecentPrimaryChanges( $age = null );
348 
354  public function hasOrMadeRecentMasterChanges( $age = null );
355 
381  public function waitForReplication( array $opts = [] );
382 
391  public function setWaitForReplicationListener( $name, callable $callback = null );
392 
399  public function getEmptyTransactionTicket( $fname );
400 
415  public function commitAndWaitForReplication( $fname, $ticket, array $opts = [] );
416 
423  public function getChronologyProtectorTouched( $domain = false );
424 
430  public function disableChronologyProtection();
431 
438  public function setLocalDomainPrefix( $prefix );
439 
443  public function closeAll();
444 
448  public function setAgentName( $agent );
449 
459  public function appendShutdownCPIndexAsQuery( $url, $index );
460 
468 
478  public function setRequestInfo( array $info );
479 
487  public function setDefaultReplicationWaitTimeout( $seconds );
488 
502  public function setTableAliases( array $aliases );
503 
516  public function setIndexAliases( array $aliases );
517 
526  public function setDomainAliases( array $aliases );
527 
535 }
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\commitPrimaryChanges
commitPrimaryChanges( $fname=__METHOD__, array $options=[])
Commit changes and clear view snapshots on all primary connections.
Wikimedia\Rdbms\ILBFactory\waitForReplication
waitForReplication(array $opts=[])
Waits for the replica DBs to catch up to the current primary position.
Wikimedia\Rdbms\ILBFactory\rollbackMasterChanges
rollbackMasterChanges( $fname=__METHOD__)
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\ILBFactory\beginPrimaryChanges
beginPrimaryChanges( $fname=__METHOD__)
Flush any primary transaction snapshots and set DBO_TRX (if DBO_DEFAULT is set)
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\hasPrimaryChanges
hasPrimaryChanges()
Determine if any primary connection has pending changes.
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\rollbackPrimaryChanges
rollbackPrimaryChanges( $fname=__METHOD__)
Rollback changes on all primary connections.
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 commitPrimaryChanges() 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__)
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=[])
Wikimedia\Rdbms\ILBFactory\setDefaultReplicationWaitTimeout
setDefaultReplicationWaitTimeout( $seconds)
Set the default timeout for replication wait checks.
Wikimedia\Rdbms\ILBFactory\hasOrMadeRecentMasterChanges
hasOrMadeRecentMasterChanges( $age=null)
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()
Wikimedia\Rdbms\ILBFactory\resolveDomainID
resolveDomainID( $domain)
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81
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)
Wikimedia\Rdbms\ILBFactory\hasOrMadeRecentPrimaryChanges
hasOrMadeRecentPrimaryChanges( $age=null)
Determine if any primary connection has pending/written changes from this request.