MediaWiki REL1_35
ILBFactory.php
Go to the documentation of this file.
1<?php
24namespace Wikimedia\Rdbms;
25
26use InvalidArgumentException;
27
33interface ILBFactory {
35 public const SHUTDOWN_NO_CHRONPROT = 0; // don't save DB positions at all
37 public const SHUTDOWN_CHRONPROT_ASYNC = 1;
39 public const SHUTDOWN_CHRONPROT_SYNC = 2;
40
42 public 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( $domain = false );
337
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
381
389 public function setRequestInfo( array $info );
390
396 public function setDefaultReplicationWaitTimeout( $seconds );
397
411 public function setTableAliases( array $aliases );
412
425 public function setIndexAliases( array $aliases );
426
435 public function setDomainAliases( array $aliases );
436
444}
Detect high-contention DB queries via profiling calls.
An interface for generating database load balancers.
beginMasterChanges( $fname=__METHOD__)
Flush any master transaction snapshots and set DBO_TRX (if DBO_DEFAULT is set)
getLocalDomainID()
Get the local (and default) database domain ID of connection handles.
redefineLocalDomain( $domain)
Close all connection and redefine the local domain for testing or schema creation.
getAllExternalLBs()
Get cached (tracked) load balancers for all external database clusters.
newExternalLB( $cluster, $owner=null)
Create a new load balancer for external storage.
commitAll( $fname=__METHOD__, array $options=[])
Commit open transactions on all connections.
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
setLocalDomainPrefix( $prefix)
Set a new table prefix for the existing local domain ID for testing.
waitForReplication(array $opts=[])
Waits for the replica DBs to catch up to the current master position.
commitAndWaitForReplication( $fname, $ticket, array $opts=[])
Convenience method for safely running commitMasterChanges()/waitForReplication()
newMainLB( $domain=false, $owner=null)
Create a new load balancer object.
__construct(array $conf)
Construct a manager of ILoadBalancer objects.
destroy()
Disables all load balancers.
laggedReplicaUsed()
Detemine if any lagged replica DB connection was used.
getChronologyProtectorClientId()
Get the client ID of the ChronologyProtector instance.
commitMasterChanges( $fname=__METHOD__, array $options=[])
Commit changes and clear view snapshots on all master connections.
setDomainAliases(array $aliases)
Convert certain database domains to alternative ones.
getExternalLB( $cluster)
Get a cached (tracked) load balancer for external storage.
getMainLB( $domain=false)
Get a cached (tracked) load balancer object.
disableChronologyProtection()
Disable the ChronologyProtector for all load balancers.
closeAll()
Close all open database connections on all open load balancers.
hasOrMadeRecentMasterChanges( $age=null)
Determine if any master connection has pending/written changes from this request.
setDefaultReplicationWaitTimeout( $seconds)
hasTransactionRound()
Check if an explicit transaction round is active.
getAllMainLBs()
Get cached (tracked) load balancers for all main database clusters.
hasMasterChanges()
Determine if any master connection has pending changes.
forEachLB( $callback, array $params=[])
Execute a function for each currently tracked (instantiated) load balancer.
getTransactionProfiler()
Get a 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.
shutdown( $mode=self::SHUTDOWN_CHRONPROT_SYNC, callable $workCallback=null, &$cpIndex=null, &$cpClientId=null)
Prepare all currently tracked (instantiated) load balancers for shutdown.
getChronologyProtectorTouched( $domain=false)
getEmptyTransactionTicket( $fname)
Get a token asserting that no transaction writes are active.
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__)
Rollback changes on all master connections.