Ver Fonte

AMBARI-209. Node selection should ignore failed nodes. (hitesh via omalley)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/ambari-186@1337230 13f79535-47bb-0310-9956-ffa450edef68
Owen O'Malley há 13 anos atrás
pai
commit
2cae166ec2

+ 2 - 0
CHANGES.txt

@@ -2,6 +2,8 @@ Ambari Change log
 
 Release 0.x.x - unreleased
 
+  AMBARI-209. Node selection should ignore failed nodes. (hitesh via omalley)
+
   AMBARI-213. Fix directory permissions so that Ganglia graphs render.
   (ramya via omalley)
 

+ 1 - 1
hmc/php/db/OrchestratorDB.php

@@ -448,7 +448,7 @@ class OrchestratorDB {
    */
   public function getAllNodes() {
     $result = $this->db->getAllHostsInfo($this->clusterName,
-        array(), array());
+        array("=" => array ( "discoveryStatus" => "SUCCESS")), array());
     if ($result === FALSE || $result["result"] != 0
         || !isset($result["hosts"]) || !is_array($result["hosts"])) {
       $this->logger->log_error("Failed to get host list from DB");

+ 0 - 8
hmc/php/frontend/deploy.php

@@ -34,14 +34,6 @@ $thisHostName = trim(strtolower(exec('hostname -f')));
 $nagiosGangliaCoHosted = FALSE;
 $dbAccessor = new HMCDBAccessor($dbPath);
 
-// check if single node install
-$hostsInfo = $dbAccessor->getAllHostsInfo($clusterName);
-if (isset($hostsInfo["hosts"])
-    && is_array($hostsInfo["hosts"]) && count($hostsInfo["hosts"] == 1)) {
-  $nagiosGangliaCoHosted = TRUE;
-}
-
-// if not single node
 // check if nagios hosted on same server
 if (!$nagiosGangliaCoHosted) {
   // check if component mapped to this host

+ 0 - 17
hmc/php/frontend/deployAddedNodes.php

@@ -55,23 +55,6 @@ $goodHosts = convertToLowerCase($goodHosts);
 
 $logger->log_debug("goodHosts: ".json_encode($goodHosts));
 
-/*
-////// Get info about all nodes from db ////
-$allHostsInfo = $dbHandle->getAllHostsInfo($clusterName, "", "");
-if ($allHostsInfo["result"] != 0 ) {
-  $logger->log_error("Got error while getting allHostsInfo :" .$allHostsInfo["error"]);
-  print json_encode($allHostsInfo);
-  return false;
-}
-
-$goodHosts = array();
-foreach ($allHostsInfo["hosts"] as $hostInfo) {
-  if ($hostInfo["discoveryStatus"] == "SUCCESS") {
-    $goodHosts[] = $hostInfo["hostName"];
-  }
-}
- */
-
 /////// Insert roles for these nodes ////////
 foreach ($components as $componentName) {
   $addHostsToComponentResult = $dbHandle->addHostsToComponent($clusterName, $componentName, $goodHosts, "UNKNOWN", "UNKNOWN");

+ 2 - 1
hmc/php/frontend/selectServices.php

@@ -88,7 +88,8 @@ $jsonOutput["allHosts"] = array();
 /*
  * FIXME need to get all hosts from select Nodes script
  */
-$allHostsInfo = $dbAccessor->getAllHostsInfo($clusterName, "", array());
+$allHostsInfo = $dbAccessor->getAllHostsInfo($clusterName,
+    array("=" => array ( "discoveryStatus" => "SUCCESS")), array());
 if ($allHostsInfo["result"] != 0 ) {
   $logger->log_error("Got error while getting hostsInfo ".$allHostsInfo["error"]);
   print json_encode($allHostsInfo);

+ 3 - 2
hmc/php/puppet/DBReader.php

@@ -31,9 +31,10 @@ class DBReader {
 
   public function getAllHostAttributes($clusterName) {
     $dbAccessor = new HMCDBAccessor($this->dbPath);
-    $allHostAttributes = $dbAccessor->getAllHostsInfo($clusterName, NULL, NULL);
+    $allHostAttributes = $dbAccessor->getAllHostsInfo($clusterName,
+        array("=" => array ( "discoveryStatus" => "SUCCESS")), array());
     return $allHostAttributes;
-  }  
+  }
 
   public function getHostNames($clusterId) {
     $dbAccessor = new HMCDBAccessor($this->dbPath);

+ 4 - 2
hmc/php/util/selectNodes.php

@@ -215,7 +215,8 @@ class SelectNodes {
     $return["error"] = "";
     $this->logger->log_error("All info: ".$clusterName."\n "
         .json_encode($masterToHost));
-    $allHostsDBInfo = $db->getAllHostsInfo($clusterName, "", array());
+    $allHostsDBInfo = $db->getAllHostsInfo($clusterName,
+        array("=" => array ( "discoveryStatus" => "SUCCESS")), array());
     if ($allHostsDBInfo["result"] != 0) {
       $this->logger->log_error("Issue getting all hosts info ".$allHostsDBInfo["error"]);
       $return["result"] = $allHostsDBInfo["result"];
@@ -307,7 +308,8 @@ class SelectNodes {
     $return = array();
     $order = array("sortColumn" => "totalMem",
         "sortOrder" => "DESC");
-    $allHostsDBInfo = $db->getAllHostsInfo($clustername, "", $order);
+    $allHostsDBInfo = $db->getAllHostsInfo($clustername,
+        array("=" => array ( "discoveryStatus" => "SUCCESS")) , $order);
     if ($allHostsDBInfo["result"] != 0) {
       $this->logger->log_error("Issue getting all hosts info ".$allHostsDBInfo["error"]);
       $return["result"] = $allHostsDBInfo["result"];

+ 5 - 7
hmc/php/util/sequentialScriptRunner.php

@@ -146,13 +146,11 @@ $hosts = readHostsFile($readFromFile);
 $hosts = convertToLowerCase($hosts);
 
 $logger->log_debug("The hosts after converting to lower case ".print_r($hosts, true));
-// Only add this host to list if the db does not have that host already. This is assuming
-// the host being in the db means the HMC host has been bootstrapped and discovered.
-$hostsInfoInDB = $dbHandle->getAllHostsInfo($clusterName, "", "");
-$logger->log_info("Host Info in DB ".print_r($hostsInfoInDB, true));
-$hostsInDB = $hostsInfoInDB["hosts"];
-if (sizeof($hostsInDB) == 0) {
-  $logger->log_info("Hosts is empty so adding $thisHostName to the list of hosts");
+// Only add this host to list if the db does not have that host already.
+$checkThisHostInDB = $dbHandle->getHostInfo($clusterName, $thisHostName);
+$logger->log_debug("Host Info in DB ".print_r($checkThisHostInDB, true));
+if ($checkThisHostInDB["result"] != 0) {
+  $logger->log_info($thisHostName . "not found in DB so adding it to the list of hosts");
   $hosts = addThisHostToList($hosts, $logger, $thisHostName, $readFromFile);
 }
 $hosts = convertToLowerCase($hosts);

+ 4 - 2
hmc/php/util/suggestProperties.php

@@ -155,7 +155,8 @@ class SuggestProperties {
     $order = array("sortColumn" => "cpuCount",
         "sortOrder" => "ASC");
 
-    $allHosts = $db->getAllHostsInfo($clusterName, "", $order);
+    $allHosts = $db->getAllHostsInfo($clusterName,
+        array("=" => array ( "discoveryStatus" => "SUCCESS")), $order);
     if ($allHosts["result"] != 0) {
       $result["result"] = $allHosts["result"];
       $result["error"] = $allHosts["error"];
@@ -295,7 +296,8 @@ class SuggestProperties {
     $order = array("sortColumn" => "cpuCount",
             "sortOrder" => "ASC");
 
-    $allHosts = $db->getAllHostsInfo($clusterName, "", $order);
+    $allHosts = $db->getAllHostsInfo($clusterName,
+        array("=" => array ( "discoveryStatus" => "SUCCESS")), $order);
     if ($allHosts["result"] != 0) {
       $result["result"] = $allHosts["result"];
       $result["error"] = $allHosts["error"];