[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Source view] [Print] [Project Stats]
Database load balancing. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
File Size: | 1224 lines (34 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
LoadBalancer:: (44 methods):
__construct()
getLoadMonitor()
parentInfo()
pickRandom()
getRandomNonLagged()
getReaderIndex()
sleep()
waitFor()
waitForAll()
getAnyOpenConnection()
doWait()
getConnection()
reuseConnection()
getConnectionRef()
getLazyConnectionRef()
openConnection()
openForeignConnection()
isOpen()
reallyOpenConnection()
reportConnectionError()
getWriterIndex()
haveIndex()
isNonZeroLoad()
getServerCount()
getServerName()
getServerInfo()
setServerInfo()
getMasterPos()
closeAll()
closeConnection()
commitAll()
commitMasterChanges()
rollbackMasterChanges()
hasMasterConnection()
hasMasterChanges()
waitTimeout()
getLaggedSlaveMode()
allowLagged()
pingAll()
forEachOpenConnection()
getMaxLag()
getLagTimes()
safeGetLag()
clearLagTimeCache()
DBConnRef:: (3 methods):
__construct()
__call()
__destruct()
Class: LoadBalancer - X-Ref
Database load balancing object__construct( $params ) X-Ref |
param: array $params Array with keys: |
getLoadMonitor() X-Ref |
Get a LoadMonitor instance return: LoadMonitor |
parentInfo( $x = null ) X-Ref |
Get or set arbitrary data used by the parent object, usually an LBFactory param: mixed $x return: mixed |
pickRandom( $weights ) X-Ref |
Given an array of non-normalised probabilities, this function will select an element and return the appropriate key param: array $weights return: bool|int|string |
getRandomNonLagged( $loads, $wiki = false ) X-Ref |
param: array $loads param: bool|string $wiki Wiki to get non-lagged for return: bool|int|string |
getReaderIndex( $group = false, $wiki = false ) X-Ref |
Get the index of the reader connection, which may be a slave This takes into account load ratios and lag times. It should always return a consistent index during a given invocation Side effect: opens connections to databases param: bool|string $group param: bool|string $wiki return: bool|int|string |
sleep( $t ) X-Ref |
Wait for a specified number of microseconds, and return the period waited param: int $t return: int |
waitFor( $pos ) X-Ref |
Set the master wait position If a DB_SLAVE connection has been opened already, waits Otherwise sets a variable telling it to wait if such a connection is opened param: DBMasterPos $pos |
waitForAll( $pos, $timeout = null ) X-Ref |
Set the master wait position and wait for ALL slaves to catch up to it param: DBMasterPos $pos param: int $timeout Max seconds to wait; default is mWaitTimeout return: bool Success (able to connect and no timeouts reached) |
getAnyOpenConnection( $i ) X-Ref |
Get any open connection to a given server index, local or foreign Returns false if there is no connection open param: int $i return: DatabaseBase|bool False on failure |
doWait( $index, $open = false, $timeout = null ) X-Ref |
Wait for a given slave to catch up to the master pos stored in $this param: int $index Server index param: bool $open Check the server even if a new connection has to be made param: int $timeout Max seconds to wait; default is mWaitTimeout return: bool |
getConnection( $i, $groups = array() X-Ref |
Get a connection by index This is the main entry point for this class. param: int $i Server index param: array $groups Query groups param: bool|string $wiki Wiki ID return: DatabaseBase |
reuseConnection( $conn ) X-Ref |
Mark a foreign connection as being available for reuse under a different DB name or prefix. This mechanism is reference-counted, and must be called the same number of times as getConnection() to work. param: DatabaseBase $conn |
getConnectionRef( $db, $groups = array() X-Ref |
Get a database connection handle reference The handle's methods wrap simply wrap those of a DatabaseBase handle param: int $db param: mixed $groups param: bool|string $wiki return: DBConnRef |
getLazyConnectionRef( $db, $groups = array() X-Ref |
Get a database connection handle reference without connecting yet The handle's methods wrap simply wrap those of a DatabaseBase handle param: int $db param: mixed $groups param: bool|string $wiki return: DBConnRef |
openConnection( $i, $wiki = false ) X-Ref |
Open a connection to the server given by the specified index Index must be an actual index into the array. If the server is already open, returns it. On error, returns false, and the connection which caused the error will be available via $this->mErrorConnection. param: int $i Server index param: bool|string $wiki Wiki ID to open return: DatabaseBase |
openForeignConnection( $i, $wiki ) X-Ref |
Open a connection to a foreign DB, or return one if it is already open. Increments a reference count on the returned connection which locks the connection to the requested wiki. This reference count can be decremented by calling reuseConnection(). If a connection is open to the appropriate server already, but with the wrong database, it will be switched to the right database and returned, as long as it has been freed first with reuseConnection(). On error, returns false, and the connection which caused the error will be available via $this->mErrorConnection. param: int $i Server index param: string $wiki Wiki ID to open return: DatabaseBase |
isOpen( $index ) X-Ref |
Test if the specified index represents an open connection param: int $index Server index return: bool |
reallyOpenConnection( $server, $dbNameOverride = false ) X-Ref |
Really opens a connection. Uncached. Returns a Database object whether or not the connection was successful. param: array $server param: bool $dbNameOverride return: DatabaseBase |
reportConnectionError() X-Ref |
return: bool |
getWriterIndex() X-Ref |
return: int |
haveIndex( $i ) X-Ref |
Returns true if the specified index is a valid server index param: string $i return: bool |
isNonZeroLoad( $i ) X-Ref |
Returns true if the specified index is valid and has non-zero load param: string $i return: bool |
getServerCount() X-Ref |
Get the number of defined servers (not the number of open connections) return: int |
getServerName( $i ) X-Ref |
Get the host name or IP address of the server with the specified index Prefer a readable name if available. param: string $i return: string |
getServerInfo( $i ) X-Ref |
Return the server info structure for a given index, or false if the index is invalid. param: int $i return: array|bool |
setServerInfo( $i, $serverInfo ) X-Ref |
Sets the server info structure for the given index. Entry at index $i is created if it doesn't exist param: int $i param: array $serverInfo |
getMasterPos() X-Ref |
Get the current master position for chronology control purposes return: mixed |
closeAll() X-Ref |
Close all open connections |
closeConnection( $conn ) X-Ref |
Close a connection Using this function makes sure the LoadBalancer knows the connection is closed. If you use $conn->close() directly, the load balancer won't update its state. param: DatabaseBase $conn |
commitAll() X-Ref |
Commit transactions on all open connections |
commitMasterChanges() X-Ref |
Issue COMMIT only on master, only if queries were done on connection |
rollbackMasterChanges() X-Ref |
Issue ROLLBACK only on master, only if queries were done on connection |
hasMasterConnection() X-Ref |
return: bool Whether a master connection is already open |
hasMasterChanges() X-Ref |
Determine if there are any pending changes that need to be rolled back or committed. return: bool |
waitTimeout( $value = null ) X-Ref |
param: mixed $value return: mixed |
getLaggedSlaveMode() X-Ref |
return: bool |
allowLagged( $mode = null ) X-Ref |
Disables/enables lag checks param: null|bool $mode return: bool |
pingAll() X-Ref |
return: bool |
forEachOpenConnection( $callback, $params = array() X-Ref |
Call a function with each open connection object param: callable $callback param: array $params |
getMaxLag( $wiki = false ) X-Ref |
Get the hostname and lag time of the most-lagged slave. This is useful for maintenance scripts that need to throttle their updates. May attempt to open connections to slaves on the default DB. If there is no lag, the maximum lag will be reported as -1. param: bool|string $wiki Wiki ID, or false for the default database return: array ( host, max lag, index of max lagged host ) |
getLagTimes( $wiki = false ) X-Ref |
Get lag time for each server Results are cached for a short time in memcached, and indefinitely in the process cache param: string|bool $wiki return: array |
safeGetLag( $conn ) X-Ref |
Get the lag in seconds for a given connection, or zero if this load balancer does not have replication enabled. This should be used in preference to Database::getLag() in cases where replication may not be in use, since there is no way to determine if replication is in use at the connection level without running potentially restricted queries such as SHOW SLAVE STATUS. Using this function instead of Database::getLag() avoids a fatal error in this case on many installations. param: DatabaseBase $conn return: int |
clearLagTimeCache() X-Ref |
Clear the cache for getLagTimes |
__construct( LoadBalancer $lb, $conn ) X-Ref |
param: LoadBalancer $lb param: DatabaseBase|array $conn Connection or (server index, group, wiki ID) array |
__call( $name, $arguments ) X-Ref |
No description |
__destruct() X-Ref |
No description |
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |