MediaWiki REL1_28
ILoadBalancer.php
Go to the documentation of this file.
1<?php
75interface ILoadBalancer {
77 const DB_REPLICA = -1;
79 const DB_MASTER = -2;
80
82 const DOMAIN_ANY = '';
83
107 public function __construct( array $params );
108
120 public function getReaderIndex( $group = false, $domain = false );
121
128 public function waitFor( $pos );
129
139 public function waitForOne( $pos, $timeout = null );
140
147 public function waitForAll( $pos, $timeout = null );
148
156 public function getAnyOpenConnection( $i );
157
169 public function getConnection( $i, $groups = [], $domain = false );
170
179 public function reuseConnection( $conn );
180
193 public function getConnectionRef( $db, $groups = [], $domain = false );
194
207 public function getLazyConnectionRef( $db, $groups = [], $domain = false );
208
224 public function openConnection( $i, $domain = false );
225
229 public function getWriterIndex();
230
237 public function haveIndex( $i );
238
245 public function isNonZeroLoad( $i );
246
252 public function getServerCount();
253
260 public function getServerName( $i );
261
267 public function getServerInfo( $i );
268
275 public function setServerInfo( $i, array $serverInfo );
276
281 public function getMasterPos();
282
287 public function disable();
288
292 public function closeAll();
293
302 public function closeConnection( IDatabase $conn );
303
309 public function commitAll( $fname = __METHOD__ );
310
317 public function finalizeMasterChanges();
318
329
342 public function beginMasterChanges( $fname = __METHOD__ );
343
349 public function commitMasterChanges( $fname = __METHOD__ );
350
360
366 public function rollbackMasterChanges( $fname = __METHOD__ );
367
376
382 public function flushReplicaSnapshots( $fname = __METHOD__ );
383
387 public function hasMasterConnection();
388
393 public function hasMasterChanges();
394
399 public function lastMasterChangeTimestamp();
400
408 public function hasOrMadeRecentMasterChanges( $age = null );
409
415 public function pendingMasterChangeCallers();
416
422 public function getLaggedReplicaMode( $domain = false );
423
428 public function laggedReplicaUsed();
429
436 public function getReadOnlyReason( $domain = false, IDatabase $conn = null );
437
443 public function allowLagged( $mode = null );
444
448 public function pingAll();
449
455 public function forEachOpenConnection( $callback, array $params = [] );
456
462 public function forEachOpenMasterConnection( $callback, array $params = [] );
463
469 public function forEachOpenReplicaConnection( $callback, array $params = [] );
470
481 public function getMaxLag( $domain = false );
482
493 public function getLagTimes( $domain = false );
494
509 public function safeGetLag( IDatabase $conn );
510
521 public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = null );
522
530 public function setTransactionListener( $name, callable $callback = null );
531
537 public function setDomainPrefix( $prefix );
538
551 public function setTableAliases( array $aliases );
552}
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition Setup.php:36
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition hooks.txt:2568
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition hooks.txt:1096
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:34
Database cluster connection, tracking, load balancing, and transaction manager interface.
setServerInfo( $i, array $serverInfo)
Sets the server info structure for the given index.
lastMasterChangeTimestamp()
Get the timestamp of the latest write query done by this thread.
haveIndex( $i)
Returns true if the specified index is a valid server index.
getLaggedReplicaMode( $domain=false)
rollbackMasterChanges( $fname=__METHOD__)
Issue ROLLBACK only on master, only if queries were done on connection.
commitMasterChanges( $fname=__METHOD__)
Issue COMMIT on all master connections where writes where done.
waitFor( $pos)
Set the master wait position If a DB_REPLICA connection has been opened already, waits Otherwise sets...
commitAll( $fname=__METHOD__)
Commit transactions on all open connections.
setTransactionListener( $name, callable $callback=null)
Set a callback via IDatabase::setTransactionListener() on all current and future master connections o...
approveMasterChanges(array $options)
Perform all pre-commit checks for things like replication safety.
waitForOne( $pos, $timeout=null)
Set the master wait position and wait for a "generic" replica DB to catch up to it.
getServerInfo( $i)
Return the server info structure for a given index, or false if the index is invalid.
getReadOnlyReason( $domain=false, IDatabase $conn=null)
beginMasterChanges( $fname=__METHOD__)
Flush any master transaction snapshots and set DBO_TRX (if DBO_DEFAULT is set)
getLazyConnectionRef( $db, $groups=[], $domain=false)
Get a database connection handle reference without connecting yet.
getServerCount()
Get the number of defined servers (not the number of open connections)
finalizeMasterChanges()
Perform all pre-commit callbacks that remain part of the atomic transactions and disable any post-com...
getConnection( $i, $groups=[], $domain=false)
Get a connection by index This is the main entry point for this class.
getConnectionRef( $db, $groups=[], $domain=false)
Get a database connection handle reference.
pendingMasterChangeCallers()
Get the list of callers that have pending master changes.
suppressTransactionEndCallbacks()
Suppress all pending post-COMMIT/ROLLBACK callbacks.
hasOrMadeRecentMasterChanges( $age=null)
Check if this load balancer object had any recent or still pending writes issued against it by this P...
getMaxLag( $domain=false)
Get the hostname and lag time of the most-lagged replica DB.
closeAll()
Close all open connections.
forEachOpenReplicaConnection( $callback, array $params=[])
Call a function with each open replica DB connection object.
setDomainPrefix( $prefix)
Set a new table prefix for the existing local domain ID for testing.
allowLagged( $mode=null)
Disables/enables lag checks.
getReaderIndex( $group=false, $domain=false)
Get the index of the reader connection, which may be a replica DB This takes into account load ratios...
isNonZeroLoad( $i)
Returns true if the specified index is valid and has non-zero load.
runMasterPostTrxCallbacks( $type)
Issue all pending post-COMMIT/ROLLBACK callbacks.
closeConnection(IDatabase $conn)
Close a connection.
getMasterPos()
Get the current master position for chronology control purposes.
openConnection( $i, $domain=false)
Open a connection to the server given by the specified index Index must be an actual index into the a...
safeGetLag(IDatabase $conn)
Get the lag in seconds for a given connection, or zero if this load balancer does not have replicatio...
waitForAll( $pos, $timeout=null)
Set the master wait position and wait for ALL replica DBs to catch up to it.
forEachOpenMasterConnection( $callback, array $params=[])
Call a function with each open connection object to a master.
disable()
Disable this load balancer.
flushReplicaSnapshots( $fname=__METHOD__)
Commit all replica DB transactions so as to flush any REPEATABLE-READ or SSI snapshot.
reuseConnection( $conn)
Mark a foreign connection as being available for reuse under a different DB name or prefix.
forEachOpenConnection( $callback, array $params=[])
Call a function with each open connection object.
__construct(array $params)
Construct a manager of IDatabase connection objects.
getAnyOpenConnection( $i)
Get any open connection to a given server index, local or foreign Returns false if there is no connec...
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...
safeWaitForMasterPos(IDatabase $conn, $pos=false, $timeout=null)
Wait for a replica DB to reach a specified master position.
getLagTimes( $domain=false)
Get an estimate of replication lag (in seconds) for each server.
getServerName( $i)
Get the host name or IP address of the server with the specified index Prefer a readable name if avai...
const DB_REPLICA
Definition defines.php:22
const DB_MASTER
Definition defines.php:23
$params