MediaWiki REL1_30
ILoadBalancer.php
Go to the documentation of this file.
1<?php
23namespace Wikimedia\Rdbms;
24
25use Exception;
26use InvalidArgumentException;
27
78interface ILoadBalancer {
80 const DB_REPLICA = -1;
82 const DB_MASTER = -2;
83
85 const DOMAIN_ANY = '';
86
88 const CONN_TRX_AUTO = 1;
89
113 public function __construct( array $params );
114
127 public function getReaderIndex( $group = false, $domain = false );
128
141 public function waitFor( $pos );
142
152 public function waitForOne( $pos, $timeout = null );
153
161 public function waitForAll( $pos, $timeout = null );
162
169 public function getAnyOpenConnection( $i );
170
184 public function getConnection( $i, $groups = [], $domain = false, $flags = 0 );
185
195 public function reuseConnection( $conn );
196
212 public function getConnectionRef( $i, $groups = [], $domain = false, $flags = 0 );
213
229 public function getLazyConnectionRef( $i, $groups = [], $domain = false, $flags = 0 );
230
246 public function getMaintenanceConnectionRef( $db, $groups = [], $domain = false, $flags = 0 );
247
264 public function openConnection( $i, $domain = false, $flags = 0 );
265
269 public function getWriterIndex();
270
277 public function haveIndex( $i );
278
285 public function isNonZeroLoad( $i );
286
292 public function getServerCount();
293
300 public function getServerName( $i );
301
309 public function getServerType( $i );
310
318 public function getServerInfo( $i );
319
328 public function setServerInfo( $i, array $serverInfo );
329
334 public function getMasterPos();
335
340 public function disable();
341
345 public function closeAll();
346
355 public function closeConnection( IDatabase $conn );
356
362 public function commitAll( $fname = __METHOD__ );
363
370 public function finalizeMasterChanges();
371
381 public function approveMasterChanges( array $options );
382
395 public function beginMasterChanges( $fname = __METHOD__ );
396
402 public function commitMasterChanges( $fname = __METHOD__ );
403
413
419 public function rollbackMasterChanges( $fname = __METHOD__ );
420
429
435 public function flushReplicaSnapshots( $fname = __METHOD__ );
436
440 public function hasMasterConnection();
441
446 public function hasMasterChanges();
447
452 public function lastMasterChangeTimestamp();
453
461 public function hasOrMadeRecentMasterChanges( $age = null );
462
468 public function pendingMasterChangeCallers();
469
475 public function getLaggedReplicaMode( $domain = false );
476
485 public function laggedReplicaUsed();
486
493 public function getReadOnlyReason( $domain = false, IDatabase $conn = null );
494
500 public function allowLagged( $mode = null );
501
505 public function pingAll();
506
512 public function forEachOpenConnection( $callback, array $params = [] );
513
519 public function forEachOpenMasterConnection( $callback, array $params = [] );
520
526 public function forEachOpenReplicaConnection( $callback, array $params = [] );
527
538 public function getMaxLag( $domain = false );
539
550 public function getLagTimes( $domain = false );
551
566 public function safeGetLag( IDatabase $conn );
567
578 public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = 10 );
579
587 public function setTransactionListener( $name, callable $callback = null );
588
594 public function setDomainPrefix( $prefix );
595
608 public function setTableAliases( array $aliases );
609}
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition Setup.php:36
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:1971
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition hooks.txt:2805
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:40
Database cluster connection, tracking, load balancing, and transaction manager interface.
approveMasterChanges(array $options)
Perform all pre-commit checks for things like replication safety.
forEachOpenConnection( $callback, array $params=[])
Call a function with each open connection object.
finalizeMasterChanges()
Perform all pre-commit callbacks that remain part of the atomic transactions and disable any post-com...
getConnection( $i, $groups=[], $domain=false, $flags=0)
Get a connection by index.
rollbackMasterChanges( $fname=__METHOD__)
Issue ROLLBACK only on master, only if queries were done on connection.
setDomainPrefix( $prefix)
Set a new table prefix for the existing local domain ID for testing.
getServerType( $i)
Get DB type of the server with the specified index.
getMaxLag( $domain=false)
Get the hostname and lag time of the most-lagged replica DB.
waitFor( $pos)
Set the master wait position.
safeWaitForMasterPos(IDatabase $conn, $pos=false, $timeout=10)
Wait for a replica DB to reach a specified master position.
suppressTransactionEndCallbacks()
Suppress all pending post-COMMIT/ROLLBACK callbacks.
setServerInfo( $i, array $serverInfo)
Sets the server info structure for the given index.
setTransactionListener( $name, callable $callback=null)
Set a callback via IDatabase::setTransactionListener() on all current and future master connections o...
getReaderIndex( $group=false, $domain=false)
Get the index of the reader connection, which may be a replica DB.
hasOrMadeRecentMasterChanges( $age=null)
Check if this load balancer object had any recent or still pending writes issued against it by this P...
forEachOpenMasterConnection( $callback, array $params=[])
Call a function with each open connection object to a master.
beginMasterChanges( $fname=__METHOD__)
Flush any master transaction snapshots and set DBO_TRX (if DBO_DEFAULT is set)
getReadOnlyReason( $domain=false, IDatabase $conn=null)
getLaggedReplicaMode( $domain=false)
getMaintenanceConnectionRef( $db, $groups=[], $domain=false, $flags=0)
Get a maintenance database connection handle reference for migrations and schema changes.
pendingMasterChangeCallers()
Get the list of callers that have pending master changes.
getMasterPos()
Get the current master position for chronology control purposes.
haveIndex( $i)
Returns true if the specified index is a valid server index.
hasMasterChanges()
Determine if there are pending changes in a transaction by this thread.
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
__construct(array $params)
Construct a manager of IDatabase connection objects.
commitMasterChanges( $fname=__METHOD__)
Issue COMMIT on all master connections where writes where done.
runMasterPostTrxCallbacks( $type)
Issue all pending post-COMMIT/ROLLBACK callbacks.
forEachOpenReplicaConnection( $callback, array $params=[])
Call a function with each open replica DB connection object.
disable()
Disable this load balancer.
reuseConnection( $conn)
Mark a foreign connection as being available for reuse under a different DB domain.
openConnection( $i, $domain=false, $flags=0)
Open a connection to the server given by the specified index.
isNonZeroLoad( $i)
Returns true if the specified index is valid and has non-zero load.
laggedReplicaUsed()
Checks whether the database for generic connections this request was both:
getServerCount()
Get the number of defined servers (not the number of open connections)
getServerInfo( $i)
Return the server info structure for a given index, or false if the index is invalid.
getConnectionRef( $i, $groups=[], $domain=false, $flags=0)
Get a database connection handle reference.
flushReplicaSnapshots( $fname=__METHOD__)
Commit all replica DB transactions so as to flush any REPEATABLE-READ or SSI snapshot.
getLazyConnectionRef( $i, $groups=[], $domain=false, $flags=0)
Get a database connection handle reference without connecting yet.
lastMasterChangeTimestamp()
Get the timestamp of the latest write query done by this thread.
closeConnection(IDatabase $conn)
Close a connection.
commitAll( $fname=__METHOD__)
Commit transactions on all open connections.
allowLagged( $mode=null)
Disables/enables lag checks.
closeAll()
Close all open connections.
getLagTimes( $domain=false)
Get an estimate of replication lag (in seconds) for each server.
waitForOne( $pos, $timeout=null)
Set the master wait position and wait for a "generic" replica DB to catch up to it.
getAnyOpenConnection( $i)
Get any open connection to a given server index, local or foreign.
getServerName( $i)
Get the host name or IP address of the server with the specified index.
waitForAll( $pos, $timeout=null)
Set the master wait position and wait for ALL replica DBs to catch up to it.
safeGetLag(IDatabase $conn)
Get the lag in seconds for a given connection, or zero if this load balancer does not have replicatio...
const DB_REPLICA
Definition defines.php:25
const DB_MASTER
Definition defines.php:26
$params