You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ji...@apache.org on 2012/05/27 09:26:00 UTC

svn commit: r1343004 - in /incubator/ambari/branches/ambari-186/hmc/php/frontend: uninstall/cleanupProcesses.php uninstall/deleteLogDirs.php uninstall/stages.php uninstall/yumCleanupHttpdStop.php uninstallCleanup.php

Author: jitendra
Date: Sun May 27 07:26:00 2012
New Revision: 1343004

URL: http://svn.apache.org/viewvc?rev=1343004&view=rev
Log:
AMBARI-301. Uninstall should not stop HMC. Contributed by Vikram.

Removed:
    incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall/deleteLogDirs.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall/yumCleanupHttpdStop.php
Modified:
    incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall/cleanupProcesses.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall/stages.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall/cleanupProcesses.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall/cleanupProcesses.php?rev=1343004&r1=1343003&r2=1343004&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall/cleanupProcesses.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall/cleanupProcesses.php Sun May 27 07:26:00 2012
@@ -11,7 +11,7 @@ $logger = new HMCLogger("CleanupProcesse
 $dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
 
 function getCommandLine() {
-  $cmdLine = "touch /etc/default/hadoop-env.sh ; killall puppet; killall java; killall jsvc; rm -rf /grid/?/hadoop/*;  rm -rf /var/log/puppet_agent.log; yum erase -y zookeeper* oozie* sqoop* pig* hbase* hadoop* hadoop-conf-pseudo* hdp_mon_dashboard; rm -rf /etc/hadoop/; rm -rf /etc/hbase; rm -rf /etc/oozie; rm -rf /etc/pig; rm -rf /etc/zookeeper; rm -rf /etc/sqoop ; rm -rf /etc/hive ; rm -rf /etc/hcatalog; rm -rf /etc/yum.repos.d/hdp* ; rm -rf /etc/yum.repos.d/cloudera* ; rm -rf /etc/yum.repos.d/cdh* ; rm -rf /var/run/hbase; rm -rf /var/run/zookeeper /var/run/hadoop /var/run/oozie /var/run/templeton /var/run/hive";
+  $cmdLine = "touch /etc/default/hadoop-env.sh ; killall puppet; rm -rf /var/log/puppet_agent.log; rm -rf /etc/yum.repos.d/hdp* ; ";
   $cmdLine = $cmdLine . 'sleep $[ $RANDOM % 5 ]; ';
   return $cmdLine;
 }

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall/stages.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall/stages.php?rev=1343004&r1=1343003&r2=1343004&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall/stages.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall/stages.php Sun May 27 07:26:00 2012
@@ -5,14 +5,6 @@ $stagesInfo = array(
       "description" => "Cleaning up processes",
       "scriptName" => "./uninstall/cleanupProcesses.php",
       ),
-    "YumCleanupAndHttpDStop" => array(
-      "description" => "Yum cleanup and httpd stop",
-      "scriptName" => "./uninstall/yumCleanupHttpdStop.php",
-      ),
-    "LogCleanup" => array(
-      "description" => "Log directories cleanup",
-      "scriptName" => "./uninstall/deleteLogDirs.php",
-      ),
     );
 
 ?>

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php?rev=1343004&r1=1343003&r2=1343004&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php Sun May 27 07:26:00 2012
@@ -19,7 +19,7 @@ $dbAccessor = new HMCDBAccessor($GLOBALS
 // status of the completed state
 function deBootStrap ($clusterName, $deployUser, $stageInfo)
 {
-  global $logger, $dbAccessor;
+  global $logger, $dbAccessor, $stagesInfo;
 
   /////// launch the stages in the background.
   $stagesFile = "./uninstall/stages.php";
@@ -56,7 +56,6 @@ function deBootStrap ($clusterName, $dep
 
   $allDone = false;
   while ($allDone == false) {
-    sleep(2);
     // use the txn id for finding the status to pass back to the user
     // the orchestrator txn id could potentially return an error because
     // there is a potential race condition before the orchestrator txnId has
@@ -69,8 +68,11 @@ function deBootStrap ($clusterName, $dep
         json_encode($orchestratorTxnId));
       // Check if this should return error FIXME
       // $jsonOutput['encounteredError'] = true;
-      return ($jsonOutput);
+      return (array('result' => 1, 'error' => $orchestratorTxnId['error']));
     }
+    // as soon as DB is read, sleep for 2 seconds because we want to 
+    // avoid continuous polling of the db
+    sleep(2);
 
     //$logger->log_error(" ==== subTxns info is  " . json_encode($orchestratorTxnId));
     $keys = array_keys($orchestratorTxnId['subTxns']);
@@ -95,24 +97,34 @@ function deBootStrap ($clusterName, $dep
       return ($jsonOutput);
     }
 
-    $jsonOutput['currentProgressStateIndex'] = count($allSubTxns['subTxns']) - 1;
-    if ($jsonOutput['currentProgressStateIndex'] < 0) {
-      $jsonOutput['currentProgressStateIndex'] = 0;
+    $logger->log_debug("allsubtxn count is ".json_encode(count($allSubTxns['subTxns'])));
+    $logger->log_debug("stages count is ".json_encode(count($stagesInfo)));
+    $logger->log_debug("subtxns ".json_encode($allSubTxns));
+    // allDone must be set once the processes launched have completed running
+    if ((count($allSubTxns['subTxns']) == count($stagesInfo))) {
+      $lastTxn = end($allSubTxns['subTxns']);
+      if (($lastTxn['opStatus'] == "SUCCESS")) {
+        $allDone = true;
+        $result = 0;
+        $error = "";
+        // remove the following 2 lines FIXME
+        $error = "Not a failure! LOL";
+        $result = 1;
+      } else if (($lastTxn['opStatus'] == "FAILED") || 
+          ($lastTxn['opStatus'] == "TOTALFAILURE")) {
+        $logger->log_debug("");
+        $allDone = true;
+        $error = json_encode($lastTxn['state']);
+        $result = 1;
+      }
     }
-    $jsonOutput['stateInfo'] = $allSubTxns;
-    // Decode log information store as part of state.
-    foreach ($jsonOutput['stateInfo']['subTxns'] as $subTxnId => $subTxnInfo) {
-      $jsonOutput['stateInfo']['subTxns'][$subTxnId]['state'] = json_decode($jsonOutput['stateInfo']['subTxns'][$subTxnId]['state']);
-    }
-
-    $allDone = true;
   }
   /////// done monitoring return back to the uninstall
   
   // need to cleanup db for this cluster
   $dbAccessor->deleteCluster($clusterName);
   
-  return array('result' => 0);
+  return array('result' => $result, 'error' => $error);
 }
 
 ?>