incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
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 GMT
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 + "<br/><br/>" );
+	document.write( "Regular download goes to: " + mirrorHost + "<br/>" );
 
 	// 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 + "<br/><br/>" );
+	document.write( "Regular download goes to: " + mirrorHost + "<br/>" );
+
+	// 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 + "<br/><br/>"
);
+	}
+
+	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              + "<br/>" );
+	document.write( "SF is active: "   + MIRROR_SF_ACTIVE               + "<br/>" );
+	document.write( "MB is active: "   + MIRROR_MB_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 + " ");
+	document.write( "with threshold: " + ( MIRROR_MB_WEIGHT / weight )  + "<br/>" );
+	document.write( "SF weight: "      + MIRROR_SF_WEIGHT + " ");
+	document.write( "with threshold: " + ( MIRROR_SF_WEIGHT / weight )  + "<br/>" );
+	document.write( "Total weight: "   + weight                         + "<br/>" );
+	document.write( "Random value: "   + randVal                        + "<br/>" );
+	document.write( "<br/>" );
+
+	// 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 + "<br/>" );
 
 	// 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 @@
   <script type="text/javascript">
   <!--
   document.write ( "<h2>This page is to test how to get download requests to more than
one mirror hosts:</h2>" );
-  document.write ( "<h3>1. Mirror hosts are: Apache, SourceForge</h3>" );
+  document.write ( "<h3>1. Mirror redirection by percent: Apache, SourceForge</h3>"
);
 
   getMirrorHost();
 
-  document.write ( "<h3>2. Mirror hosts are: Apache, SourceForge, MirrorBrain</h3>"
);
+  document.write ( "<h3>2. Mirror redirection by percent: Apache, SourceForge, MirrorBrain</h3>"
);
 
-  getMirrorHost_asf_sf_mb();
+  getMirrorHost_asf_sf_mb_percent();
+
+  document.write ( "<h3>3. Mirror redirection by weight: Apache, SourceForge, MirrorBrain</h3>"
);
+
+  getMirrorHost_asf_sf_mb_weighted();
 
   //-->
   </script>



Mime
View raw message