Bug 1102283 - Add suport for locale based throttling. r=nthomas,rhelmer

git-svn-id: svn://10.0.0.236/trunk@265692 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
raliiev%mozilla.com 2014-11-26 16:24:25 +00:00
parent 3461a135ce
commit bcbf866627
2 changed files with 65 additions and 6 deletions

View File

@ -75,6 +75,61 @@ define('THROTTLE_LEVEL',100);
// Turns logging throttled hits on and off. // Turns logging throttled hits on and off.
define('THROTTLE_LOGGING',false); define('THROTTLE_LOGGING',false);
// This defines explicit throttling levels per locale. It overrides global and
// product throttling only for the specified locales.
$localeThrottling = array(
# 'Firefox' => array(
# '10.0' => array('en-US' => 3),
# '10.0.1' => array('en-US' => 3),
# '10.0.2' => array('en-US' => 3),
# '11.0' => array('en-US' => 3),
# '12.0' => array('en-US' => 3),
# '13.0' => array('en-US' => 3),
# '13.0.1' => array('en-US' => 3),
# '14.0.1' => array('en-US' => 3),
# '15.0' => array('en-US' => 3),
# '15.0.1' => array('en-US' => 3),
# '16.0' => array('en-US' => 3),
# '16.0.1' => array('en-US' => 3),
# '16.0.2' => array('en-US' => 3),
# '17.0' => array('en-US' => 3),
# '17.0.1' => array('en-US' => 3),
# '18.0' => array('en-US' => 3),
# '18.0.1' => array('en-US' => 3),
# '18.0.2' => array('en-US' => 3),
# '19.0' => array('en-US' => 3),
# '19.0.1' => array('en-US' => 3),
# '19.0.2' => array('en-US' => 3),
# '25.0' => array('en-US' => 3),
# '25.0.1' => array('en-US' => 3),
# '21.0' => array('en-US' => 3),
# '22.0' => array('en-US' => 3),
# '23.0' => array('en-US' => 3),
# '23.0.1' => array('en-US' => 3),
# '24.0' => array('en-US' => 3),
# '25.0' => array('en-US' => 3),
# '25.0.1' => array('en-US' => 3),
# '26.0' => array('en-US' => 3),
# '27.0' => array('en-US' => 3),
# '27.0.1' => array('en-US' => 3),
# '28.0' => array('en-US' => 3),
# '29.0' => array('en-US' => 3),
# '29.0.1' => array('en-US' => 3),
# '30.0' => array('en-US' => 3),
# '31.0' => array('en-US' => 3),
# '32.0' => array('en-US' => 3),
# '32.0.1' => array('en-US' => 3),
# '32.0.2' => array('en-US' => 3),
# '32.0.3' => array('en-US' => 3),
# '33.0' => array('en-US' => 3),
# '33.0.1' => array('en-US' => 3),
# '33.0.2' => array('en-US' => 3),
# '33.0.3' => array('en-US' => 3),
# '33.1' => array('en-US' => 3),
# '33.1.1' => array('en-US' => 3),
# ),
);
// This defines explicit throttling levels. If global throttling is on, these // This defines explicit throttling levels. If global throttling is on, these
// override global levels. If it is off, this still works. For example, this // override global levels. If it is off, this still works. For example, this
// is 10% throttling (only 10% of the time updates are offered): // is 10% throttling (only 10% of the time updates are offered):

View File

@ -112,12 +112,16 @@ if ( (empty($_GET['force']) || $_GET['force']!=1) ) {
$aus = new AUS_Object(); $aus = new AUS_Object();
// Check explicit throttling. // Check explicit throttling.
if ( !$aus->isThrottleException($clean['version'], $clean['channel']) if ( !$aus->isThrottleException($clean['version'], $clean['channel']) ) {
&& isset($productThrottling[$clean['product']][$clean['version']]) // check if locale based throttling is set. Do not use product based throttling if set
&& mt_rand(0,99) >= $productThrottling[$clean['product']][$clean['version']] if ( isset($localeThrottling[$clean['product']][$clean['version']][$clean['locale']]) ) {
) { if ( mt_rand(0,99) >= $localeThrottling[$clean['product']][$clean['version']][$clean['locale']] ){
$throttleMe = true; $throttleMe = true;
}
} elseif ( isset($productThrottling[$clean['product']][$clean['version']])
&& mt_rand(0,99) >= $productThrottling[$clean['product']][$clean['version']] ) {
$throttleMe = true;
}
// Check global throttling. // Check global throttling.
} elseif ( defined('THROTTLE_GLOBAL') && THROTTLE_GLOBAL && } elseif ( defined('THROTTLE_GLOBAL') && THROTTLE_GLOBAL &&
defined('THROTTLE_LEVEL') && defined('THROTTLE_LEVEL') &&