http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88812
Revision: 88812
Author: reedy
Date: 2011-05-25 18:41:31 +0000 (Wed, 25 May 2011)
Log Message:
-----------
Documentation
Modified Paths:
--------------
trunk/phase3/includes/db/DatabaseError.php
trunk/phase3/includes/db/LBFactory_Multi.php
trunk/phase3/includes/db/LBFactory_Single.php
trunk/phase3/includes/db/LoadBalancer.php
trunk/phase3/includes/db/LoadMonitor.php
Modified: trunk/phase3/includes/db/DatabaseError.php
===================================================================
--- trunk/phase3/includes/db/DatabaseError.php 2011-05-25 18:37:32 UTC (rev
88811)
+++ trunk/phase3/includes/db/DatabaseError.php 2011-05-25 18:41:31 UTC (rev
88812)
@@ -1,18 +1,19 @@
<?php
-/******************************************************************************
- * Error classes
- *****************************************************************************/
/**
* Database error base class
* @ingroup Database
*/
class DBError extends MWException {
+
+ /**
+ * @var DatabaseBase
+ */
public $db;
/**
* Construct a database error
- * @param $db Database object which threw the error
+ * @param $db DatabaseBase object which threw the error
* @param $error String A simple error message to be used for debugging
*/
function __construct( DatabaseBase &$db, $error ) {
Modified: trunk/phase3/includes/db/LBFactory_Multi.php
===================================================================
--- trunk/phase3/includes/db/LBFactory_Multi.php 2011-05-25 18:37:32 UTC
(rev 88811)
+++ trunk/phase3/includes/db/LBFactory_Multi.php 2011-05-25 18:41:31 UTC
(rev 88812)
@@ -98,6 +98,10 @@
return $section;
}
+ /**
+ * @param $wiki
+ * @return LoadBalancer
+ */
function newMainLB( $wiki = false ) {
list( $dbName, ) = $this->getDBNameAndPrefix( $wiki );
$section = $this->getSectionForWiki( $wiki );
@@ -111,6 +115,10 @@
return $this->newLoadBalancer( $this->serverTemplate,
$this->sectionLoads[$section], $groupLoads );
}
+ /**
+ * @param $wiki
+ * @return LoadBalancer
+ */
function getMainLB( $wiki = false ) {
$section = $this->getSectionForWiki( $wiki );
if ( !isset( $this->mainLBs[$section] ) ) {
@@ -122,6 +130,11 @@
return $this->mainLBs[$section];
}
+ /**
+ * @param $cluster
+ * @param $wiki
+ * @return LoadBalancer
+ */
function newExternalLB( $cluster, $wiki = false ) {
if ( !isset( $this->externalLoads[$cluster] ) ) {
throw new MWException( __METHOD__.": Unknown cluster
\"$cluster\"" );
@@ -136,6 +149,11 @@
return $this->newLoadBalancer( $template,
$this->externalLoads[$cluster], array() );
}
+ /**
+ * @param $cluster
+ * @param $wiki
+ * @return LoadBalancer
+ */
function &getExternalLB( $cluster, $wiki = false ) {
if ( !isset( $this->extLBs[$cluster] ) ) {
$this->extLBs[$cluster] = $this->newExternalLB(
$cluster, $wiki );
@@ -146,6 +164,8 @@
/**
* Make a new load balancer object based on template and load array
+ *
+ * @return LoadBalancer
*/
function newLoadBalancer( $template, $loads, $groupLoads ) {
global $wgMasterWaitTimeout;
Modified: trunk/phase3/includes/db/LBFactory_Single.php
===================================================================
--- trunk/phase3/includes/db/LBFactory_Single.php 2011-05-25 18:37:32 UTC
(rev 88811)
+++ trunk/phase3/includes/db/LBFactory_Single.php 2011-05-25 18:41:31 UTC
(rev 88812)
@@ -14,18 +14,30 @@
$this->lb = new LoadBalancer_Single( $conf );
}
+ /**
+ * @return LoadBalancer_Single
+ */
function newMainLB( $wiki = false ) {
return $this->lb;
}
+ /**
+ * @return LoadBalancer_Single
+ */
function getMainLB( $wiki = false ) {
return $this->lb;
}
+ /**
+ * @return LoadBalancer_Single
+ */
function newExternalLB( $cluster, $wiki = false ) {
return $this->lb;
}
+ /**
+ * @return LoadBalancer_Single
+ */
function &getExternalLB( $cluster, $wiki = false ) {
return $this->lb;
}
@@ -55,6 +67,9 @@
) ) ) );
}
+ /**
+ * @return DatabaseBase
+ */
function reallyOpenConnection( $server, $dbNameOverride = false ) {
return $this->db;
}
Modified: trunk/phase3/includes/db/LoadBalancer.php
===================================================================
--- trunk/phase3/includes/db/LoadBalancer.php 2011-05-25 18:37:32 UTC (rev
88811)
+++ trunk/phase3/includes/db/LoadBalancer.php 2011-05-25 18:41:31 UTC (rev
88812)
@@ -89,6 +89,10 @@
/**
* Given an array of non-normalised probabilities, this function will
select
* an element and return the appropriate key
+ *
+ * @param $weights
+ *
+ * @return int
*/
function pickRandom( $weights ) {
if ( !is_array( $weights ) || count( $weights ) == 0 ) {
@@ -116,6 +120,11 @@
return $i;
}
+ /**
+ * @param $loads
+ * @param $wiki bool
+ * @return bool|int|string
+ */
function getRandomNonLagged( $loads, $wiki = false ) {
# Unset excessively lagged servers
$lags = $this->getLagTimes( $wiki );
@@ -160,6 +169,9 @@
* always return a consistent index during a given invocation
*
* Side effect: opens connections to databases
+ * @param $group bool
+ * @param $wiki bool
+ * @return bool|int|string
*/
function getReaderIndex( $group = false, $wiki = false ) {
global $wgReadOnly, $wgDBClusterTimeout, $wgDBAvgStatusPoll,
$wgDBtype;
@@ -517,8 +529,8 @@
* On error, returns false, and the connection which caused the
* error will be available via $this->mErrorConnection.
*
- * @param $i Integer: server index
- * @param $wiki String: wiki ID to open
+ * @param $i Integer server index
+ * @param $wiki String wiki ID to open
* @return DatabaseBase
*
* @access private
@@ -626,6 +638,7 @@
*
* @param $index Integer: server index
* @access private
+ * @return bool
*/
function isOpen( $index ) {
if( !is_integer( $index ) ) {
@@ -638,6 +651,8 @@
* Really opens a connection. Uncached.
* Returns a Database object whether or not the connection was
successful.
* @access private
+ *
+ * @return DatabaseBase
*/
function reallyOpenConnection( $server, $dbNameOverride = false ) {
if( !is_array( $server ) ) {
@@ -693,6 +708,8 @@
/**
* Returns true if the specified index is a valid server index
+ *
+ * @return bool
*/
function haveIndex( $i ) {
return array_key_exists( $i, $this->mServers );
@@ -700,6 +717,8 @@
/**
* Returns true if the specified index is valid and has non-zero load
+ *
+ * @return bool
*/
function isNonZeroLoad( $i ) {
return array_key_exists( $i, $this->mServers ) &&
$this->mLoads[$i] != 0;
@@ -707,6 +726,8 @@
/**
* Get the number of defined servers (not the number of open
connections)
+ *
+ * @return int
*/
function getServerCount() {
return count( $this->mServers );
@@ -787,6 +808,8 @@
/**
* Deprecated function, typo in function name
+ *
+ * @deprecated in 1.18
*/
function closeConnecton( $conn ) {
$this->closeConnection( $conn );
@@ -796,7 +819,7 @@
* 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 $conn
+ * @param $conn
* @return void
*/
function closeConnection( $conn ) {
@@ -831,7 +854,9 @@
}
}
- /* Issue COMMIT only on master, only if queries were done on connection
*/
+ /**
+ * Issue COMMIT only on master, only if queries were done on connection
+ */
function commitMasterChanges() {
// Always 0, but who knows.. :)
$masterIndex = $this->getWriterIndex();
@@ -856,10 +881,11 @@
}
/* Disables/enables lag checks */
- function allowLagged($mode=null) {
- if ($mode===null)
+ function allowLagged( $mode = null ) {
+ if ( $mode === null) {
return $this->mAllowLagged;
- $this->mAllowLagged=$mode;
+ }
+ $this->mAllowLagged = $mode;
}
function pingAll() {
Modified: trunk/phase3/includes/db/LoadMonitor.php
===================================================================
--- trunk/phase3/includes/db/LoadMonitor.php 2011-05-25 18:37:32 UTC (rev
88811)
+++ trunk/phase3/includes/db/LoadMonitor.php 2011-05-25 18:41:31 UTC (rev
88812)
@@ -72,9 +72,19 @@
$this->parent = $parent;
}
+ /**
+ * @param $loads
+ * @param $group bool
+ * @param $wiki bool
+ */
function scaleLoads( &$loads, $group = false, $wiki = false ) {
}
+ /**
+ * @param $serverIndexes
+ * @param $wiki
+ * @return array
+ */
function getLagTimes( $serverIndexes, $wiki ) {
wfProfileIn( __METHOD__ );
$expiry = 5;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs