* @ingroup Database
*/
class LoadBalancer {
- /* private */ var $mServers, $mConns, $mLoads, $mGroupLoads;
- /* private */ var $mErrorConnection;
- /* private */ var $mReadIndex, $mAllowLagged;
- /* private */ var $mWaitForPos, $mWaitTimeout;
- /* private */ var $mLaggedSlaveMode, $mLastError = 'Unknown error';
- /* private */ var $mParentInfo, $mLagTimes;
- /* private */ var $mLoadMonitorClass, $mLoadMonitor;
+ private $mServers, $mConns, $mLoads, $mGroupLoads;
+ private $mErrorConnection;
+ private $mReadIndex, $mAllowLagged;
+ private $mWaitForPos, $mWaitTimeout;
+ private $mLaggedSlaveMode, $mLastError = 'Unknown error';
+ private $mParentInfo, $mLagTimes;
+ private $mLoadMonitorClass, $mLoadMonitor;
/**
* @param $params Array with keys:
* Given an array of non-normalised probabilities, this function will select
* an element and return the appropriate key
*/
- function pickRandom( $weights )
- {
+ function pickRandom( $weights ) {
if ( !is_array( $weights ) || count( $weights ) == 0 ) {
return false;
}
}
}
+ /**
+ * Sets the server info structure for the given index. Entry at index $i is created if it doesn't exist
+ */
+ function setServerInfo( $i, $serverInfo ) {
+ $this->mServers[i] = $serverInfo;
+ }
+
/**
* Get the current master position for chronology control purposes
* @return mixed
}
if ( $d > 1 ) {
$lb = wfGetLB();
- foreach ( $lb->mServers as $i => $server ) {
- $lb->mServers[$i]['flags'] |= DBO_DEBUG;
+ $serverCount = $lb->getServerCount();
+ for ( $i = 0; $i < $serverCount; $i++ ) {
+ $server = $lb->getServerInfo( $i );
+ $server['flags'] |= DBO_DEBUG;
+ $lb->setServerInfo( $i, $server );
}
}
if ( $d > 2 ) {