You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2012/07/04 22:53:26 UTC
svn commit: r1357402 - in /incubator/ambari/branches/branch-0.9: CHANGES.txt
hmc/js/assignMasters.js hmc/js/clustersList.js
Author: yusaku
Date: Wed Jul 4 20:53:26 2012
New Revision: 1357402
URL: http://svn.apache.org/viewvc?rev=1357402&view=rev
Log:
AMBARI-495. HMC master node not shown in topology and node assignments if the HMC server is not assigned to any other role (Contributed by yusaku)
Modified:
incubator/ambari/branches/branch-0.9/CHANGES.txt
incubator/ambari/branches/branch-0.9/hmc/js/assignMasters.js
incubator/ambari/branches/branch-0.9/hmc/js/clustersList.js
Modified: incubator/ambari/branches/branch-0.9/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9/CHANGES.txt?rev=1357402&r1=1357401&r2=1357402&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.9/CHANGES.txt (original)
+++ incubator/ambari/branches/branch-0.9/CHANGES.txt Wed Jul 4 20:53:26 2012
@@ -6,6 +6,9 @@ characters wide.
Release 0.9.0 - unreleased
+ AMBARI-495. HMC master node not shown in topology and node assignments
+ if the HMC server is not assigned to any other role (yusaku)
+
AMBARI-596. Remove unused images in images/ directory. (vinodkv)
AMBARI-594. Move documentation into a sub-directory. (vinodkv)
Modified: incubator/ambari/branches/branch-0.9/hmc/js/assignMasters.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9/hmc/js/assignMasters.js?rev=1357402&r1=1357401&r2=1357402&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.9/hmc/js/assignMasters.js (original)
+++ incubator/ambari/branches/branch-0.9/hmc/js/assignMasters.js Wed Jul 4 20:53:26 2012
@@ -21,6 +21,8 @@
function AssignMasters() {
+ var managerHostName;
+ var allHosts;
var registeredAssignHostsEventHandlers = false;
function getNodeInfo(nodeName) {
@@ -28,10 +30,10 @@ function AssignMasters() {
if (nodeName == null) {
return null;
}
- for (host in this.allHosts) {
- if (this.allHosts[host].hostName == nodeName) {
+ for (var host in allHosts) {
+ if (allHosts[host].hostName == nodeName) {
// globalYui.log("Get node info: " + allHosts[host].hostName);
- return this.allHosts[host];
+ return allHosts[host];
}
}
@@ -49,15 +51,11 @@ function AssignMasters() {
function renderHostsToMasterServices(hostsToMasterServices) {
var markup = '';
for (var host in hostsToMasterServices) {
- var hostInfo = getNodeInfo(host);
- markup += '<div class="hostToMasterServices"><h3>' + host + '<span class="hostInfo">' + getTotalMemForDisplay(hostInfo.totalMem) + ', ' + hostInfo.cpuCount + ' cores</span></h3><ul>';
- for (var j in hostsToMasterServices[host]) {
- markup += '<li>' + hostsToMasterServices[host][j] + '</li>';
- }
- // add manager server
- if (host == this.managerHostName) {
- markup += '<li>' + App.Props.managerServiceName + ' Server</li>';
- }
+ var hostInfo = getNodeInfo(host);
+ markup += '<div class="hostToMasterServices"><h3>' + host + '<span class="hostInfo">' + getTotalMemForDisplay(hostInfo.totalMem) + ', ' + hostInfo.cpuCount + ' cores</span></h3><ul>';
+ for (var j in hostsToMasterServices[host]) {
+ markup += '<li>' + hostsToMasterServices[host][j] + '</li>';
+ }
markup += '</ul><div style="clear:both"></div></div>';
}
$('#hostsToMasterServices').html(markup);
@@ -110,8 +108,8 @@ function AssignMasters() {
var chosenHost = getNodeInfo(chosenHostName);
var markup = '<select name="' + masterName + '">';
markup += '<option selected="selected" value="' + chosenHost.hostName + '">' + getHostInfoForDisplay(chosenHost) + '</option>';
- for (var i in this.allHosts) {
- var host = this.allHosts[i];
+ for (var i in allHosts) {
+ var host = allHosts[i];
if (host.hostName != chosenHost.hostName) {
markup += '<option value="' + host.hostName + '">' + host.hostName + ' - ' + getTotalMemForDisplay(host.totalMem) + ', ' + host.cpuCount + ' cores</option>';
}
@@ -201,8 +199,8 @@ function AssignMasters() {
registeredAssignHostsEventHandlers = true;
}
- this.allHosts = clusterInfo.allHosts;
- this.managerHostName = clusterInfo.managerHostName;
+ allHosts = clusterInfo.allHosts;
+ managerHostName = clusterInfo.managerHostName;
var servicesInfo = globalYui.Array( clusterInfo.services );
var masterServices = {};
@@ -243,7 +241,12 @@ function AssignMasters() {
}
hostsToMasterServices[masterServices[i].host][masterServices[i].name] = masterServices[i].displayName;
}
-
+ // add manager server
+ if (hostsToMasterServices[managerHostName] == null) {
+ hostsToMasterServices[managerHostName] = {};
+ }
+ hostsToMasterServices[managerHostName].MANAGER_SERVER = App.Props.managerServiceName + ' Server';
+
$('#masterServicesToHosts').html(markup);
renderHostsToMasterServices(hostsToMasterServices);
Modified: incubator/ambari/branches/branch-0.9/hmc/js/clustersList.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-0.9/hmc/js/clustersList.js?rev=1357402&r1=1357401&r2=1357402&view=diff
==============================================================================
--- incubator/ambari/branches/branch-0.9/hmc/js/clustersList.js (original)
+++ incubator/ambari/branches/branch-0.9/hmc/js/clustersList.js Wed Jul 4 20:53:26 2012
@@ -19,53 +19,58 @@
*
*/
-function ClustersList() {
-
- var managerHostName;
-
+function ClustersList() {
+
+ var managerHostName = '';
+
function populateHostToMasterRoleMapping(clusterServices, hostMap) {
-
+
+ var hostName;
+
for (var serviceName in clusterServices) {
if (clusterServices.hasOwnProperty(serviceName)) {
-
- if (clusterServices[serviceName].isEnabled == "1" &&
- clusterServices[serviceName].attributes.runnable &&
- !clusterServices[serviceName].attributes.noDisplay) {
-
+
+ if (clusterServices[serviceName].isEnabled == "1" &&
+ clusterServices[serviceName].attributes.runnable &&
+ !clusterServices[serviceName].attributes.noDisplay) {
+
globalYui.Array.each( clusterServices[serviceName].components, function (serviceComponent) {
if (serviceComponent.isMaster) {
// just add the master to the hostname object
for (var i in serviceComponent.hostNames) {
- var hostName = serviceComponent.hostNames[i];
+ hostName = serviceComponent.hostNames[i];
if ( !( hostName in hostMap ) ) {
- hostMap[hostName] = new Array();
- hostMap[hostName].push({ serviceName: serviceComponent.displayName, isMaster: true });
- } else {
- hostMap[hostName].push({ serviceName: serviceComponent.displayName, isMaster: true });
+ hostMap[hostName] = [];
}
+ hostMap[hostName].push({ serviceName: serviceComponent.displayName, isMaster: true });
}
}
});
}
}
}
+ hostName = managerHostName;
+ if (!(hostName in hostMap)) {
+ hostMap[hostName] = [];
+ }
+ hostMap[hostName].push({ serviceName: App.Props.managerServiceName + ' Server', isMaster: true });
}
-
+
function populateHostToClientRoleMapping(clusterServices, hostMap) {
-
+
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) {
+
+ if (clusterServices[serviceName].isEnabled == "1" &&
+ !clusterServices[serviceName].attributes.noDisplay) {
+
+ globalYui.Array.each( clusterServices[serviceName].components, function (serviceComponent) {
if (serviceComponent.isClient) {
// just add the client to the hostname object
for (var i in serviceComponent.hostNames) {
var hostName = serviceComponent.hostNames[i];
if ( !( hostName in hostMap ) ) {
- hostMap[hostName] = new Array();
+ hostMap[hostName] = [];
hostMap[hostName].push({ serviceName: serviceComponent.displayName, isMaster: false });
} else {
hostMap[hostName].push({ serviceName: serviceComponent.displayName, isMaster: false });
@@ -77,40 +82,37 @@ function ClustersList() {
}
}
}
-
+
function generateHostRoleMappingMarkup( clusterServices ) {
-
+
var hostMap = {};
var markup = '';
-
- populateHostToMasterRoleMapping(clusterServices, hostMap);
+
+ populateHostToMasterRoleMapping(clusterServices, hostMap);
populateHostToClientRoleMapping(clusterServices, hostMap);
-
+
markup += '<div>';
for (var hostName in hostMap) {
markup += '<div class="hostToServices clearfix"><h3>' + hostName + '</h3>' + '<ul>';
- if (hostName == managerHostName) {
- markup += '<li class="master">' + App.Props.managerServiceName + ' Server</li>';
- }
for (var service in hostMap[hostName]) {
markup += '<li class="' + ((hostMap[hostName][service].isMaster) ? 'master' : 'client') + '">' + hostMap[hostName][service].serviceName + '</li>';
}
markup += '</ul></div>';
}
markup += '</div>';
-
+
return markup;
}
-
+
this.render = function() {
-
+
globalYui.io("../php/frontend/listClusters.php", {
method: 'GET',
timeout : 10000,
on: {
success: function (x,o) {
globalYui.log("RAW JSON DATA: " + o.responseText);
-
+
// Process the JSON data returned from the server
try {
clusterListInfoJson = globalYui.JSON.parse(o.responseText);
@@ -119,21 +121,21 @@ function ClustersList() {
alert("JSON Parse failed!");
return;
}
-
+
globalYui.log("PARSED DATA: " + globalYui.Lang.dump(clusterListInfoJson));
-
+
if (clusterListInfoJson.result != 0) {
// Error!
- alert("Got error!" + clusterListInfoJson.error);
+ alert("Got error!" + clusterListInfoJson.error);
return;
}
-
- clusterListInfoJson = clusterListInfoJson.response;
+
+ clusterListInfoJson = clusterListInfoJson.response;
var numClusters = clusterListInfoJson.length;
var clustersListMarkup;
var clusterId;
var multipleClustersSupported = false;
-
+
if (numClusters == 0) {
clustersListMarkup = "";
} else {
@@ -141,7 +143,7 @@ function ClustersList() {
clustersListMarkup = "<table>" +
"<caption>List of clusters</caption>" +
"<thead><tr><th>Name of the cluster</th><th>Cluster status</th><th>Actions</th></tr></thead>";
- var i = 0;
+
for (clusterId in clusterListInfoJson) {
clustersListMarkup += "<tr><td><a href='manageServices.php?clusterId=" + clusterId + "' id='existingClusterLinkDivId'>" + clusterId + "</a></td><td>" + clusterListInfoJson[clusterId] + "</td><td>Uninstall</td></tr>" ;
}
@@ -155,25 +157,25 @@ function ClustersList() {
}
}
}
-
+
var newClusterLinkHTML = "";
if (multipleClustersSupported || numClusters == 0) {
document.location.href = "/hmc/html/welcome.php";
return;
}
-
+
/* Beginning of adding Role Topology information. */
globalYui.io( "../php/frontend/fetchClusterServices.php?clusterName=" + clusterName + "&getConfigs=true&getComponents=true", {
timeout: 10000,
on: {
success: function(x1, o1) {
-
+
hideLoadingImg();
-
+
globalYui.log("RAW JSON DATA: " + o1.responseText);
-
+
var clusterServicesResponseJson;
-
+
try {
clusterServicesResponseJson = globalYui.JSON.parse(o1.responseText);
}
@@ -181,27 +183,27 @@ function ClustersList() {
alert("JSON Parse failed");
return;
}
-
+
managerHostName = clusterServicesResponseJson.response.managerHostName;
-
+
globalYui.log(globalYui.Lang.dump(clusterServicesResponseJson));
-
+
/* Check that clusterServicesResponseJson actually indicates success. */
if( clusterServicesResponseJson.result == 0 ) {
-
+
var clusterServices = clusterServicesResponseJson.response.services;
-
+
var markup =
'<div class="clearfix">' +
'<h2>Cluster: ' + clusterName + '</h2>' +
- '<div id="serviceLegend">' +
- '<span class="masterLegend">Master</span><span class="clientLegend" style="margin-right:0">Client</span>' +
- '</div>' +
+ '<div id="serviceLegend">' +
+ '<span class="masterLegend">Master</span><span class="clientLegend" style="margin-right:0">Client</span>' +
+ '</div>' +
'</div>' +
- '</div>';
-
+ '</div>';
+
globalYui.one("#clusterHostRoleMappingDynamicRenderDivId").setContent(
- markup + generateHostRoleMappingMarkup(clusterServices) );
+ markup + generateHostRoleMappingMarkup(clusterServices) );
globalYui.one("#clusterHostRoleMappingDivId").show();
}
else {
@@ -215,18 +217,18 @@ function ClustersList() {
}
});
/* End of adding Role Topology information. */
-
+
globalYui.one("#clustersListDivId").setContent( clustersListMarkup );
globalYui.one("#clustersListDivId").setStyle('display', 'block');
-
+
if (globalYui.one('#newClusterLinkDivId') != null) {
globalYui.one('#newClusterLinkDivId').on('click',function (e) {
/* Done with this stage, hide it. */
globalYui.one("#clustersListDivId").setStyle('display','none');
// globalYui.one("#installationWizardDivId").setStyle('display','block');
- });
+ });
}
-
+
},
failure: function (x,o) {
// e.target.set('disabled', false);