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 
69  public function __construct( array $conf );
70 
78  public function destroy();
79 
87  public function getLocalDomainID();
88 
94  public function resolveDomainID( $domain );
95 
104  public function redefineLocalDomain( $domain );
105 
121  public function newMainLB( $domain = false, $owner = null ): ILoadBalancer;
122 
131  public function getMainLB( $domain = false ): ILoadBalancer;
132 
149  public function newExternalLB( $cluster, $owner = null ): ILoadBalancer;
150 
160  public function getExternalLB( $cluster ): ILoadBalancer;
161 
172  public function getAllMainLBs(): array;
173 
182  public function getAllExternalLBs(): array;
183 
193  public function forEachLB( $callback, array $params = [] );
194 
203  public function shutdown(
204  $flags = self::SHUTDOWN_NORMAL,
205  callable $workCallback = null,
206  &$cpIndex = null,
207  &$cpClientId = null
208  );
209 
219  public function flushReplicaSnapshots( $fname = __METHOD__ );
220 
234  public function commitAll( $fname = __METHOD__, array $options = [] );
235 
252  public function beginPrimaryChanges( $fname = __METHOD__ );
253 
265  public function commitPrimaryChanges( $fname = __METHOD__, array $options = [] );
266 
275  public function rollbackPrimaryChanges( $fname = __METHOD__ );
276 
283  public function hasTransactionRound();
284 
293  public function isReadyForRoundOperations();
294 
303  public function hasPrimaryChanges();
304 
312  public function laggedReplicaUsed();
313 
322  public function hasOrMadeRecentPrimaryChanges( $age = null );
323 
349  public function waitForReplication( array $opts = [] );
350 
359  public function setWaitForReplicationListener( $name, callable $callback = null );
360 
367  public function getEmptyTransactionTicket( $fname );
368 
383  public function commitAndWaitForReplication( $fname, $ticket, array $opts = [] );
384 
391  public function getChronologyProtectorTouched( $domain = false );
392 
398  public function disableChronologyProtection();
399 
406  public function setLocalDomainPrefix( $prefix );
407 
411  public function closeAll();
412 
416  public function setAgentName( $agent );
417 
427  public function appendShutdownCPIndexAsQuery( $url, $index );
428 
436 
446  public function setRequestInfo( array $info );
447 
455  public function setDefaultReplicationWaitTimeout( $seconds );
456 
470  public function setTableAliases( array $aliases );
471 
484  public function setIndexAliases( array $aliases );
485 
494  public function setDomainAliases( array $aliases );
495 
503 }
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\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()
Determine 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\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
Idiom for "no special shutdown flags".
Definition: ILBFactory.php:35
Wikimedia\Rdbms\ILBFactory\setDefaultReplicationWaitTimeout
setDefaultReplicationWaitTimeout( $seconds)
Set the default timeout for replication wait checks.
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\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.