MediaWiki REL1_31
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)
 
- Public Member Functions inherited from Wikimedia\Rdbms\LoadBalancer
 __destruct ()
 
 allowLagged ( $mode=null)
 Disables/enables lag checks.
 
 approveMasterChanges (array $options)
 Perform all pre-commit checks for things like replication safety.
 
 beginMasterChanges ( $fname=__METHOD__)
 Flush any master transaction snapshots and set DBO_TRX (if DBO_DEFAULT is set)
 
 closeAll ()
 Close all open connections.
 
 closeConnection (IDatabase $conn)
 Close a connection.
 
 commitAll ( $fname=__METHOD__)
 Commit transactions on all open connections.
 
 commitMasterChanges ( $fname=__METHOD__)
 Issue COMMIT on all master connections where writes where done.
 
 disable ()
 Disable this load balancer.
 
 finalizeMasterChanges ()
 Perform all pre-commit callbacks that remain part of the atomic transactions and disable any post-commit callbacks until runMasterPostTrxCallbacks()
 
 flushReplicaSnapshots ( $fname=__METHOD__)
 Commit all replica DB transactions so as to flush any REPEATABLE-READ or SSI snapshot.
 
 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 connection handle by server index.
 
 getConnectionRef ( $db, $groups=[], $domain=false, $flags=0)
 Get a database connection handle reference.
 
 getLaggedReplicaMode ( $domain=false)
 
 getLaggedSlaveMode ( $domain=false)
 
 getLagTimes ( $domain=false)
 Get an estimate of replication lag (in seconds) for each server.
 
 getLazyConnectionRef ( $db, $groups=[], $domain=false, $flags=0)
 Get a database connection handle reference without connecting yet.
 
 getLocalDomainID ()
 Get the local (and default) database domain ID of connection handles.
 
 getMaintenanceConnectionRef ( $db, $groups=[], $domain=false, $flags=0)
 Get a maintenance database connection handle reference for migrations and schema changes.
 
 getMasterPos ()
 Get the current master position for chronology control purposes.
 
 getMaxLag ( $domain=false)
 Get the hostname and lag time of the most-lagged replica DB.
 
 getReaderIndex ( $group=false, $domain=false)
 Get the index of the reader connection, which may be a replica DB.
 
 getReadOnlyReason ( $domain=false, IDatabase $conn=null)
 
 getServerAttributes ( $i)
 
 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.
 
 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.
 
 getWriterIndex ()
 
 hasMasterChanges ()
 Determine if there are pending changes 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.
 
 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:
 
 laggedSlaveUsed ()
 
 lastMasterChangeTimestamp ()
 Get the timestamp of the latest write query done by this thread.
 
 openConnection ( $i, $domain=false, $flags=0)
 Open a connection to the server given by the specified index.
 
 pendingMasterChangeCallers ()
 Get the list of callers that have pending master changes.
 
 pingAll ()
 
 reuseConnection (IDatabase $conn)
 Mark a foreign connection as being available for reuse under a different DB domain.
 
 rollbackMasterChanges ( $fname=__METHOD__)
 Issue ROLLBACK only on master, only if queries were done on connection.
 
 runMasterPostTrxCallbacks ( $type)
 Issue all pending post-COMMIT/ROLLBACK 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)
 
 setDomainPrefix ( $prefix)
 Set a new table prefix for the existing local domain ID for testing.
 
 setIndexAliases (array $aliases)
 Convert certain index names to alternative names before querying the DB.
 
 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.
 
 setTransactionListener ( $name, callable $callback=null)
 Set a callback via IDatabase::setTransactionListener() on all current and future master connections of this load balancer.
 
 suppressTransactionEndCallbacks ()
 Suppress all pending post-COMMIT/ROLLBACK callbacks.
 
 waitFor ( $pos)
 Set the master wait position.
 
 waitForAll ( $pos, $timeout=null)
 Set the master wait position and wait for ALL replica DBs to catch up to it.
 
 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 (array $server, DatabaseDomain $domainOverride)
 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 $this.
 
 getScopedPHPBehaviorForCommit ()
 Make PHP ignore user aborts/disconnects until the returned value leaves scope.
 

Private Attributes

IDatabase $db
 

Additional Inherited Members

- Public Attributes inherited from Wikimedia\Rdbms\LoadBalancer
const KEY_FOREIGN_FREE = 'foreignFree'
 
const KEY_FOREIGN_FREE_NOROUND = 'foreignFreeAutoCommit'
 
const KEY_FOREIGN_INUSE = 'foreignInUse'
 
const KEY_FOREIGN_INUSE_NOROUND = 'foreignInUseAutoCommit'
 
const KEY_LOCAL = 'local'
 
const KEY_LOCAL_NOROUND = 'localAutoCommit'
 
- 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.
 
- Protected Attributes inherited from Wikimedia\Rdbms\LoadBalancer
string $agent
 Agent name for query profiling.
 
bool $cliMode
 Whether this PHP instance is for a CLI script.
 
LoggerInterface $connLogger
 
LoggerInterface $perfLogger
 
object string $profiler
 Class name or object With profileIn/profileOut methods.
 
LoggerInterface $queryLogger
 
LoggerInterface $replLogger
 
TransactionProfiler $trxProfiler
 

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.

References $params.

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 71 of file LoadBalancerSingle.php.

References Wikimedia\Rdbms\LoadBalancerSingle\$db, and $params.

◆ reallyOpenConnection()

Wikimedia\Rdbms\LoadBalancerSingle::reallyOpenConnection ( array $server,
DatabaseDomain $domainOverride )
protected

Open a new network connection to a server (uncached)

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

Parameters
array$server
DatabaseDomain$domainOverrideUse an unspecified domain to not select any database
Returns
Database
Exceptions
DBAccessError
InvalidArgumentException

Reimplemented from Wikimedia\Rdbms\LoadBalancer.

Definition at line 75 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: