return $section;
}
+ /**
+ * @param $wiki
+ * @return LoadBalancer
+ */
function newMainLB( $wiki = false ) {
list( $dbName, ) = $this->getDBNameAndPrefix( $wiki );
$section = $this->getSectionForWiki( $wiki );
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] ) ) {
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\"" );
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 );
/**
* Make a new load balancer object based on template and load array
+ *
+ * @return LoadBalancer
*/
function newLoadBalancer( $template, $loads, $groupLoads ) {
global $wgMasterWaitTimeout;
/**
* 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 ) {
return $i;
}
+ /**
+ * @param $loads
+ * @param $wiki bool
+ * @return bool|int|string
+ */
function getRandomNonLagged( $loads, $wiki = false ) {
# Unset excessively lagged servers
$lags = $this->getLagTimes( $wiki );
* 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;
* 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
*
* @param $index Integer: server index
* @access private
+ * @return bool
*/
function isOpen( $index ) {
if( !is_integer( $index ) ) {
* 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 ) ) {
/**
* Returns true if the specified index is a valid server index
+ *
+ * @return bool
*/
function haveIndex( $i ) {
return array_key_exists( $i, $this->mServers );
/**
* 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;
/**
* Get the number of defined servers (not the number of open connections)
+ *
+ * @return int
*/
function getServerCount() {
return count( $this->mServers );
/**
* Deprecated function, typo in function name
+ *
+ * @deprecated in 1.18
*/
function closeConnecton( $conn ) {
$this->closeConnection( $conn );
* 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 ) {
}
}
- /* 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();
}
/* 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() {