ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vik...@apache.org
Subject svn commit: r1347299 - in /incubator/ambari/branches/ambari-186: CHANGES.txt hmc/js/addNodes.js hmc/php/db/HMCDBAccessor.php hmc/php/frontend/addNodes.php
Date Thu, 07 Jun 2012 02:08:20 GMT
Author: vikram
Date: Thu Jun  7 02:08:19 2012
New Revision: 1347299

URL: http://svn.apache.org/viewvc?rev=1347299&view=rev
Log:
AMBARI-479. Add nodes after install does not allow re-bootstrap if user closes browser after
bootstrap and before starting services (Contributed by Vikram)

Modified:
    incubator/ambari/branches/ambari-186/CHANGES.txt
    incubator/ambari/branches/ambari-186/hmc/js/addNodes.js
    incubator/ambari/branches/ambari-186/hmc/php/db/HMCDBAccessor.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/addNodes.php

Modified: incubator/ambari/branches/ambari-186/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/CHANGES.txt?rev=1347299&r1=1347298&r2=1347299&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/CHANGES.txt (original)
+++ incubator/ambari/branches/ambari-186/CHANGES.txt Thu Jun  7 02:08:19 2012
@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-479. Add nodes after install does not allow re-bootstrap if user closes browser
after bootstrap and before starting services (Vikram)
+
   AMBARI-477. Spec file for using installer with php-5.3 (Hitesh via Vikram)
 
   AMBARI-478. Checkbox in the review and deploy page does not show proper state (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=1347299&r1=1347298&r2=1347299&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/js/addNodes.js (original)
+++ incubator/ambari/branches/ambari-186/hmc/js/addNodes.js Thu Jun  7 02:08:19 2012
@@ -186,11 +186,7 @@ globalYui.one("#fileUploadTargetId").on(
 
       if (responseJson.result != 0) {
         // This means we hit an error
-        if (responseJson.result == 2) {
-          hideLoadingImg();
-          setFormStatus(responseJson.error, true);
-          return;
-      } else if (responseJson.result == 3) {
+      if (responseJson.result == 3) {
         info =
           '<p>' +
             responseJson.error + '. ' +
@@ -201,11 +197,15 @@ globalYui.one("#fileUploadTargetId").on(
           setFormStatus(info, true);
           var infoPanel = createInformationalPanel("#informationalPanelContainerDivId", "Duplicate
nodes");
           infoPanel.set('centered', true);
-          var infoPanelContent = '<ul>';
-          for (host in responseJson.hosts) {
-            infoPanelContent += '<li>' + responseJson.hosts[host] + '</li>';
+          var infoPanelContent = '';
+          for (cluster in responseJson.hosts) {
+            infoPanelContent += 'Cluster: <b>' + cluster + '</b><ul>';
+            for (host in responseJson.hosts[cluster]) {
+              infoPanelContent += '<li>' + responseJson.hosts[cluster][host] + '</li>';
+            }
+
+            infoPanelContent += '</ul><br/>';
           }
-          infoPanelContent += '</ul>';
           infoPanel.set('bodyContent', infoPanelContent);
           infoPanel.addButton({
             value: 'Close',

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=1347299&r1=1347298&r2=1347299&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/db/HMCDBAccessor.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/db/HMCDBAccessor.php Thu Jun  7 02:08:19
2012
@@ -1094,6 +1094,7 @@ class HMCDBAccessor {
       $host["discoveryStatus"] = $entry["discovery_status"];
       $host["badHealthReason"] = $entry["bad_health_reason"];
       $host["attributes"] = json_decode($entry["attributes"], true);
+      $host["clusterName"] = $entry["cluster_name"];
       array_push($response["hosts"], $host);
     }
     LockRelease(); return $response;
@@ -3381,7 +3382,7 @@ class HMCDBAccessor {
       $host["discoveryStatus"] = $entry["discovery_status"];
       $host["badHealthReason"] = $entry["bad_health_reason"];
       $host["attributes"] = json_decode($entry["attributes"], true);
-      array_push($response["hosts"], $host);
+      array_push($response["hosts"][$host["hostName"]], $host);
     }
     LockRelease(); return $response;
   }

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=1347299&r1=1347298&r2=1347299&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/addNodes.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/addNodes.php Thu Jun  7 02:08:19
2012
@@ -82,42 +82,48 @@ $logger->log_info("Doing a fresh install
 if (!$freshInstall) {
 
   // Get the list of current nodes
-    $allHostsInfoResult = $dbAccessor->getAllHostsInfo($clusterName, array());
-    if ($allHostsInfoResult["result"] != 0 ) {
-      $logger->log_error("Got error while getting hostInfo for $host :" .$allHostsInfoResult["error"]);
-      print json_encode($allHostsInfoResult);
-      return;
-    }
-
-    // See if they are duplicates
-    $newHosts = readHostsFile($hostsFileDestination);
-    $duplicateHosts = array();
-    $logger->log_debug("Checking for Duplicate Hosts.");
-    foreach ($allHostsInfoResult["hosts"] as $hostInfo) {
-      if (in_array($hostInfo["hostName"], $newHosts)) {
-        $duplicateHosts[] = $hostInfo["hostName"];
-      }
-    }
-    $numDupHosts = count($duplicateHosts);
-    $numNewHosts = count($newHosts);
-    if ($numDupHosts != 0) {
-      if ($numNewHosts == $numDupHosts) {
-        print (json_encode(array("result" => 2, "error" => "All the hosts in the given
file are already being used in cluster '$clusterName'")));
-      } else {
-        print (json_encode(array("result" => 3, "error" => "Some hosts in the given
file are already being used in cluster '$clusterName'", "hosts" => $duplicateHosts)));
-
-        // Just re-edit the hosts' file in case users says go ahead
-        $nodeFileOut = fopen($hostsFileDestination, "w");
-        foreach ($newHosts as $newHost) {
-          if (in_array($newHost, $duplicateHosts)) {
-            continue;
-          }
-          fwrite($nodeFileOut, $newHost."\n");
+  $allHostsInfoResult = $dbAccessor->getAllHostsInfo("", array());
+  if ($allHostsInfoResult["result"] != 0 ) {
+    $logger->log_error("Got error while getting hostInfo for $host :" .$allHostsInfoResult["error"]);
+    print json_encode($allHostsInfoResult);
+    return;
+  }
+
+  $unassignedHostResult = $dbAccessor->getAllUnassignedHosts($clusterName);
+  if ($unassignedHostResult["result"] != 0) {
+    print json_encode($unassignedHostResult);
+    return;
+  }
+
+  $unassignedHostList = $unassignedHostResult["hosts"];
+
+  // See if they are duplicates
+  $newHosts = readHostsFile($hostsFileDestination);
+  $duplicateHosts = array();
+  $logger->log_debug("Checking for Duplicate Hosts.");
+  foreach ($allHostsInfoResult["hosts"] as $hostInfo) {
+    $logger->log_debug("Checking for Duplicate Hosts. hostname = ".
+      $hostInfo["hostName"]. " key does not exist? " . 
+      array_key_exists($hostInfo["hostName"], $unassignedHostList). 
+      " incoming cluster name: $clusterName, host is part of cluster "
+      .$hostInfo["clusterName"]);
+    if (in_array($hostInfo["hostName"], $newHosts) &&
+      (!(array_key_exists($hostInfo["hostName"], $unassignedHostList)) 
+      || ($hostInfo["clusterName"] != $clusterName))) {
+        if (!array_key_exists($hostInfo["clusterName"], $duplicateHosts)) {
+          $duplicateHosts[$hostInfo["clusterName"]] = array();
         }
-        fclose($nodeFileOut);
+
+        array_push($duplicateHosts[$hostInfo["clusterName"]], 
+                   $hostInfo["hostName"]);
       }
-      return;
-    }
+  }
+  $numDupHosts = count($duplicateHosts);
+  $numNewHosts = count($newHosts);
+  if ($numDupHosts != 0) {
+    print (json_encode(array("result" => 3, "error" => "Some hosts in the given file
are already being used in cluster", "hosts" => $duplicateHosts)));
+    return;
+  }
 } else {
   // Update the state of the cluster.
   $state = "CONFIGURATION_IN_PROGRESS";



Mime
View raw message