From bcbf86662706a330530d21635b866b070066038c Mon Sep 17 00:00:00 2001 From: "raliiev%mozilla.com" Date: Wed, 26 Nov 2014 16:24:25 +0000 Subject: [PATCH] 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 --- mozilla/webtools/aus/xml/inc/config-dist.php | 55 ++++++++++++++++++++ mozilla/webtools/aus/xml/index.php | 16 +++--- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/mozilla/webtools/aus/xml/inc/config-dist.php b/mozilla/webtools/aus/xml/inc/config-dist.php index c8e0607d19f..4a6ffdd0309 100644 --- a/mozilla/webtools/aus/xml/inc/config-dist.php +++ b/mozilla/webtools/aus/xml/inc/config-dist.php @@ -75,6 +75,61 @@ define('THROTTLE_LEVEL',100); // Turns logging throttled hits on and off. 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 // override global levels. If it is off, this still works. For example, this // is 10% throttling (only 10% of the time updates are offered): diff --git a/mozilla/webtools/aus/xml/index.php b/mozilla/webtools/aus/xml/index.php index 4bba2846062..fed2ba3e0cc 100644 --- a/mozilla/webtools/aus/xml/index.php +++ b/mozilla/webtools/aus/xml/index.php @@ -112,12 +112,16 @@ if ( (empty($_GET['force']) || $_GET['force']!=1) ) { $aus = new AUS_Object(); // Check explicit throttling. - if ( !$aus->isThrottleException($clean['version'], $clean['channel']) - && isset($productThrottling[$clean['product']][$clean['version']]) - && mt_rand(0,99) >= $productThrottling[$clean['product']][$clean['version']] - ) { - $throttleMe = true; - + if ( !$aus->isThrottleException($clean['version'], $clean['channel']) ) { + // check if locale based throttling is set. Do not use product based throttling if set + if ( isset($localeThrottling[$clean['product']][$clean['version']][$clean['locale']]) ) { + if ( mt_rand(0,99) >= $localeThrottling[$clean['product']][$clean['version']][$clean['locale']] ){ + $throttleMe = true; + } + } elseif ( isset($productThrottling[$clean['product']][$clean['version']]) + && mt_rand(0,99) >= $productThrottling[$clean['product']][$clean['version']] ) { + $throttleMe = true; + } // Check global throttling. } elseif ( defined('THROTTLE_GLOBAL') && THROTTLE_GLOBAL && defined('THROTTLE_LEVEL') &&