Browse Source

AMBARI-526. Display client nodes as part of cluster topology display. (Contributed by Varun)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/ambari-186@1347029 13f79535-47bb-0310-9956-ffa450edef68
Vikram Dixit K 13 years ago
parent
commit
7548dfb0ef
3 changed files with 70 additions and 17 deletions
  1. 2 0
      CHANGES.txt
  2. 61 8
      hmc/js/clustersList.js
  3. 7 9
      hmc/php/frontend/fetchClusterServices.php

+ 2 - 0
CHANGES.txt

@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-526. Display client nodes as part of cluster topology display. (Varun via Vikram)
+
   AMBARI-359. invalid parameter java_needed during uninstall (Ramya via Vikram)
 
   AMBARI-265. Reconfig page close button (x) is not visible (Vinod via Vikram)

+ 61 - 8
hmc/js/clustersList.js

@@ -1,10 +1,6 @@
-function generateClusterHostRoleMappingMarkup( clusterServices ) {
+function generateClusterMastersHostRoleMappingMarkup( clusterServices ) {
 
-  var clusterHostRoleMappingMarkup = 
-  '<fieldset id=clustersHostRoleMappingFieldsetId>' +
-    '<legend>' +
-      'Locations Of Service Masters' + 
-    '</legend>';
+  var clusterMastersHostRoleMappingMarkup = '';
 
   for (var serviceName in clusterServices) {
     if (clusterServices.hasOwnProperty(serviceName)) {
@@ -16,7 +12,7 @@ function generateClusterHostRoleMappingMarkup( clusterServices ) {
         globalYui.Array.each( clusterServices[serviceName].components, function (serviceComponent) {
           
           if (serviceComponent.isMaster) {
-            clusterHostRoleMappingMarkup += 
+            clusterMastersHostRoleMappingMarkup += 
               '<div class=formElement>' + 
                 '<label>' + serviceComponent.displayName + ': ' + '</label>' + 
                 serviceComponent.hostName +
@@ -28,7 +24,64 @@ function generateClusterHostRoleMappingMarkup( clusterServices ) {
     }
   }
 
-  clusterHostRoleMappingMarkup += 
+  return clusterMastersHostRoleMappingMarkup;
+}
+
+function generateClusterClientsHostRoleMappingMarkup( clusterServices ) {
+
+  var clusterClientsHostRoleMappingMarkup = '';
+  var finalHostMap = {};
+
+  /*
+  for (var serviceName in clusterServices) {
+    if (clusterServices.hasOwnProperty(serviceName)) {
+
+      if (clusterServices[serviceName].isEnabled == "1" && 
+          !clusterServices[serviceName].attributes.noDisplay) {
+
+        globalYui.Array.each( clusterServices[serviceName].components, function (serviceComponent) {
+          
+          globalYui.log("AAA is " + serviceComponent.hostname);
+          globalYui.log("BBB is " + globalYui.Lang.dump(serviceComponent));
+          if (serviceComponent.isClient) {
+            globalYui.log("Final host array is " + globalYui.Lang.dump(finalHostMap));
+            // just add the client to the hostname object
+            if ( !( serviceComponent.hostName in finalHostMap ) ) {
+              finalHostMap[serviceComponent.hostName] = new Array();
+              finalHostMap[serviceComponent.hostName].push(serviceComponent.displayName);
+              globalYui.log("XXX is " + globalYui.Lang.dump(finalHostMap));
+            } else {
+              // FIXME fails to push display name to this array
+              globalYui.log("Service component array has " + globalYui.Lang.dump(finalHostMap[serviceComponent.hostName]) + " YYY: " + serviceComponent.hostname);
+              globalYui.log("ZZZ is " + globalYui.Lang.dump(finalHostMap));
+              finalHostMap[serviceComponent.hostname].push(serviceComponent.displayName);
+            }
+          }
+
+        });
+      }
+    }
+  }
+  */
+
+  return clusterClientsHostRoleMappingMarkup;
+}
+
+function generateClusterHostRoleMappingMarkup( clusterServices ) {
+
+  var clusterHostRoleMappingMarkup = 
+  '<fieldset id=clusterMastersHostRoleMappingFieldsetId>' +
+    '<legend>' +
+      'Locations Of Service Masters' + 
+    '</legend>' + 
+    generateClusterMastersHostRoleMappingMarkup(clusterServices) + 
+  '</fieldset>' + 
+  '<br/>' +
+  '<fieldset id=clusterClientsHostRoleMappingFieldsetId>' +
+    '<legend>' +
+      'Locations Of Service Clients' + 
+    '</legend>' + 
+    generateClusterClientsHostRoleMappingMarkup(clusterServices) + 
   '</fieldset>';
 
   return clusterHostRoleMappingMarkup;

+ 7 - 9
hmc/php/frontend/fetchClusterServices.php

@@ -45,16 +45,14 @@ function getAllComponentsForService ($serviceName)
   $componentResult = $dbAccessor->getAllServiceComponents($serviceName);
   if ($componentResult["result"] == 0) {
     foreach($componentResult["components"] as $componentName => $component) {
-      if($component["isMaster"] == 1) {
-        $hostsForComponentDBResult = $dbAccessor->getHostsForComponent($clusterName, $componentName);
-        if ($hostsForComponentDBResult["result"] != 0 ) {
-          $logger->log_error("Got error while getting hosts for component ".$hostsForComponentDBResult["error"]);
-          print json_encode($hostsForComponentDBResult);
-          return;
-        }
-        $allHosts = array_keys($hostsForComponentDBResult["hosts"]);
-        $component["hostName"] = $allHosts[0];
+      $hostsForComponentDBResult = $dbAccessor->getHostsForComponent($clusterName, $componentName);
+      if ($hostsForComponentDBResult["result"] != 0 ) {
+        $logger->log_error("Got error while getting hosts for component ".$hostsForComponentDBResult["error"]);
+        print json_encode($hostsForComponentDBResult);
+        return;
       }
+      $allHosts = array_keys($hostsForComponentDBResult["hosts"]);
+      $component["hostName"] = $allHosts[0];
       array_push($returnComponentsArray, $component);
     }
   } else {