class LBFactorySimple extends LBFactory {
/** @var LoadBalancer */
private $mainLB;
-
/** @var LoadBalancer[] */
private $extLBs = array();
- /** @var ChronologyProtector */
- private $chronProt;
+ /** @var string */
+ private $loadMonitorClass;
public function __construct( array $conf ) {
- $this->chronProt = new ChronologyProtector;
+ parent::__construct( $conf );
+
+ $this->loadMonitorClass = isset( $conf['loadMonitorClass'] )
+ ? $conf['loadMonitorClass']
+ : null;
}
/**
*/
public function newMainLB( $wiki = false ) {
global $wgDBservers;
- if ( $wgDBservers ) {
+
+ if ( is_array( $wgDBservers ) ) {
$servers = $wgDBservers;
+ foreach ( $servers as $i => &$server ) {
+ if ( $i == 0 ) {
+ $server['master'] = true;
+ } else {
+ $server['slave'] = true;
+ }
+ }
} else {
global $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, $wgDBtype, $wgDebugDumpSql;
global $wgDBssl, $wgDBcompress;
'dbname' => $wgDBname,
'type' => $wgDBtype,
'load' => 1,
- 'flags' => $flags
+ 'flags' => $flags,
+ 'master' => true
) );
}
return new LoadBalancer( array(
'servers' => $servers,
+ 'loadMonitor' => $this->loadMonitorClass,
+ 'readOnlyReason' => $this->readOnlyReason
) );
}
}
return new LoadBalancer( array(
- 'servers' => $wgExternalServers[$cluster]
+ 'servers' => $wgExternalServers[$cluster],
+ 'loadMonitor' => $this->loadMonitorClass,
+ 'readOnlyReason' => $this->readOnlyReason
) );
}
}
}
- public function shutdown() {
- if ( $this->mainLB ) {
- $this->chronProt->shutdownLB( $this->mainLB );
- }
- foreach ( $this->extLBs as $extLB ) {
- $this->chronProt->shutdownLB( $extLB );
+ public function shutdown( $flags = 0 ) {
+ if ( !( $flags & self::SHUTDOWN_NO_CHRONPROT ) ) {
+ $this->shutdownChronologyProtector( $this->chronProt );
}
- $this->chronProt->shutdown();
- $this->commitMasterChanges();
+ $this->commitMasterChanges(); // sanity
}
}