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 00:29:12 UTC

svn commit: r1347180 - in /incubator/ambari/branches/ambari-186: CHANGES.txt hmc/js/addNodes.js hmc/js/createCluster.js hmc/js/uninstall.js hmc/php/frontend/addNodes.php hmc/php/frontend/nodesAction.php

Author: vikram
Date: Wed Jun  6 22:29:11 2012
New Revision: 1347180

URL: http://svn.apache.org/viewvc?rev=1347180&view=rev
Log:
AMBARI-402. Completing successful add node takes one to initialize cluster page starting from scratch (Contributed by Varun)

Modified:
    incubator/ambari/branches/ambari-186/CHANGES.txt
    incubator/ambari/branches/ambari-186/hmc/js/addNodes.js
    incubator/ambari/branches/ambari-186/hmc/js/createCluster.js
    incubator/ambari/branches/ambari-186/hmc/js/uninstall.js
    incubator/ambari/branches/ambari-186/hmc/php/frontend/addNodes.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/nodesAction.php

Modified: incubator/ambari/branches/ambari-186/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/CHANGES.txt?rev=1347180&r1=1347179&r2=1347180&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/CHANGES.txt (original)
+++ incubator/ambari/branches/ambari-186/CHANGES.txt Wed Jun  6 22:29:11 2012
@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-402. Completing successful add node takes one to initialize cluster page starting from scratch (Varun via Vikram)
+
   AMBARI-401. Manual config changes for nn get reset on stop/start from hmc (Jitendra via Vikram)
 
   AMBARI-399. Cannot uninstall - the page hangs with the spinning icon (Yusaku via Vikram)

Modified: incubator/ambari/branches/ambari-186/hmc/js/addNodes.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/js/addNodes.js?rev=1347180&r1=1347179&r2=1347180&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/js/addNodes.js (original)
+++ incubator/ambari/branches/ambari-186/hmc/js/addNodes.js Wed Jun  6 22:29:11 2012
@@ -144,7 +144,7 @@ globalYui.one('#addNodesSubmitButtonId')
   var addNodesFilesForm = globalYui.one("#addNodesFilesFormId");
 
   addNodesFilesForm.set('action', '../php/frontend/addNodes.php?clusterName=' +
-    InstallationWizard.AddNodes.renderData.clusterName + "&freshInstall=" + InstallationWizard.AddNodes.renderData.freshInstall);
+    InstallationWizard.AddNodes.renderData.clusterName);
 
   /* Set the target of the first form's upload to be a hidden iframe
    * on the page so as not to redirect to the PHP page we're POSTing

Modified: incubator/ambari/branches/ambari-186/hmc/js/createCluster.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/js/createCluster.js?rev=1347180&r1=1347179&r2=1347180&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/js/createCluster.js (original)
+++ incubator/ambari/branches/ambari-186/hmc/js/createCluster.js Wed Jun  6 22:29:11 2012
@@ -49,8 +49,6 @@ globalYui.one('#createClusterSubmitButto
               createClusterResponseJson = createClusterResponseJson.response;
 
               /* Done with this stage, transition to the next. */
-              // Add freshInstall tag
-              createClusterResponseJson.freshInstall = true;
               transitionToNextStage( "#createClusterCoreDivId", createClusterData, 
                   "#addNodesCoreDivId", createClusterResponseJson, InstallationWizard.AddNodes.render );
             },

Modified: incubator/ambari/branches/ambari-186/hmc/js/uninstall.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/js/uninstall.js?rev=1347180&r1=1347179&r2=1347180&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/js/uninstall.js (original)
+++ incubator/ambari/branches/ambari-186/hmc/js/uninstall.js Wed Jun  6 22:29:11 2012
@@ -84,7 +84,7 @@ globalYui.one('#addNodesSubmitButtonId')
   var addNodesFilesForm = globalYui.one("#addNodesFilesFormId");
 
   addNodesFilesForm.set('action', '../php/frontend/addNodes.php?clusterName=' + 
-    clusterName + "&freshInstall=false");
+    clusterName);
 
   /* Set the target of the first form's upload to be a hidden iframe 
    * on the page so as not to redirect to the PHP page we're POSTing 

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/addNodes.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/addNodes.php?rev=1347180&r1=1347179&r2=1347180&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/addNodes.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/addNodes.php Wed Jun  6 22:29:11 2012
@@ -17,7 +17,18 @@ $logger = new HMCLogger("UploadFiles");
 $dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
 
 $clusterName = $_GET['clusterName'];
-$freshInstall = $_GET['freshInstall'];
+
+/* Figure out whether it's a fresh install or an AddNodesWizard-ish flow. */
+$clusterStateResponse = $dbAccessor->getClusterState($clusterName);
+
+if ($clusterStateResponse['result'] != 0) {
+  print json_encode($clusterStateResponse);
+  return;
+}
+
+$clusterState = json_decode($clusterStateResponse['state'], true);
+$freshInstall = ($clusterState['state'] == 'CONFIGURATION_IN_PROGRESS') ? true : false;
+
 $clusterDir = getClusterDir($clusterName);
 
 $logString = "Cluster Name: $clusterName Cleanup required? $freshInstall and type: ".gettype($freshInstall);
@@ -26,7 +37,7 @@ $logger->log_debug($logString);
 
 // We need to clean up prior instances for this
 // cluster name if this is a fresh install
-if ($freshInstall == 'true') {
+if ($freshInstall) {
   $dbAccessor->cleanupHosts($clusterName);
 }
 
@@ -59,7 +70,7 @@ header("Content-type: application/json")
 
 // Validate that there are no nodes that are already in use in case of addNodesWizard
 $logger->log_debug("$freshInstall");
-if ($freshInstall != "true") {
+if (!$freshInstall) {
 
   // Get the list of current nodes
     $allHostsInfoResult = $dbAccessor->getAllHostsInfo($clusterName, array());
@@ -98,19 +109,19 @@ if ($freshInstall != "true") {
       }
       return;
     }
+} else {
+  // Update the state of the cluster.
+  $state = "CONFIGURATION_IN_PROGRESS";
+  $displayName = "Configuration in progress";
+  $context = array (
+      'stage' => "ADD_NODES"
+      );
+
+  $retval = updateClusterState($clusterName, $state, $displayName, $context);
 }
 
 print (json_encode(array("result" => 0)));
 
-// Update the state of the cluster.
-$state = "CONFIGURATION_IN_PROGRESS";
-$displayName = "Configuration in progress";
-$context = array (
-  'stage' => "ADD_NODES"
-);
-
-$retval = updateClusterState($clusterName, $state, $displayName, $context);
-
 /*
 $outjson = array(
                   "errorCode"=> $retval['result'],

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/nodesAction.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/nodesAction.php?rev=1347180&r1=1347179&r2=1347180&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/nodesAction.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/nodesAction.php Wed Jun  6 22:29:11 2012
@@ -167,11 +167,25 @@ $context = array (
   'txnId' => $rootTxnId
 );
 
-// update state of the cluster to be configuration in progress
-$retval = updateClusterState($clusterName, $state, $displayName, $context);
-if ($retval['result'] != 0) {
-  $result = $retval['result'];
-  $error = $retval['error'];
+/* Only updateClusterState() if we're in the middle of configuring the cluster 
+ * the first time through. 
+ */
+$clusterStateResponse = $dbAccessor->getClusterState($clusterName);
+
+if ($clusterStateResponse['result'] != 0) {
+  print json_encode($clusterStateResponse);
+  return;
+}
+
+$clusterState = json_decode($clusterStateResponse['state'], true);
+
+if ($clusterState['state'] == 'CONFIGURATION_IN_PROGRESS') {
+  // update state of the cluster to be configuration in progress
+  $retval = updateClusterState($clusterName, $state, $displayName, $context);
+  if ($retval['result'] != 0) {
+    $result = $retval['result'];
+    $error = $retval['error'];
+  }
 }
 
 print (json_encode(array(