incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vik...@apache.org
Subject svn commit: r1346603 - in /incubator/ambari/branches/ambari-186: ./ hmc/php/db/ hmc/php/frontend/ hmc/php/util/
Date Tue, 05 Jun 2012 21:32:46 GMT
Author: vikram
Date: Tue Jun  5 21:32:45 2012
New Revision: 1346603

URL: http://svn.apache.org/viewvc?rev=1346603&view=rev
Log:
AMBARI-338. Cluster status update needs to happen for all stages of installation wizard. 
(Contributed by Vikram)

Added:
    incubator/ambari/branches/ambari-186/hmc/php/frontend/deployPostProcess.php
Modified:
    incubator/ambari/branches/ambari-186/CHANGES.txt
    incubator/ambari/branches/ambari-186/hmc/php/db/HMCDBAccessor.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/addNodes.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/assignMasters.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/configureCluster.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/configureServices.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/createCluster.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/fetchTxnProgress.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/nodesAction.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/nodesActionProgress.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/selectServices.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php
    incubator/ambari/branches/ambari-186/hmc/php/util/clusterState.php
    incubator/ambari/branches/ambari-186/hmc/php/util/lock.php

Modified: incubator/ambari/branches/ambari-186/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/CHANGES.txt?rev=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/CHANGES.txt (original)
+++ incubator/ambari/branches/ambari-186/CHANGES.txt Tue Jun  5 21:32:45 2012
@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-338. Cluster status update needs to happen for all stages of installation wizard.
(Vikram)
+
   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)

Modified: incubator/ambari/branches/ambari-186/hmc/php/db/HMCDBAccessor.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/db/HMCDBAccessor.php?rev=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/db/HMCDBAccessor.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/db/HMCDBAccessor.php Tue Jun  5 21:32:45
2012
@@ -77,25 +77,26 @@ class HMCDBAccessor {
     }
     LockRelease(); return $response;
   }
+  
+  /**
+   * Update cluster state for a given clusterName
+   * @param string $clusterName Cluster Name
+   * @param string $state New state of cluster
+   * @return mixed
+   *   array ( "state" => $clusterState,
+   *           "result" => 0,
+   *           "error" => "");
+   */
 
   public function getClusterState ($clusterName) {
     LockAcquire();
-    $response = array ( "clusterName" => $clusterName,
-        "result" => 0, "error" => "");
-    $ret = $this->dbHandle->beginTransaction();
-    if (!$ret) {
-      $error = $this->getLastDBErrorAsString();
-      $response["result"] = 1;
-      $response["error"] = "Failed to start DB transaction, error=".$error;
-      LockRelease(); return $response;
-    }
     $query = "SELECT state FROM Clusters WHERE cluster_name = "
         . $this->dbHandle->quote($clusterName);
+    $response = array ( "result" => 0, "error" => "");
     $this->logger->log_trace("Running query: $query");
     $pdoStmt = $this->dbHandle->query($query);
     if ($pdoStmt === FALSE) {
       $error = $this->getLastDBErrorAsString();
-      $this->dbHandle->rollBack();
       $this->logger->log_error("Error when executing query"
           . ", query=".$query
           . ", error=".$error);
@@ -104,17 +105,15 @@ class HMCDBAccessor {
       LockRelease(); return $response;
     }
     $result = $pdoStmt->fetchAll(PDO::FETCH_BOTH);
- 
-    LockRelease();
-
     if (isset($result) && is_array($result) && count($result) == 1) {
-      $response[$clusterName] = $result[0]["state"];
-      return $response;
+      $response["state"] = $result[0]["state"];
+      LockRelease(); return $response;
     }
 
     $response["result"] = 1;
     $response["error"] = "Result is not set or not array or count is not 1 ".json_encode($result);
-    return $response;
+
+    LockRelease(); return $response;
   }
 
   /**
@@ -2921,6 +2920,7 @@ class HMCDBAccessor {
         $rowsChanged += $ret;
       }
     }
+
     $ret = $this->dbHandle->commit();
     if (!$ret) {
       $error = $this->getLastDBErrorAsString();

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=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/addNodes.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/addNodes.php Tue Jun  5 21:32:45
2012
@@ -5,6 +5,7 @@ include_once '../conf/Config.inc';
 include_once 'localDirs.php';
 include_once "../util/lock.php";
 include_once '../db/HMCDBAccessor.php';
+include_once "../util/clusterState.php";
 
 /*
 sleep(3);
@@ -52,8 +53,17 @@ if (move_uploaded_file($_FILES['clusterH
     //echo "Possible file upload attack!\n";
 }
 
+// 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"=> 0,
+                  "errorCode"=> $retval['result'],
  //                 "clusterName" => $clusterName,
  //                 "finalDestination" => $identityFileDestination,
  //                 "fileToBeMoved" => $_FILES['clusterDeployUserIdentityFile']['tmp_name'],

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/assignMasters.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/assignMasters.php?rev=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/assignMasters.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/assignMasters.php Tue Jun  5 21:32:45
2012
@@ -6,6 +6,7 @@ include_once 'localDirs.php';
 include_once "../util/lock.php";
 include_once '../db/HMCDBAccessor.php';
 include_once '../util/selectNodes.php';
+include_once '../util/clusterState.php';
 
 $logger = new HMCLogger("AssignHosts");
 $dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
@@ -91,7 +92,7 @@ if ($nameNodeInfoResult["result"] != 0 )
   return;
 }
 $logger->log_error("All mount points: ".$nameNodeInfoResult["disksInfo"]);
-$AllMountPoints = json_decode($nameNodeInfoResult["disksInfo"]);
+$AllMountPoints = json_decode($nameNodeInfoResult["disksInfo"], true);
 
 // generate the mount points info required by javascript in the next phase
 $propertiesArr = $dbAccessor->getConfigPropertiesMetaInfo();
@@ -141,6 +142,22 @@ $outjson = array(
                                 ),
             );
 
-print(json_encode(array( "result" => 0, "error" => "", "response" => $outjson)));
+// Update the state of the cluster.
+$result = 0;
+$error = "";
+
+$state = "CONFIGURATION_IN_PROGRESS";
+$displayName = "Configuration in progress";
+$context = array (
+  'stage' => "ASSIGN_MASTERS"
+);
+
+$retval = updateClusterState($clusterName, $state, $displayName, $context);
+if ($retval['result'] != 0) {
+  $result = $retval['result'];
+  $error = $retval['error'];
+}
+
+print(json_encode(array( "result" => $result, "error" => $error, "response" => $outjson)));
 
 ?>

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/configureCluster.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/configureCluster.php?rev=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/configureCluster.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/configureCluster.php Tue Jun  5
21:32:45 2012
@@ -6,6 +6,7 @@ include_once 'localDirs.php';
 include_once "../util/lock.php";
 include_once '../db/HMCDBAccessor.php';
 include_once '../util/suggestProperties.php';
+include_once '../util/clusterState.php';
 
 $logger = new HMCLogger("ConfigureCluster");
 $dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
@@ -40,6 +41,22 @@ if ($ret["result"] != 0) {
 $jsonOutput = array();
 $jsonOutput["clusterName"] = $clusterName;
 
-print(json_encode(array("result" => 0, "error" => "", "response" => $jsonOutput)));
+// Update the state of the cluster.
+$result = 0;
+$error = "";
+
+$state = "CONFIGURATION_IN_PROGRESS";
+$displayName = "Configuration in progress";
+$context = array (
+  'stage' => "CONFIGURE_CLUSTER"
+);
+
+$retval = updateClusterState($clusterName, $state, $displayName, $context);
+if ($retval['result'] != 0) {
+  $result = $retval['result'];
+  $error = $retval['error'];
+}
+
+print(json_encode(array("result" => $result, "error" => $error, "response" => $jsonOutput)));
 
 ?>

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/configureServices.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/configureServices.php?rev=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/configureServices.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/configureServices.php Tue Jun  5
21:32:45 2012
@@ -7,6 +7,7 @@ include_once "../util/lock.php";
 include_once '../db/HMCDBAccessor.php';
 include_once './configUtils.php';
 include_once '../util/suggestProperties.php';
+include_once "../util/clusterState.php";
 
 $logger = new HMCLogger("Options");
 $dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
@@ -27,6 +28,23 @@ if ($result['result'] != 0) {
 
 $jsonOutput = array();
 $jsonOutput['clusterName'] = $clusterName;
-print (json_encode(array("result" => 0, "error" => 0, "response" => $jsonOutput)));
+
+// Update the state of the cluster.
+$result = 0;
+$error = "";
+
+$state = "CONFIGURATION_IN_PROGRESS";
+$displayName = "Configuration in progress";
+$context = array (
+  'stage' => "CONFIGURE_SERVICES"
+);
+
+$retval = updateClusterState($clusterName, $state, $displayName, $context);
+if ($retval['result'] != 0) {
+  $result = $retval['result'];
+  $error = $retval['error'];
+}
+
+print (json_encode(array("result" => $result, "error" => $error, "response" => $jsonOutput)));
 
 ?>

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/createCluster.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/createCluster.php?rev=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/createCluster.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/createCluster.php Tue Jun  5 21:32:45
2012
@@ -5,6 +5,7 @@ include_once '../conf/Config.inc';
 include_once './localDirs.php';
 include_once "../util/lock.php";
 include_once '../db/HMCDBAccessor.php';
+include_once '../util/clusterState.php';
 
 header("Content-type: application/json");
 
@@ -133,9 +134,25 @@ if ($propertiesArr["result"] != 0) {
   return;
 }
 
+$result = 0;
+$error = "";
+
+$state = "CONFIGURATION_IN_PROGRESS";
+$displayName = "Configuration in progress";
+$context = array (
+  'stage' => "CREATE_CLUSTER"
+);
+
+// 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'];
+}
+
 $output = array(
-                 "result" => 0,
-                 "error" => "",
+                 "result" => $result,
+                 "error" => $error,
                  "response" => array(
                                  "clusterName" => $response["clusterName"],
                                  "yumRepo" => array (

Added: incubator/ambari/branches/ambari-186/hmc/php/frontend/deployPostProcess.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/deployPostProcess.php?rev=1346603&view=auto
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/deployPostProcess.php (added)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/deployPostProcess.php Tue Jun  5
21:32:45 2012
@@ -0,0 +1,54 @@
+<?php
+
+include_once '../util/Logger.php';
+include_once '../conf/Config.inc';
+include_once 'localDirs.php';
+include_once "../util/lock.php";
+include_once '../db/HMCDBAccessor.php';
+include_once '../util/clusterState.php';
+
+include_once 'commandUtils.php';
+include_once "../util/HMCTxnUtils.php";
+
+function deployPostProcess($clusterName, $user, $txnId, $progress)
+{
+
+  $logger = new HMCLogger("DeployPostProcess");
+  $dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
+
+  $result = 0;
+  $error = "";
+
+  $txnStatus = $dbAccessor->getTransactionStatusInfo($clusterName, $txnId);
+  if ($txnStatus['result'] != 0) {
+    $logger->log_error("Deploy post process get txn info failed");
+    $result = $txnStatus['result'];
+    $error = $txnStatus['error'];
+    return (array("result" => $result, "error" => $error));
+  }
+
+  $txnStatus = !($progress['encounteredError']);
+  $state = "DEPLOYED";
+  if ($txnStatus) {
+    $displayName = "Deployed successfully";
+  } else {
+    $displayName = "Deploy failed";
+  }
+
+  $context = array (
+    'status' => $txnStatus,
+    'txnId' => $txnId
+  );
+
+  // update state of the cluster 
+  $retval = updateClusterState($clusterName, $state, $displayName, $context);
+  if ($retval['result'] != 0) {
+    $logger->log_error("Update cluster state failed");
+    $result = $retval['result'];
+    $error = $retval['error'];
+  }
+
+  return (array("result" => $result, "error" => $error));
+}
+
+?>

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/fetchTxnProgress.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/fetchTxnProgress.php?rev=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/fetchTxnProgress.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/fetchTxnProgress.php Tue Jun  5
21:32:45 2012
@@ -4,6 +4,7 @@ include_once '../util/Logger.php';
 include_once "../conf/Config.inc";
 include_once "../orchestrator/HMC.php";
 include_once "uninstallCleanup.php";
+include_once "deployPostProcess.php";
 
 $dbPath = $GLOBALS["DB_PATH"];
 
@@ -16,6 +17,10 @@ $logger = new HMCLogger("TxnProgress");
 $map = array(
   "HMC::uninstallHDP" => array (
       "deBootStrap"
+  ),
+
+  "HMC::deployHDP" => array (
+      "deployPostProcess"
   )
 );
 
@@ -696,7 +701,7 @@ if (($progress['processRunning'] == FALS
     // run the next script from the map
     foreach ($map[$statusInfo['function']] as $postProcessFunc) {
       $logger->log_debug("Post process function is ".$postProcessFunc);
-      $retval = $postProcessFunc($clusterName,$deployUser, $lastTransaction);
+      $retval = $postProcessFunc($clusterName, $deployUser, $txnId, $progress);
       if ($retval["result"] != 0) {
         $progress['encounteredError'] = TRUE;
         break;

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=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/nodesAction.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/nodesAction.php Tue Jun  5 21:32:45
2012
@@ -7,6 +7,7 @@ include_once "../util/lock.php";
 include_once '../db/HMCDBAccessor.php';
 
 include_once 'commandUtils.php';
+include_once '../util/clusterState.php';
 include_once "../util/HMCTxnUtils.php";
 
 $logger = new HMCLogger("setupNodes");
@@ -155,9 +156,27 @@ if ($execBackgroundResult == FALSE) {
   return;
 }
 
+$result = 0;
+$error = "";
+
+$state = "CONFIGURATION_IN_PROGRESS";
+$displayName = "Configuration in progress";
+
+$context = array (
+  'stage' => "ADD_NODES",
+  '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'];
+}
+
 print (json_encode(array(
-  "result" => 0,
-  "error" => "",
+  "result" => $result,
+  "error" => $error,
   "response" => array(
     "clusterName" => $clusterName,
     "txnId" => $rootTxnId,

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/nodesActionProgress.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/nodesActionProgress.php?rev=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/nodesActionProgress.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/nodesActionProgress.php Tue Jun
 5 21:32:45 2012
@@ -93,7 +93,7 @@ if ($jsonOutput['currentProgressStateInd
 $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']);
+  $jsonOutput['stateInfo']['subTxns'][$subTxnId]['state'] = json_decode($jsonOutput['stateInfo']['subTxns'][$subTxnId]['state'],
true);
 }
 
 print json_encode($jsonOutput);

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/selectServices.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/selectServices.php?rev=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/selectServices.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/selectServices.php Tue Jun  5 21:32:45
2012
@@ -5,7 +5,7 @@ include_once '../conf/Config.inc';
 include_once 'localDirs.php';
 include_once "../util/lock.php";
 include_once '../db/HMCDBAccessor.php';
-
+include_once "../util/clusterState.php";
 include_once '../util/selectNodes.php';
 // include_once 'install_puppet.php';
 
@@ -153,5 +153,21 @@ foreach($allServicesArray["services"] as
 }
 //////////////////// End of populate service masters for the UI ///////////////////////////
 
-print (json_encode(array("result" => 0, "error" => 0, "response" => $jsonOutput)));
+// Update the state of the cluster.
+$result = 0;
+$error = "";
+
+$state = "CONFIGURATION_IN_PROGRESS";
+$displayName = "Configuration in progress";
+$context = array (
+  'stage' => "SELECT_SERVICES"
+);
+
+$retval = updateClusterState($clusterName, $state, $displayName, $context);
+if ($retval['result'] != 0) {
+  $result = $retval['result'];
+  $error = $retval['error'];
+}
+
+print (json_encode(array("result" => $result, "error" => $error, "response" => $jsonOutput)));
 ?>

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=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php Tue Jun  5
21:32:45 2012
@@ -17,7 +17,7 @@ $dbAccessor = new HMCDBAccessor($GLOBALS
 // and poll for completion.
 // upon completion, does the nodesActionProgress piece to update
 // status of the completed state
-function deBootStrap ($clusterName, $deployUser, $stageInfo)
+function deBootStrap ($clusterName, $deployUser, $txnId, $progressInfo)
 {
   global $logger, $dbAccessor, $stagesInfo;
 

Modified: incubator/ambari/branches/ambari-186/hmc/php/util/clusterState.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/util/clusterState.php?rev=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/util/clusterState.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/util/clusterState.php Tue Jun  5 21:32:45
2012
@@ -1,18 +1,29 @@
 <?php
 
-include_once '../php/util/Logger.php';
-include_once '../php/conf/Config.inc';
-include_once '../php/frontend/localDirs.php';
-include_once "../php/util/lock.php";
-include_once '../php/db/HMCDBAccessor.php';
-
 // initial setup
-$logger = new HMCLogger("sequentialScriptExecutor");
-$dbHandle = new HMCDBAccessor($GLOBALS["DB_PATH"]);
+function updateClusterState ($clusterName, $state, $displayName, $context) {
+  $logger = new HMCLogger("ClusterState");
+  $dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
+
+  $stateObj = array (
+                  'state' => $state,
+                  'displayName' => $displayName,
+                  'timeStamp' => time(),
+                  'context' => $context
+                );
+
+  $stateStr = json_encode($stateObj);
+  $retval = $dbAccessor->setClusterState($clusterName, $stateStr);
+
+  $logger->log_debug("Update Cluster State with ".$stateStr);
+
+  return $retval;
+}
 
 function needWipeOut ($clusterName) {
-  global $logger, $dbHandle;
-  $clusterStatus = $dbHandle->getClusterStatus($clusterName);
+  $logger = new HMCLogger("ClusterState");
+  $dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
+  $clusterStatus = $dbAccessor->getClusterStatus($clusterName);
   return $clusterStatus;
 }
 

Modified: incubator/ambari/branches/ambari-186/hmc/php/util/lock.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/util/lock.php?rev=1346603&r1=1346602&r2=1346603&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/util/lock.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/util/lock.php Tue Jun  5 21:32:45 2012
@@ -12,8 +12,13 @@ function LockAcquire() {
   $fileHdl = fopen($lockFile, "r");
   $GLOBALS['fileHdl'] = $fileHdl;
   $retval = flock($fileHdl, LOCK_EX);
-//  $logger->log_debug("Acquired Lock Status for Process: "
-//    . json_encode(posix_getpid()). " : ". json_encode($retval));
+  /* Uncomment for debugging purposes
+  $e = new Exception;
+  $logger->log_debug("Acquired Lock Status for Process: "
+    . json_encode(posix_getpid()). " : ". json_encode($retval) . " backtrace: ".
+  $e->getTraceAsString());
+  unset($e);
+   */
   return;
 }
 
@@ -24,8 +29,13 @@ function LockRelease() {
 //    . json_encode(posix_getpid()));
   $fileHdl = $GLOBALS['fileHdl'];
   $retval = flock($fileHdl, LOCK_UN);
-//  $logger->log_debug("Released Lock Status for Process: "
-//    . json_encode(posix_getpid()). " : ". json_encode($retval));
+  /* Uncomment for debugging purposes
+  $e = new Exception;
+  $logger->log_debug("Released Lock Status for Process: "
+  . json_encode(posix_getpid()). " : ". json_encode($retval) . " backtrace: ".
+  $e->getTraceAsString());
+  unset($e);
+   */
 }
 
 ?>



Mime
View raw message