You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vi...@apache.org on 2012/06/07 04:15:41 UTC
svn commit: r1347301 - in /incubator/ambari/branches/ambari-186: ./ hmc/
hmc/html/ hmc/package/rpm/ hmc/package/rpm/SPECS/
Author: vikram
Date: Thu Jun 7 02:15:40 2012
New Revision: 1347301
URL: http://svn.apache.org/viewvc?rev=1347301&view=rev
Log:
AMBARI-480. Reduce Page Load Time By Combining HMC JS Files (Contributed by Varun)
Added:
incubator/ambari/branches/ambari-186/hmc/fileCombinator.php
Removed:
incubator/ambari/branches/ambari-186/hmc/yuiCombinator.php
Modified:
incubator/ambari/branches/ambari-186/CHANGES.txt
incubator/ambari/branches/ambari-186/hmc/html/addNodesWizard.php
incubator/ambari/branches/ambari-186/hmc/html/bootstrapJs.htmli
incubator/ambari/branches/ambari-186/hmc/html/index.php
incubator/ambari/branches/ambari-186/hmc/html/initializeCluster.php
incubator/ambari/branches/ambari-186/hmc/html/manageServices.php
incubator/ambari/branches/ambari-186/hmc/html/showDeployProgress.php
incubator/ambari/branches/ambari-186/hmc/html/showManageServicesProgress.php
incubator/ambari/branches/ambari-186/hmc/html/showUninstallProgress.php
incubator/ambari/branches/ambari-186/hmc/html/uninstallWizard.php
incubator/ambari/branches/ambari-186/hmc/package/rpm/SPECS/hmc.spec
incubator/ambari/branches/ambari-186/hmc/package/rpm/create_hmc_rpm.sh
Modified: incubator/ambari/branches/ambari-186/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/CHANGES.txt?rev=1347301&r1=1347300&r2=1347301&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/CHANGES.txt (original)
+++ incubator/ambari/branches/ambari-186/CHANGES.txt Thu Jun 7 02:15:40 2012
@@ -6,6 +6,8 @@ characters wide.
Release 0.1.x - unreleased
+ AMBARI-480. Reduce Page Load Time By Combining HMC JS Files (Varun via Vikram)
+
AMBARI-479. Add nodes after install does not allow re-bootstrap if user closes browser after bootstrap and before starting services (Vikram)
AMBARI-477. Spec file for using installer with php-5.3 (Hitesh via Vikram)
Added: incubator/ambari/branches/ambari-186/hmc/fileCombinator.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/fileCombinator.php?rev=1347301&view=auto
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/fileCombinator.php (added)
+++ incubator/ambari/branches/ambari-186/hmc/fileCombinator.php Thu Jun 7 02:15:40 2012
@@ -0,0 +1,52 @@
+<?php
+
+function deduceContentType ($fileToLoad)
+{
+ $contentType = '';
+
+ $fileExtension = pathinfo($fileToLoad, PATHINFO_EXTENSION);
+
+ if ($fileExtension == 'css')
+ {
+ $contentType = 'text/css';
+ }
+ elseif ($fileExtension == 'js' )
+ {
+ $contentType = 'application/js';
+ }
+
+ return $contentType;
+}
+
+/* main() */
+$filesToLoad = explode('&', $_SERVER['QUERY_STRING']);
+
+$contentType = '';
+$responseBody = '';
+
+foreach ($filesToLoad as $fileToLoad)
+{
+ /* Assumes a request has only homogenous file types, which holds true for
+ * the combined requests YUI makes.
+ */
+ if (empty($contentType))
+ {
+ $contentType = deduceContentType($fileToLoad);
+ }
+
+ $fileContents = file_get_contents('./' . $fileToLoad);
+
+ if ($fileContents)
+ {
+ $responseBody .= $fileContents;
+ }
+}
+
+header('Content-type: ' . $contentType);
+/* TODO XXX Add appropriate Cache-Control/Age/Last-Modified/Expires headers
+ * here to be super-efficient.
+ */
+
+echo $responseBody;
+
+?>
Modified: incubator/ambari/branches/ambari-186/hmc/html/addNodesWizard.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/html/addNodesWizard.php?rev=1347301&r1=1347300&r2=1347301&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/html/addNodesWizard.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/html/addNodesWizard.php Thu Jun 7 02:15:40 2012
@@ -126,13 +126,13 @@
};
var jsFilesToLoad = [
- '../js/utils.js',
- '../js/txnUtils.js',
- '../js/addNodes.js',
- '../js/addNodesProgress.js',
- '../js/selectComponents.js',
- '../js/deployAddedNodesProgress.js',
- '../js/addNodesWizardInit.js'
+ 'js/utils.js',
+ 'js/txnUtils.js',
+ 'js/addNodes.js',
+ 'js/addNodesProgress.js',
+ 'js/selectComponents.js',
+ 'js/deployAddedNodesProgress.js',
+ 'js/addNodesWizardInit.js'
];
</script>
Modified: incubator/ambari/branches/ambari-186/hmc/html/bootstrapJs.htmli
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/html/bootstrapJs.htmli?rev=1347301&r1=1347300&r2=1347301&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/html/bootstrapJs.htmli (original)
+++ incubator/ambari/branches/ambari-186/hmc/html/bootstrapJs.htmli Thu Jun 7 02:15:40 2012
@@ -2,25 +2,9 @@
<script type="text/javascript">
- /* Loads the next file from the global jsFilesToLoad array (destroying it
- * in the process).
- */
- function loadNextJsFile() {
-
- if( jsFilesToLoad.length > 0 ) {
-
- var dynamicJsScript = document.createElement("script");
- dynamicJsScript.type = "text/javascript";
- dynamicJsScript.src = jsFilesToLoad.shift();
- globalYui.log('Loading ' + dynamicJsScript.src);
- dynamicJsScript.onload = loadNextJsFile;
- document.getElementsByTagName("head")[0].appendChild(dynamicJsScript);
- }
- }
-
var globalYuiLoaderOptions = {
combine: true,
- comboBase: '../yuiCombinator.php?',
+ comboBase: '../fileCombinator.php?',
root: 'yui-3.5.1/build/'
};
@@ -30,8 +14,12 @@
"datasource-polling", "stylesheet", "dd-drop", "dd-constrain",
"dd-proxy", "transition", "overlay", "node-event-simulate", function (Y) {
- /* Kick off the sequential loading. */
- loadNextJsFile();
+ /* Load all the files in jsFilesToLoad in one shot. */
+ var dynamicJsScript = document.createElement("script");
+ dynamicJsScript.type = "text/javascript";
+ dynamicJsScript.src = '../fileCombinator.php?' + jsFilesToLoad.join('&');
+ globalYui.log('Loading ' + dynamicJsScript.src);
+ document.getElementsByTagName("head")[0].appendChild(dynamicJsScript);
});
</script>
Modified: incubator/ambari/branches/ambari-186/hmc/html/index.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/html/index.php?rev=1347301&r1=1347300&r2=1347301&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/html/index.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/html/index.php Thu Jun 7 02:15:40 2012
@@ -38,8 +38,8 @@
<script type="text/javascript">
var jsFilesToLoad = [
- '../js/utils.js',
- '../js/clustersList.js'
+ 'js/utils.js',
+ 'js/clustersList.js'
];
</script>
Modified: incubator/ambari/branches/ambari-186/hmc/html/initializeCluster.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/html/initializeCluster.php?rev=1347301&r1=1347300&r2=1347301&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/html/initializeCluster.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/html/initializeCluster.php Thu Jun 7 02:15:40 2012
@@ -309,21 +309,21 @@
};
var jsFilesToLoad = [
- '../js/ext/jquery.min.js',
- '../js/ext/bootstrap.min.js',
- '../js/utils.js',
- '../js/txnUtils.js',
- '../js/installationWizard.js',
- '../js/createCluster.js',
- '../js/addNodes.js',
- '../js/addNodesProgress.js',
- '../js/selectServices.js',
- '../js/assignMasters.js',
- '../js/configureCluster.js',
- '../js/configureServicesUtils.js',
- '../js/configureServices.js',
- '../js/reviewAndDeploy.js',
- '../js/deployProgress.js'
+ 'js/ext/jquery.min.js',
+ 'js/ext/bootstrap.min.js',
+ 'js/utils.js',
+ 'js/txnUtils.js',
+ 'js/installationWizard.js',
+ 'js/createCluster.js',
+ 'js/addNodes.js',
+ 'js/addNodesProgress.js',
+ 'js/selectServices.js',
+ 'js/assignMasters.js',
+ 'js/configureCluster.js',
+ 'js/configureServicesUtils.js',
+ 'js/configureServices.js',
+ 'js/reviewAndDeploy.js',
+ 'js/deployProgress.js'
];
</script>
Modified: incubator/ambari/branches/ambari-186/hmc/html/manageServices.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/html/manageServices.php?rev=1347301&r1=1347300&r2=1347301&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/html/manageServices.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/html/manageServices.php Thu Jun 7 02:15:40 2012
@@ -97,11 +97,11 @@
var clusterName = '<?php echo $_GET['clusterName']; ?>';
var jsFilesToLoad = [
- '../js/utils.js',
- '../js/txnUtils.js',
- '../js/configureServicesUtils.js',
- '../js/manageServices.js',
- '../js/manageServicesProgress.js'
+ 'js/utils.js',
+ 'js/txnUtils.js',
+ 'js/configureServicesUtils.js',
+ 'js/manageServices.js',
+ 'js/manageServicesProgress.js'
];
</script>
Modified: incubator/ambari/branches/ambari-186/hmc/html/showDeployProgress.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/html/showDeployProgress.php?rev=1347301&r1=1347300&r2=1347301&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/html/showDeployProgress.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/html/showDeployProgress.php Thu Jun 7 02:15:40 2012
@@ -32,10 +32,10 @@
var clusterName = '<?php echo $clusterName; ?>';
var jsFilesToLoad = [
- '../js/utils.js',
- '../js/txnUtils.js',
- '../js/deployProgress.js',
- '../js/showDeployProgress.js'
+ 'js/utils.js',
+ 'js/txnUtils.js',
+ 'js/deployProgress.js',
+ 'js/showDeployProgress.js'
];
</script>
Modified: incubator/ambari/branches/ambari-186/hmc/html/showManageServicesProgress.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/html/showManageServicesProgress.php?rev=1347301&r1=1347300&r2=1347301&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/html/showManageServicesProgress.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/html/showManageServicesProgress.php Thu Jun 7 02:15:40 2012
@@ -32,10 +32,10 @@
var clusterName = '<?php echo $clusterName; ?>';
var jsFilesToLoad = [
- '../js/utils.js',
- '../js/txnUtils.js',
- '../js/manageServicesProgress.js',
- '../js/showManageServicesProgress.js'
+ 'js/utils.js',
+ 'js/txnUtils.js',
+ 'js/manageServicesProgress.js',
+ 'js/showManageServicesProgress.js'
];
</script>
Modified: incubator/ambari/branches/ambari-186/hmc/html/showUninstallProgress.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/html/showUninstallProgress.php?rev=1347301&r1=1347300&r2=1347301&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/html/showUninstallProgress.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/html/showUninstallProgress.php Thu Jun 7 02:15:40 2012
@@ -32,10 +32,10 @@
var clusterName = '<?php echo $clusterName; ?>';
var jsFilesToLoad = [
- '../js/utils.js',
- '../js/txnUtils.js',
- '../js/uninstallProgress.js',
- '../js/showUninstallProgress.js'
+ 'js/utils.js',
+ 'js/txnUtils.js',
+ 'js/uninstallProgress.js',
+ 'js/showUninstallProgress.js'
];
</script>
Modified: incubator/ambari/branches/ambari-186/hmc/html/uninstallWizard.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/html/uninstallWizard.php?rev=1347301&r1=1347300&r2=1347301&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/html/uninstallWizard.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/html/uninstallWizard.php Thu Jun 7 02:15:40 2012
@@ -82,10 +82,10 @@
};
var jsFilesToLoad = [
- '../js/utils.js',
- '../js/txnUtils.js',
- '../js/uninstall.js',
- '../js/uninstallProgress.js',
+ 'js/utils.js',
+ 'js/txnUtils.js',
+ 'js/uninstall.js',
+ 'js/uninstallProgress.js',
];
</script>
Modified: incubator/ambari/branches/ambari-186/hmc/package/rpm/SPECS/hmc.spec
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/package/rpm/SPECS/hmc.spec?rev=1347301&r1=1347300&r2=1347301&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/package/rpm/SPECS/hmc.spec (original)
+++ incubator/ambari/branches/ambari-186/hmc/package/rpm/SPECS/hmc.spec Thu Jun 7 02:15:40 2012
@@ -101,7 +101,7 @@ fi
%__cp -rf puppet $RPM_BUILD_ROOT/%{web_prefixdir}/
%__cp -rf php $RPM_BUILD_ROOT/%{web_prefixdir}/
%__cp -rf yui-3.5.1 $RPM_BUILD_ROOT/%{web_prefixdir}/
-%__cp -f yuiCombinator.php $RPM_BUILD_ROOT/%{web_prefixdir}/
+%__cp -f fileCombinator.php $RPM_BUILD_ROOT/%{web_prefixdir}/
%__cp -rf conf $RPM_BUILD_ROOT/%{web_prefixdir}/
%__cp -rf puppet/manifestloader $RPM_BUILD_ROOT/%{puppet_master_dir}
%__cp -rf puppet/modules $RPM_BUILD_ROOT/%{puppet_master_dir}
Modified: incubator/ambari/branches/ambari-186/hmc/package/rpm/create_hmc_rpm.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/package/rpm/create_hmc_rpm.sh?rev=1347301&r1=1347300&r2=1347301&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/package/rpm/create_hmc_rpm.sh (original)
+++ incubator/ambari/branches/ambari-186/hmc/package/rpm/create_hmc_rpm.sh Thu Jun 7 02:15:40 2012
@@ -55,7 +55,7 @@ cp -rf ${BASEDIR}/../../php ${HMC_DIR}
cp -rf ${BASEDIR}/../../yui-3.5.1 ${HMC_DIR}
cp -rf ${BASEDIR}/../../conf ${HMC_DIR}
cp -rf ${BASEDIR}/../../fonts ${HMC_DIR}
-cp -f ${BASEDIR}/../../yuiCombinator.php ${HMC_DIR}
+cp -f ${BASEDIR}/../../fileCombinator.php ${HMC_DIR}
TAR_DEST="${BUILD_DIR}/${PKG_NAME}-$VERSION.tar.gz"
cd ${BUILD_DIR};