/**
  * @param array $conf An associative array with one member:
  *  - connection: The IDatabase connection object
  */
 public function __construct(array $conf)
 {
     parent::__construct($conf);
     if (!isset($conf['connection'])) {
         throw new InvalidArgumentException("Missing 'connection' argument.");
     }
     $lb = new LoadBalancerSingle(array_merge($this->baseLoadBalancerParams(), $conf));
     $this->initLoadBalancer($lb);
     $this->lb = $lb;
 }
 /**
  * @see LBFactory::__construct()
  * @param array $conf Parameters of LBFactory::__construct() as well as:
  *   - servers : list of server configuration maps to Database::factory().
  *      Additionally, the server maps should have a 'load' key, which is used to decide
  *      how often clients connect to one server verses the others. A 'max lag' key should
  *      also be set on server maps, indicating how stale the data can be before the load
  *      balancer tries to avoid using it. The map can have 'is static' set to disable blocking
  *      replication sync checks (intended for archive servers with unchanging data).
  *   - externalClusters : map of cluster names to server arrays. The servers arrays have the
  *      same format as "servers" above.
  */
 public function __construct(array $conf)
 {
     parent::__construct($conf);
     $this->servers = isset($conf['servers']) ? $conf['servers'] : [];
     foreach ($this->servers as $i => $server) {
         if ($i == 0) {
             $this->servers[$i]['master'] = true;
         } else {
             $this->servers[$i]['replica'] = true;
         }
     }
     $this->externalClusters = isset($conf['externalClusters']) ? $conf['externalClusters'] : [];
     $this->loadMonitorClass = isset($conf['loadMonitorClass']) ? $conf['loadMonitorClass'] : 'LoadMonitor';
 }
 /**
  * @param array $conf
  * @throws MWException
  */
 public function __construct(array $conf)
 {
     parent::__construct($conf);
     $this->chronProt = new ChronologyProtector();
     $this->conf = $conf;
     $required = array('sectionsByDB', 'sectionLoads', 'serverTemplate');
     $optional = array('groupLoadsBySection', 'groupLoadsByDB', 'hostsByName', 'externalLoads', 'externalTemplateOverrides', 'templateOverridesByServer', 'templateOverridesByCluster', 'masterTemplateOverrides', 'readOnlyBySection', 'loadMonitorClass');
     foreach ($required as $key) {
         if (!isset($conf[$key])) {
             throw new MWException(__CLASS__ . ": {$key} is required in configuration");
         }
         $this->{$key} = $conf[$key];
     }
     foreach ($optional as $key) {
         if (isset($conf[$key])) {
             $this->{$key} = $conf[$key];
         }
     }
 }
Exemple #4
0
 public function __construct(array $conf)
 {
     parent::__construct($conf);
     $this->loadMonitorClass = isset($conf['loadMonitorClass']) ? $conf['loadMonitorClass'] : null;
 }
 /**
  * @param array $conf An associative array with one member:
  *  - connection: The DatabaseBase connection object
  */
 public function __construct(array $conf)
 {
     parent::__construct($conf);
     $this->lb = new LoadBalancerSingle(['readOnlyReason' => $this->readOnlyReason, 'trxProfiler' => $this->trxProfiler] + $conf);
 }
 public function __construct(array $conf)
 {
     parent::__construct($conf);
     $this->chronProt = new ChronologyProtector();
     $this->loadMonitorClass = isset($conf['loadMonitorClass']) ? $conf['loadMonitorClass'] : null;
 }
Exemple #7
0
 /**
  * @see LBFactory::__construct()
  *
  * Template override precedence (highest => lowest):
  *   - templateOverridesByServer
  *   - masterTemplateOverrides
  *   - templateOverridesBySection/templateOverridesByCluster
  *   - externalTemplateOverrides
  *   - serverTemplate
  * Overrides only work on top level keys (so nested values will not be merged).
  *
  * Server configuration maps should be of the format Database::factory() requires.
  * Additionally, a 'max lag' key should also be set on server maps, indicating how stale the
  * data can be before the load balancer tries to avoid using it. The map can have 'is static'
  * set to disable blocking  replication sync checks (intended for archive servers with
  * unchanging data).
  *
  * @param array $conf Parameters of LBFactory::__construct() as well as:
  *   - sectionsByDB                Map of database names to section names.
  *   - sectionLoads                2-d map. For each section, gives a map of server names to
  *                                 load ratios. For example:
  *                                 [
  *                                     'section1' => [
  *                                         'db1' => 100,
  *                                         'db2' => 100
  *                                     ]
  *                                 ]
  *   - serverTemplate              Server configuration map intended for Database::factory().
  *                                 Note that "host", "hostName" and "load" entries will be
  *                                 overridden by "sectionLoads" and "hostsByName".
  *   - groupLoadsBySection         3-d map giving server load ratios for each section/group.
  *                                 For example:
  *                                 [
  *                                     'section1' => [
  *                                         'group1' => [
  *                                             'db1' => 100,
  *                                             'db2' => 100
  *                                         ]
  *                                     ]
  *                                 ]
  *   - groupLoadsByDB              3-d map giving server load ratios by DB name.
  *   - hostsByName                 Map of hostname to IP address.
  *   - externalLoads               Map of external storage cluster name to server load map.
  *   - externalTemplateOverrides   Set of server configuration maps overriding
  *                                 "serverTemplate" for external storage.
  *   - templateOverridesByServer   2-d map overriding "serverTemplate" and
  *                                 "externalTemplateOverrides" on a server-by-server basis.
  *                                 Applies to both core and external storage.
  *   - templateOverridesBySection  2-d map overriding the server configuration maps by section.
  *   - templateOverridesByCluster  2-d map overriding the server configuration maps by external
  *                                 storage cluster.
  *   - masterTemplateOverrides     Server configuration map overrides for all master servers.
  *   - loadMonitorClass            Name of the LoadMonitor class to always use.
  *   - readOnlyBySection           A map of section name to read-only message.
  *                                 Missing or false for read/write.
  */
 public function __construct(array $conf)
 {
     parent::__construct($conf);
     $this->conf = $conf;
     $required = ['sectionsByDB', 'sectionLoads', 'serverTemplate'];
     $optional = ['groupLoadsBySection', 'groupLoadsByDB', 'hostsByName', 'externalLoads', 'externalTemplateOverrides', 'templateOverridesByServer', 'templateOverridesByCluster', 'templateOverridesBySection', 'masterTemplateOverrides', 'readOnlyBySection', 'loadMonitorClass'];
     foreach ($required as $key) {
         if (!isset($conf[$key])) {
             throw new InvalidArgumentException(__CLASS__ . ": {$key} is required.");
         }
         $this->{$key} = $conf[$key];
     }
     foreach ($optional as $key) {
         if (isset($conf[$key])) {
             $this->{$key} = $conf[$key];
         }
     }
 }
 /**
  * @param array $conf An associative array with one member:
  *  - connection: The DatabaseBase connection object
  */
 public function __construct(array $conf)
 {
     parent::__construct($conf);
     $this->lb = new LoadBalancerSingle($conf);
 }
 /**
  * @param array $conf An associative array with one member:
  *  - connection: The DatabaseBase connection object
  */
 public function __construct(array $conf)
 {
     parent::__construct($conf);
     $conf['readOnlyReason'] = $this->readOnlyReason;
     $this->lb = new LoadBalancerSingle($conf);
 }