Return-Path: X-Original-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CA7B098FE for ; Sat, 7 Apr 2012 19:30:25 +0000 (UTC) Received: (qmail 75527 invoked by uid 500); 7 Apr 2012 19:30:25 -0000 Delivered-To: apmail-incubator-ooo-commits-archive@incubator.apache.org Received: (qmail 75490 invoked by uid 500); 7 Apr 2012 19:30:25 -0000 Mailing-List: contact ooo-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ooo-dev@incubator.apache.org Delivered-To: mailing list ooo-commits@incubator.apache.org Received: (qmail 75482 invoked by uid 99); 7 Apr 2012 19:30:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Apr 2012 19:30:25 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Apr 2012 19:30:24 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id EF57D23888FE; Sat, 7 Apr 2012 19:30:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1310832 - in /incubator/ooo/ooo-site/trunk/content/download/test: download_new_dl.js globalvars_new_dl.js index_new_dl.html Date: Sat, 07 Apr 2012 19:30:03 -0000 To: ooo-commits@incubator.apache.org From: marcus@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120407193003.EF57D23888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: marcus Date: Sat Apr 7 19:30:03 2012 New Revision: 1310832 URL: http://svn.apache.org/viewvc?rev=1310832&view=rev Log: New case with weighted values for mirror redirection Modified: incubator/ooo/ooo-site/trunk/content/download/test/download_new_dl.js incubator/ooo/ooo-site/trunk/content/download/test/globalvars_new_dl.js incubator/ooo/ooo-site/trunk/content/download/test/index_new_dl.html Modified: incubator/ooo/ooo-site/trunk/content/download/test/download_new_dl.js URL: http://svn.apache.org/viewvc/incubator/ooo/ooo-site/trunk/content/download/test/download_new_dl.js?rev=1310832&r1=1310831&r2=1310832&view=diff ============================================================================== --- incubator/ooo/ooo-site/trunk/content/download/test/download_new_dl.js (original) +++ incubator/ooo/ooo-site/trunk/content/download/test/download_new_dl.js Sat Apr 7 19:30:03 2012 @@ -28,7 +28,7 @@ function getMirrorHost() { } } - document.write( "Regular download goes to: " + mirrorHost + "

" ); + document.write( "Regular download goes to: " + mirrorHost + "
" ); // Defining fall back mirror host if ( mirrorHost == "" ) { @@ -51,7 +51,7 @@ function getMirrorHost() { return mirrorHost; } -function getMirrorHost_asf_sf_mb() { +function getMirrorHost_asf_sf_mb_percent() { var mirrorHost = ""; var randVal = ( Math.random() * 100 ); var MIRROR_RATIO = MIRROR_RATIO_2; @@ -77,14 +77,83 @@ function getMirrorHost_asf_sf_mb() { } } - // Are Mirrorbrain mirrors working? + // Are MirrorBrain mirrors working? if ( MIRROR_MB_ACTIVE > 0 ) { // If random value is higher than ratio * 2 if ( randVal > ( MIRROR_RATIO * 2 ) ) { mirrorHost = "MirrorBrain"; } } - document.write( "Regular download goes to: " + mirrorHost + "

" ); + document.write( "Regular download goes to: " + mirrorHost + "
" ); + + // Defining fall back mirror host + if ( mirrorHost == "" ) { + // Are Apache mirrors working? + if ( MIRROR_ASF_ACTIVE > 0 ) { + mirrorHost = "Apache"; + + // Else are SourceForge mirrors working? + } else if ( MIRROR_SF_ACTIVE > 0 ) { + mirrorHost = "SourceForge"; + + // Else are MirrorBrain mirrors working? + } else if ( MIRROR_MB_ACTIVE > 0 ) { + mirrorHost = "MirrorBrain"; + + // None is working, we have a problem + } else { + mirrorHost = "None, what to do?"; + } + + document.write( "Fall back download goes to: " + mirrorHost + "

" ); + } + + return mirrorHost; +} + +function getMirrorHost_asf_sf_mb_weighted() { + var mirrorHost = ""; + var weight = MIRROR_ASF_WEIGHT + MIRROR_MB_WEIGHT + MIRROR_SF_WEIGHT; + var randVal = Math.random(); + + document.write( "ASF is active: " + MIRROR_ASF_ACTIVE + "
" ); + document.write( "SF is active: " + MIRROR_SF_ACTIVE + "
" ); + document.write( "MB is active: " + MIRROR_MB_ACTIVE + "
" ); + document.write( "ASF weight: " + MIRROR_ASF_WEIGHT + " "); + document.write( "with threshold: " + ( MIRROR_ASF_WEIGHT / weight ) + "
" ); + document.write( "MB weight: " + MIRROR_MB_WEIGHT + " "); + document.write( "with threshold: " + ( MIRROR_MB_WEIGHT / weight ) + "
" ); + document.write( "SF weight: " + MIRROR_SF_WEIGHT + " "); + document.write( "with threshold: " + ( MIRROR_SF_WEIGHT / weight ) + "
" ); + document.write( "Total weight: " + weight + "
" ); + document.write( "Random value: " + randVal + "
" ); + document.write( "
" ); + + // Are Apache mirrors working? + if ( MIRROR_ASF_ACTIVE > 0 ) { + // If random value is lower than ASF weight divided by total weight + if ( randVal < ( MIRROR_ASF_WEIGHT / weight ) ) { + mirrorHost = "Apache"; + } + } + + // Are MirrorBrain mirrors working? + if ( MIRROR_MB_ACTIVE > 0 ) { + // If random value is lower than SF weight divided by the total weight + // and higher than ASF weight divided by the total weight + if ( randVal < ( MIRROR_SF_WEIGHT / weight ) && ( randVal > ( MIRROR_ASF_WEIGHT / weight ) )) { + mirrorHost = "MirrorBrain"; + } + } + + // Are SourceForge mirrors working? + if ( MIRROR_SF_ACTIVE > 0 ) { + // If random value is higher than MB weight divided by total weight + if ( randVal > ( MIRROR_MB_WEIGHT / weight ) ) { + mirrorHost = "SourceForge"; + } + } + document.write( "Regular download goes to: " + mirrorHost + "
" ); // Defining fall back mirror host if ( mirrorHost == "" ) { Modified: incubator/ooo/ooo-site/trunk/content/download/test/globalvars_new_dl.js URL: http://svn.apache.org/viewvc/incubator/ooo/ooo-site/trunk/content/download/test/globalvars_new_dl.js?rev=1310832&r1=1310831&r2=1310832&view=diff ============================================================================== --- incubator/ooo/ooo-site/trunk/content/download/test/globalvars_new_dl.js (original) +++ incubator/ooo/ooo-site/trunk/content/download/test/globalvars_new_dl.js Sat Apr 7 19:30:03 2012 @@ -15,11 +15,14 @@ // The supported mirror hosts, 0 means not ready to receive load // The mirror ratio in percent -var MIRROR_ASF_ACTIVE = 0; +var MIRROR_ASF_ACTIVE = 1; var MIRROR_SF_ACTIVE = 1; var MIRROR_MB_ACTIVE = 1; var MIRROR_RATIO_1 = 75; var MIRROR_RATIO_2 = 33; +var MIRROR_ASF_WEIGHT = 1; +var MIRROR_MB_WEIGHT = 2; +var MIRROR_SF_WEIGHT = 3; // Exchange the variables resp. its content to switch the MirrorBrain server var MIRROR_BOUNCER_URL = "http://openoffice.bouncer.osuosl.org/"; Modified: incubator/ooo/ooo-site/trunk/content/download/test/index_new_dl.html URL: http://svn.apache.org/viewvc/incubator/ooo/ooo-site/trunk/content/download/test/index_new_dl.html?rev=1310832&r1=1310831&r2=1310832&view=diff ============================================================================== --- incubator/ooo/ooo-site/trunk/content/download/test/index_new_dl.html (original) +++ incubator/ooo/ooo-site/trunk/content/download/test/index_new_dl.html Sat Apr 7 19:30:03 2012 @@ -14,13 +14,17 @@