incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r1310936 - in /incubator/ooo/ooo-site/trunk/content/download/test: download_new_dl.js globalvars_new_dl.js
Date Sun, 08 Apr 2012 01:55:56 GMT
Author: marcus
Date: Sun Apr  8 01:55:56 2012
New Revision: 1310936

URL: http://svn.apache.org/viewvc?rev=1310936&view=rev
Log:
New 3rd 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

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=1310936&r1=1310935&r2=1310936&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 Sun Apr  8 01:55:56
2012
@@ -35,25 +35,28 @@ function getMirrorHost() {
 		// Are Apache mirrors working?
 		if ( MIRROR_ASF_ACTIVE > 0 ) {
 			mirrorHost = "Apache";
+		}
 
 		// Else are SourceForge mirrors working?
-		} else if ( MIRROR_SF_ACTIVE > 0 ) {
+		else if ( MIRROR_SF_ACTIVE > 0 ) {
 			mirrorHost = "SourceForge";
+		}
 
 		// None is working, we have a problem
-		} else {
+		else {
 			mirrorHost = "No mirror host active, what to do?";
 		}
 
-		document.write( "Fall back download goes to: " + mirrorHost + "<br/><br/>"
);
+		document.write( "Fall back download goes to: " + mirrorHost + "<br/>" );
+		document.write( "<br/>" );
 	}
 
 	return mirrorHost;
 }
 
 function getMirrorHost_asf_sf_mb_percent() {
-	var mirrorHost = "";
-	var randVal    = ( Math.random() * 100 );
+	var mirrorHost   = "";
+	var randVal      = ( Math.random() * 100 );
 	var MIRROR_RATIO = MIRROR_RATIO_2;
 
 	document.write( "ASF is active: " + MIRROR_ASF_ACTIVE + "<br/>" );
@@ -84,6 +87,7 @@ function getMirrorHost_asf_sf_mb_percent
 			mirrorHost = "MirrorBrain";
 		}
 	}
+
 	document.write( "Regular download goes to: " + mirrorHost + "<br/>" );
 
 	// Defining fall back mirror host
@@ -91,34 +95,96 @@ function getMirrorHost_asf_sf_mb_percent
 		// Are Apache mirrors working?
 		if ( MIRROR_ASF_ACTIVE > 0 ) {
 			mirrorHost = "Apache";
+		}
 
 		// Else are SourceForge mirrors working?
-		} else if ( MIRROR_SF_ACTIVE > 0 ) {
+		else if ( MIRROR_SF_ACTIVE > 0 ) {
 			mirrorHost = "SourceForge";
+		}
 
 		// Else are MirrorBrain mirrors working?
-		} else if ( MIRROR_MB_ACTIVE > 0 ) {
+		else if ( MIRROR_MB_ACTIVE > 0 ) {
 			mirrorHost = "MirrorBrain";
+		}
 
 		// None is working, we have a problem
-		} else {
+		else {
 			mirrorHost = "None, what to do?";
 		}
 
-		document.write( "Fall back download goes to: " + mirrorHost + "<br/><br/>"
);
+		document.write( "Fall back download goes to: " + mirrorHost + "<br/>" );
+		document.write( "<br/>" );
 	}
 
 	return mirrorHost;
 }
 
 function getMirrorHost_asf_sf_mb_weighted() {
+	var mirrorHost    = "";
+	// get total weight of the weight array (here it is 6)
+	var weight        = eval( MIRROR_HOSTS_WEIGHT.join( "+" ) );
+	// multiply the random numbe with the total weight and round it down
+	var randVal       = Math.floor ( Math.random() * weight );
+	// Assign the random position of the weighted array
+	var mirrorHost = MIRROR_HOSTS_WEIGHTED [ randVal ];
+
+	document.write( "ASF is active: " + MIRROR_ASF_ACTIVE        + "<br/>" );
+	document.write( "MB is active: "  + MIRROR_MB_ACTIVE         + "<br/>" );
+	document.write( "SF is active: "  + MIRROR_SF_ACTIVE         + "<br/>" );
+	document.write( "ASF weight: "    + MIRROR_HOSTS_WEIGHT[ 0 ] + "<br/>" );
+	document.write( "MB weight: "     + MIRROR_HOSTS_WEIGHT[ 1 ] + "<br/>" );
+	document.write( "SF weight: "     + MIRROR_HOSTS_WEIGHT[ 2 ] + "<br/>" );
+	document.write( "Total weight: "  + weight                   + "<br/>" );
+	document.write( "Random value: "  + randVal                  + "<br/>" );
+	document.write( "<br/>" );
+
+	document.write( "Regular download goes to: " + mirrorHost + "<br/>" );
+
+	// Defining fall back mirror host
+
+	// Is Apache down?
+	if ( ( MIRROR_ASF_ACTIVE < 1 ) && ( mirrorHost == "Apache" ) )
+		mirrorHost = "MirrorBrain";
+
+	// Is MirrorBrain down?
+	else if ( ( MIRROR_MB_ACTIVE < 1 ) && ( mirrorHost == "MirrorBrain" ) )
+		mirrorHost = "SourceForge";
+
+	// Is SourceForge down?
+	else if ( ( MIRROR_SF_ACTIVE < 1 ) && ( mirrorHost == "SourceForge" ) )
+		mirrorHost = "MirrorBrain";
+
+	// Is Apache and MirrorBrain down?
+	if ( ( MIRROR_ASF_ACTIVE < 1 ) && ( MIRROR_MB_ACTIVE < 1 ) )
+		mirrorHost = "SourceForge";
+
+	// Is Apache and SourceForge down?
+	else if ( ( MIRROR_ASF_ACTIVE < 1 ) && ( MIRROR_SF_ACTIVE < 1 ) )
+		mirrorHost = "MirrorBrain";
+
+	// Is MirrorBrain and SourceForge down?
+	else if ( ( MIRROR_MB_ACTIVE < 1 ) && ( MIRROR_SF_ACTIVE < 1 ) )
+		mirrorHost = "Apache";
+
+	// None is working, we have a problem
+	if ( ( MIRROR_ASF_ACTIVE < 1 ) && ( MIRROR_MB_ACTIVE < 1 )
+	&& ( MIRROR_SF_ACTIVE < 1 ) )
+		mirrorHost = "None, what to do?";
+
+	document.write( "Fall back download goes to: " + mirrorHost + "<br/>" );
+	document.write( "<br/>" );
+
+	return mirrorHost;
+}
+
+function getMirrorHost_asf_sf_mb_weighted2() {
 	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              + "<br/>" );
-	document.write( "SF is active: "   + MIRROR_SF_ACTIVE               + "<br/>" );
 	document.write( "MB is active: "   + MIRROR_MB_ACTIVE               + "<br/>" );
+	document.write( "SF is active: "   + MIRROR_SF_ACTIVE               + "<br/>" );
 	document.write( "ASF weight: "     + MIRROR_ASF_WEIGHT + " ");
 	document.write( "with threshold: " + ( MIRROR_ASF_WEIGHT / weight ) + "<br/>" );
 	document.write( "MB weight: "      + MIRROR_MB_WEIGHT + " ");
@@ -139,9 +205,10 @@ function getMirrorHost_asf_sf_mb_weighte
 
 	// 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 ) )) {
+		// 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_ASF_WEIGHT / weight ) )
+		&& ( randVal < ( MIRROR_SF_WEIGHT / weight ) ) ) {
 			mirrorHost = "MirrorBrain";
 		}
 	}
@@ -153,6 +220,7 @@ function getMirrorHost_asf_sf_mb_weighte
 			mirrorHost = "SourceForge";
 		}
 	}
+
 	document.write( "Regular download goes to: " + mirrorHost + "<br/>" );
 
 	// Defining fall back mirror host
@@ -161,20 +229,21 @@ function getMirrorHost_asf_sf_mb_weighte
 		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";
 
+		// Else are SourceForge mirrors working?
+		} else if ( MIRROR_SF_ACTIVE > 0 ) {
+			mirrorHost = "SourceForge";
+
 		// None is working, we have a problem
 		} else {
 			mirrorHost = "None, what to do?";
 		}
 
-		document.write( "Fall back download goes to: " + mirrorHost + "<br/><br/>"
);
+		document.write( "Fall back download goes to: " + mirrorHost + "<br/>" );
+		document.write( "<br/>" );
 	}
 
 	return 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=1310936&r1=1310935&r2=1310936&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 Sun Apr  8 01:55:56
2012
@@ -15,14 +15,14 @@
 
 // The supported mirror hosts, 0 means not ready to receive load
 // The mirror ratio in percent
-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;
+var MIRROR_ASF_ACTIVE   = 1;
+var MIRROR_SF_ACTIVE    = 0;
+var MIRROR_MB_ACTIVE    = 1;
+var MIRROR_RATIO_1      = 75;
+var MIRROR_RATIO_2      = 33;
+var MIRROR_HOSTS        = [ "Apache", "MirrorBrain", "SourceForge" ];
+var MIRROR_HOSTS_WEIGHT = [ 1, 2, 3 ];
+var MIRROR_HOSTS_WEIGHTED = [ "Apache", "MirrorBrain", "MirrorBrain", "SourceForge", "SourceForge",
"SourceForge" ];
 
 // Exchange the variables resp. its content to switch the MirrorBrain server
 var MIRROR_BOUNCER_URL      = "http://openoffice.bouncer.osuosl.org/";



Mime
View raw message