MediaWiki fundraising/REL1_35
Wikimedia\Rdbms\LoadBalancerSingle Class Reference

Trivial LoadBalancer that always returns an injected connection handle. More...

Inheritance diagram for Wikimedia\Rdbms\LoadBalancerSingle:
Collaboration diagram for Wikimedia\Rdbms\LoadBalancerSingle:

Public Member Functions

 __construct (array $params)
 
 __destruct ()
 
- Public Member Functions inherited from Wikimedia\Rdbms\LoadBalancer
 allowLagged ( $mode=null)
 Disables/enables lag checks.
 
 approveMasterChanges (array $options, $fname=__METHOD__, $owner=null)
 Perform all pre-commit checks for things like replication safety.
 
 beginMasterChanges ( $fname=__METHOD__, $owner=null)
 Flush any master transaction snapshots and set DBO_TRX (if DBO_DEFAULT is set)
 
 closeAll ( $fname=__METHOD__, $owner=null)
 Close all open connections.
 
 closeConnection (IDatabase $conn)
 Close a connection.
 
 commitAll ( $fname=__METHOD__, $owner=null)
 Commit transactions on all open connections.
 
 commitMasterChanges ( $fname=__METHOD__, $owner=null)
 Issue COMMIT on all open master connections to flush changes and view snapshots.
 
 disable ( $fname=__METHOD__, $owner=null)
 Close all connections and disable this load balancer.
 
 finalizeMasterChanges ( $fname=__METHOD__, $owner=null)
 Run pre-commit callbacks and defer execution of post-commit callbacks.
 
 flushMasterSnapshots ( $fname=__METHOD__, $owner=null)
 Commit all master DB transactions so as to flush any REPEATABLE-READ or SSI snapshots.
 
 flushReplicaSnapshots ( $fname=__METHOD__, $owner=null)
 Commit all replica DB transactions so as to flush any REPEATABLE-READ or SSI snapshots.
 
 forEachOpenConnection ( $callback, array $params=[])
 Call a function with each open connection object.
 
 forEachOpenMasterConnection ( $callback, array $params=[])
 Call a function with each open connection object to a master.
 
 forEachOpenReplicaConnection ( $callback, array $params=[])
 Call a function with each open replica DB connection object.
 
 getAnyOpenConnection ( $i, $flags=0)
 Get any open connection to a given server index, local or foreign.
 
 getConnection ( $i, $groups=[], $domain=false, $flags=0)
 Get a live handle for a real or virtual (DB_MASTER/DB_REPLICA) server index.
 
 getConnectionRef ( $i, $groups=[], $domain=false, $flags=0)
 Get a live database handle reference for a real or virtual (DB_MASTER/DB_REPLICA) server index.
 
 getLaggedReplicaMode ( $domain=false)
 
 getLagTimes ( $domain=false)
 Get an estimate of replication lag (in seconds) for each server.
 
 getLazyConnectionRef ( $i, $groups=[], $domain=false, $flags=0)
 Get a database handle reference for a real or virtual (DB_MASTER/DB_REPLICA) server index.
 
 getLocalDomainID ()
 Get the local (and default) database domain ID of connection handles.
 
 getMaintenanceConnectionRef ( $i, $groups=[], $domain=false, $flags=0)
 Get a live database handle for a real or virtual (DB_MASTER/DB_REPLICA) server index that can be used for data migrations and schema changes.
 
 getMasterPos ()
 Get the current master replication position.
 
 getMaxLag ( $domain=false)
 Get the hostname and lag time of the most-lagged replica server.
 
 getReaderIndex ( $group=false, $domain=false)
 Get the server index of the reader connection for a given group.
 
 getReadOnlyReason ( $domain=false)
 
 getReplicaResumePos ()
 Get the highest DB replication position for chronology control purposes.
 
 getServerAttributes ( $i)
 
 getServerConnection ( $i, $domain, $flags=0)
 
 getServerCount ()
 Get the number of servers defined in configuration.
 
 getServerInfo ( $i)
 Return the server info structure for a given index or false if the index is invalid.
 
 getServerName ( $i)
 Get the host name or IP address of the server with the specified index.
 
 getServerType ( $i)
 Get DB type of the server with the specified index.
 
 getTransactionRoundStage ()
 
 getWriterIndex ()
 Get the server index of the master server.
 
 hasMasterChanges ()
 Whether there are pending changes or callbacks in a transaction by this thread.
 
 hasMasterConnection ()
 
 hasOrMadeRecentMasterChanges ( $age=null)
 Check if this load balancer object had any recent or still pending writes issued against it by this PHP thread.
 
 hasReplicaServers ()
 Whether there are any replica servers configured.
 
 hasStreamingReplicaServers ()
 Whether any replica servers use streaming replication from the master server.
 
 haveIndex ( $i)
 Returns true if the specified index is a valid server 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:
 
 lastMasterChangeTimestamp ()
 Get the timestamp of the latest write query done by this thread.
 
 openConnection ( $i, $domain=false, $flags=0)
 
 pendingMasterChangeCallers ()
 Get the list of callers that have pending master changes.
 
 pingAll ()
 
 redefineLocalDomain ( $domain)
 Close all connection and redefine the local domain for testing or schema creation.
 
 resolveDomainID ( $domain)
 
 reuseConnection (IDatabase $conn)
 Mark a live handle as being available for reuse under a different database domain.
 
 rollbackMasterChanges ( $fname=__METHOD__, $owner=null)
 Issue ROLLBACK only on master, only if queries were done on connection.
 
 runMasterTransactionIdleCallbacks ( $fname=__METHOD__, $owner=null)
 Consume and run all pending post-COMMIT/ROLLBACK callbacks and commit dangling transactions.
 
 runMasterTransactionListenerCallbacks ( $fname=__METHOD__, $owner=null)
 Run all recurring post-COMMIT/ROLLBACK listener callbacks.
 
 safeGetLag (IDatabase $conn)
 Get the lag in seconds for a given connection, or zero if this load balancer does not have replication enabled.
 
 safeWaitForMasterPos (IDatabase $conn, $pos=false, $timeout=null)
 Wait for a replica DB to reach a specified master position.
 
 setDomainAliases (array $aliases)
 Convert certain database domains to alternative ones.
 
 setIndexAliases (array $aliases)
 Convert certain index names to alternative names before querying the DB.
 
 setLocalDomainPrefix ( $prefix)
 Set a new table prefix for the existing local domain ID for testing.
 
 setTableAliases (array $aliases)
 Make certain table names use their own database, schema, and table prefix when passed into SQL queries pre-escaped and without a qualified database name.
 
 setTempTablesOnlyMode ( $value, $domain)
 Indicate whether the tables on this domain are only temporary tables for testing.
 
 setTransactionListener ( $name, callable $callback=null)
 Set a callback via IDatabase::setTransactionListener() on all current and future master connections of this load balancer.
 
 waitFor ( $pos)
 Set the master position to reach before the next generic group DB handle query.
 
 waitForAll ( $pos, $timeout=null)
 Set the master wait position and wait for ALL replica DBs to catch up to it.
 
 waitForMasterPos (IDatabase $conn, $pos=false, $timeout=null)
 Wait for a replica DB to reach a specified master position.
 
 waitForOne ( $pos, $timeout=null)
 Set the master wait position and wait for a generic replica DB to catch up to it.
 

Static Public Member Functions

static newFromConnection (IDatabase $db, array $params=[])
 

Protected Member Functions

 reallyOpenConnection ( $i, DatabaseDomain $domain, array $lbInfo=[])
 Open a new network connection to a server (uncached)
 
- Protected Member Functions inherited from Wikimedia\Rdbms\LoadBalancer
 doWait ( $index, $open=false, $timeout=null)
 Wait for a given replica DB to catch up to the master pos stored in "waitForPos".
 
 getExistingReaderIndex ( $group)
 Get the server index chosen by the load balancer for use with the given query group.
 
 resolveDomainInstance ( $domain)
 

Private Attributes

IDatabase $db
 

Additional Inherited Members

- Public Attributes inherited from Wikimedia\Rdbms\ILoadBalancer
const DB_MASTER = self::DB_PRIMARY
 Request a primary, write-enabled DB connection.
 
const DB_PRIMARY = -2
 Request a primary, write-enabled DB connection.
 

Detailed Description

Trivial LoadBalancer that always returns an injected connection handle.

Definition at line 31 of file LoadBalancerSingle.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Rdbms\LoadBalancerSingle::__construct ( array $params)
Parameters
array$paramsAn associative array with one member:
  • connection: An IDatabase connection object

Reimplemented from Wikimedia\Rdbms\LoadBalancer.

Definition at line 39 of file LoadBalancerSingle.php.

◆ __destruct()

Wikimedia\Rdbms\LoadBalancerSingle::__destruct ( )

Reimplemented from Wikimedia\Rdbms\LoadBalancer.

Definition at line 85 of file LoadBalancerSingle.php.

Member Function Documentation

◆ newFromConnection()

static Wikimedia\Rdbms\LoadBalancerSingle::newFromConnection ( IDatabase $db,
array $params = [] )
static
Parameters
IDatabase$dbLive connection handle
array$paramsParameter map to LoadBalancerSingle::__constructs()
Returns
LoadBalancerSingle
Since
1.28

Definition at line 73 of file LoadBalancerSingle.php.

References Wikimedia\Rdbms\LoadBalancerSingle\$db, and Wikimedia\Rdbms\IDatabase\getDomainID().

◆ reallyOpenConnection()

Wikimedia\Rdbms\LoadBalancerSingle::reallyOpenConnection ( $i,
DatabaseDomain $domain,
array $lbInfo = [] )
protected

Open a new network connection to a server (uncached)

Returns a Database object whether or not the connection was successful.

Parameters
int$iSpecific server index
DatabaseDomain$domainDomain the connection is for, possibly unspecified
array$lbInfoAdditional information for setLBInfo()
Returns
Database
Exceptions
DBAccessError
InvalidArgumentException

Reimplemented from Wikimedia\Rdbms\LoadBalancer.

Definition at line 81 of file LoadBalancerSingle.php.

References Wikimedia\Rdbms\LoadBalancerSingle\$db.

Member Data Documentation

◆ $db

IDatabase Wikimedia\Rdbms\LoadBalancerSingle::$db
private

The documentation for this class was generated from the following file: