MediaWiki REL1_37
ILBFactory.php
Go to the documentation of this file.
1<?php
24namespace Wikimedia\Rdbms;
25
26use InvalidArgumentException;
27
33interface 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
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}
Detect high-contention DB queries via profiling calls.
An interface for generating database load balancers.
beginMasterChanges( $fname=__METHOD__)
getLocalDomainID()
Get the local (and default) database domain ID of connection handles.
redefineLocalDomain( $domain)
Close all connections and redefine the local domain for testing or schema creation.
beginPrimaryChanges( $fname=__METHOD__)
Flush any primary transaction snapshots and set DBO_TRX (if DBO_DEFAULT is set)
getAllExternalLBs()
Get the tracked load balancer instances for all external clusters.
newExternalLB( $cluster, $owner=null)
Create a new load balancer instance for an external cluster.
commitAll( $fname=__METHOD__, array $options=[])
Commit open transactions on all connections.
setRequestInfo(array $info)
Inject HTTP request header/cookie information during setup of this instance.
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
commitPrimaryChanges( $fname=__METHOD__, array $options=[])
Commit changes and clear view snapshots on all primary connections.
setLocalDomainPrefix( $prefix)
Set a new table prefix for the existing local domain ID for testing.
hasPrimaryChanges()
Determine if any primary connection has pending changes.
waitForReplication(array $opts=[])
Waits for the replica DBs to catch up to the current primary position.
rollbackPrimaryChanges( $fname=__METHOD__)
Rollback changes on all primary connections.
commitAndWaitForReplication( $fname, $ticket, array $opts=[])
Call commitPrimaryChanges() and waitForReplication() if $ticket indicates it is safe.
newMainLB( $domain=false, $owner=null)
Create a new load balancer instance for a main cluster.
__construct(array $conf)
Construct a manager of ILoadBalancer instances.
shutdown( $flags=self::SHUTDOWN_NORMAL, callable $workCallback=null, &$cpIndex=null, &$cpClientId=null)
Prepare all instantiated tracked load balancer instances for shutdown.
destroy()
Close all connections and make further attempts to open connections result in DBAccessError.
laggedReplicaUsed()
Detemine if any lagged replica DB connection was used.
getChronologyProtectorClientId()
Get the client ID of the ChronologyProtector instance.
commitMasterChanges( $fname=__METHOD__, array $options=[])
setDomainAliases(array $aliases)
Convert certain database domains to alternative ones.
getExternalLB( $cluster)
Get the tracked load balancer instance for an external cluster.
getMainLB( $domain=false)
Get the tracked load balancer instance for a main cluster.
disableChronologyProtection()
Disable the ChronologyProtector on all instantiated tracked load balancer instances.
closeAll()
Close all connections on instantiated tracked load balancer instances.
hasOrMadeRecentMasterChanges( $age=null)
setDefaultReplicationWaitTimeout( $seconds)
Set the default timeout for replication wait checks.
const SHUTDOWN_NO_CHRONPROT
Do not save "session consistency" DB replication positions.
hasTransactionRound()
Check if an explicit transaction round is active.
const SHUTDOWN_NORMAL
Idion for "no special shutdown flags".
getAllMainLBs()
Get the tracked load balancer instances for all main clusters.
forEachLB( $callback, array $params=[])
Execute a function for each instantiated tracked load balancer instance.
getTransactionProfiler()
Get the TransactionProfiler used by this instance.
setIndexAliases(array $aliases)
Convert certain index names to alternative names before querying the DB.
appendShutdownCPIndexAsQuery( $url, $index)
Append ?cpPosIndex parameter to a URL for ChronologyProtector purposes if needed.
getChronologyProtectorTouched( $domain=false)
Get the UNIX timestamp when the client last touched the DB, if they did so recently.
hasOrMadeRecentPrimaryChanges( $age=null)
Determine if any primary connection has pending/written changes from this request.
getEmptyTransactionTicket( $fname)
Get a token asserting that no transaction writes are active on tracked load balancers.
isReadyForRoundOperations()
Check if transaction rounds can be started, committed, or rolled back right now.
flushReplicaSnapshots( $fname=__METHOD__)
Commit all replica DB transactions so as to flush any REPEATABLE-READ or SSI snapshot.
setWaitForReplicationListener( $name, callable $callback=null)
Add a callback to be run in every call to waitForReplication() before waiting.
rollbackMasterChanges( $fname=__METHOD__)
Database cluster connection, tracking, load balancing, and transaction manager interface.