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/05 23:30:46 UTC
svn commit: r1346602 - in /incubator/ambari/branches/ambari-186: CHANGES.txt
hmc/html/showDeployProgress.php hmc/js/deployProgress.js
hmc/js/showDeployProgress.js hmc/php/frontend/deploy.php
Author: vikram
Date: Tue Jun 5 21:30:46 2012
New Revision: 1346602
URL: http://svn.apache.org/viewvc?rev=1346602&view=rev
Log:
AMBARI-330. Provide a way to resume if browser crashes/is closed during the deploy-in-progress (Contributed by Varun)
Added:
incubator/ambari/branches/ambari-186/hmc/html/showDeployProgress.php
incubator/ambari/branches/ambari-186/hmc/js/showDeployProgress.js
Modified:
incubator/ambari/branches/ambari-186/CHANGES.txt
incubator/ambari/branches/ambari-186/hmc/js/deployProgress.js
incubator/ambari/branches/ambari-186/hmc/php/frontend/deploy.php
Modified: incubator/ambari/branches/ambari-186/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/CHANGES.txt?rev=1346602&r1=1346601&r2=1346602&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/CHANGES.txt (original)
+++ incubator/ambari/branches/ambari-186/CHANGES.txt Tue Jun 5 21:30:46 2012
@@ -6,6 +6,8 @@ characters wide.
Release 0.1.x - unreleased
+ AMBARI-330. Provide a way to resume if browser crashes/is closed during the deploy-in-progress (Varun via Vikram)
+
AMBARI-320. Reconfiguring a stopped service starts it incorrectly (Hitesh via Vikram)
AMBARI-340. Info logs for PuppetInvoker (Jitendra via Vikram)
Added: 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=1346602&view=auto
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/html/showDeployProgress.php (added)
+++ incubator/ambari/branches/ambari-186/hmc/html/showDeployProgress.php Tue Jun 5 21:30:46 2012
@@ -0,0 +1,45 @@
+<?php require_once "./head.inc" ?>
+<html>
+ <head>
+ <title id="pageTitleId"><?php echo $RES['page.title'] ?></title>
+
+ <!-- CSS -->
+ <link type="text/css" rel="stylesheet" href="../yui-3.5.1/build/cssreset/cssreset-min.css">
+ <link type="text/css" rel="stylesheet" href="../css/bootstrap.css" media="screen"/>
+ <link type="text/css" rel="stylesheet" href="../css/common.css" media="screen"/>
+ <link type="text/css" rel="stylesheet" href="../css/common2.css" media="screen"/>
+ <link type="text/css" rel="stylesheet" href="../css/common3.css" media="screen"/>
+ <link rel="shortcut icon" href="../images/logo-micro.gif">
+ <!-- End CSS -->
+ </head>
+
+ <body class="yui3-skin-sam">
+ <?php require "./topnav.htmli"; ?>
+
+ <div id="contentDivId">
+
+ <?php require "./utils.htmli"; ?>
+ <?php require "./txnUtils.htmli"; ?>
+
+ </div>
+ <!-- End of contentDivId -->
+
+ <?php require "./footer.htmli"; ?>
+
+ <!-- Javascript Scaffolding -->
+ <script type="text/javascript">
+ /* Minimal data required to bootstrap clusters.js. */
+ var clusterName = '<?php echo $_GET['clusterName']; ?>';
+
+ var jsFilesToLoad = [
+ '../js/utils.js',
+ '../js/txnUtils.js',
+ '../js/deployProgress.js',
+ '../js/showDeployProgress.js'
+ ];
+ </script>
+
+ <?php require "./bootstrapJs.htmli"; ?>
+ <!-- End of Javascript Scaffolding -->
+ </body>
+</html>
Modified: incubator/ambari/branches/ambari-186/hmc/js/deployProgress.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/js/deployProgress.js?rev=1346602&r1=1346601&r2=1346602&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/js/deployProgress.js (original)
+++ incubator/ambari/branches/ambari-186/hmc/js/deployProgress.js Tue Jun 5 21:30:46 2012
@@ -68,7 +68,15 @@ function renderDeployProgress (deployPro
* and have asked for a deploy, so there's no going back - remove
* all traces of #installationWizardProgressBarDivId.
*/
- globalYui.one('#installationWizardProgressBarDivId').setStyle('display', 'none');
+ var installationWizardProgressBarDiv = globalYui.one('#installationWizardProgressBarDivId');
+
+ /* But be safe and perform this removal only if #installationWizardProgressBarDivId
+ * actually exists on the page - this .js file is now being used in more
+ * than one place, so this robustness is needed.
+ */
+ if (installationWizardProgressBarDiv) {
+ installationWizardProgressBarDiv.setStyle('display', 'none')
+ }
var hmcRestartMsg = '';
if (deployProgressInfo.nagiosGangliaCoHosted != null
Added: incubator/ambari/branches/ambari-186/hmc/js/showDeployProgress.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/js/showDeployProgress.js?rev=1346602&view=auto
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/js/showDeployProgress.js (added)
+++ incubator/ambari/branches/ambari-186/hmc/js/showDeployProgress.js Tue Jun 5 21:30:46 2012
@@ -0,0 +1,2 @@
+/* Main() */
+executeStage( '../php/frontend/deploy.php?clusterName=' + clusterName, renderDeployProgress );
Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/deploy.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/deploy.php?rev=1346602&r1=1346601&r2=1346602&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/deploy.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/deploy.php Tue Jun 5 21:30:46 2012
@@ -9,6 +9,7 @@ include_once "../orchestrator/HMC.php";
include_once "../db/OrchestratorDB.php";
include_once "../puppet/DBReader.php";
include_once "../puppet/PuppetInvoker.php";
+include_once "../util/clusterState.php";
$dbPath = $GLOBALS["DB_PATH"];
$clusterName = $_GET['clusterName'];
@@ -16,23 +17,69 @@ $clusterName = $_GET['clusterName'];
$startTime = time();
$hmc = new HMC($dbPath, $clusterName);
-$result = $hmc->deployHDP();
-if ($result["result"] != 0) {
- print json_encode($result);
+/* For returning in our JSON at the very end. */
+$result = 0;
+$error = "";
+
+$txnId = -1;
+
+$dbAccessor = new HMCDBAccessor($dbPath);
+$clusterStateResponse = $dbAccessor->getClusterState($clusterName);
+
+if ($clusterStateResponse['result'] != 0) {
+ print json_encode($clusterStateResponse);
return;
}
-if (!isset($result["txnId"])) {
- print json_encode ( array("result" => 1, "error" => "Could not obtain txn info for triggered command"));
- return;
+$clusterState = json_decode($clusterStateResponse['state'], true);
+
+/* Run an actual deploy only if this cluster has passed the stage of
+ * configuring its services (which means the next thing to do is to
+ * kick off the deploy).
+ */
+if (($clusterState['state'] == 'CONFIGURATION_IN_PROGRESS') &&
+ ($clusterState['context']['stage'] == 'CONFIGURE_SERVICES')) {
+
+ $deployResult = $hmc->deployHDP();
+ if ($deployResult["result"] != 0) {
+ print json_encode($deployResult);
+ return;
+ }
+
+ if (!isset($deployResult["txnId"])) {
+ print json_encode ( array("result" => 1, "error" => "Could not obtain txn info for triggered command"));
+ return;
+ }
+
+ $txnId = $deployResult["txnId"];
+
+ /* (And when we kick off the deploy is the only time to update the state of the cluster) */
+ $state = "DEPLOYMENT_IN_PROGRESS";
+ $displayName = "Deployment in progress";
+ $context = array (
+ 'txnId' => $txnId
+ );
+
+ $retval = updateClusterState($clusterName, $state, $displayName, $context);
+ if ($retval['result'] != 0) {
+ $result = $retval['result'];
+ $error = $retval['error'];
+ }
}
+/* In case the deploy is already running or has ended, just return the txnId
+ * from the DB instead of kicking off a fresh deploy - this is so we can use
+ * this entrypoint to show the cluster's deploy progress at any time in the
+ * future, not just during a live deploy.
+ */
+elseif (($clusterState['state'] == 'DEPLOYMENT_IN_PROGRESS') ||
+ ($clusterState['state'] == 'DEPLOYED')) {
-$txnId = $result["txnId"];
+ $txnId = $clusterState['context']['txnId'];
+}
$thisHostName = trim(strtolower(exec('hostname -f')));
$nagiosGangliaCoHosted = FALSE;
-$dbAccessor = new HMCDBAccessor($dbPath);
// check if nagios hosted on same server
if (!$nagiosGangliaCoHosted) {
@@ -63,6 +110,6 @@ $jsonOutput = array(
/* ...and spit it out. */
header("Content-type: application/json");
-print (json_encode(array("result" => 0, "error" => 0, "response" => $jsonOutput)));
+print (json_encode(array("result" => $result, "error" => $error, "response" => $jsonOutput)));
?>