Repository: ambari Updated Branches: refs/heads/trunk d5b830d39 -> 4a11ff281
AMBARI-6037. Load public host names for Quick Links. (Max Shepel via akovalenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4a11ff28 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4a11ff28 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4a11ff28 Branch: refs/heads/trunk Commit: 4a11ff281fac6f8dc36e4fdac57d09a4365a9368 Parents: d5b830d Author: Aleksandr Kovalenko <[email protected]> Authored: Thu Jun 5 19:59:45 2014 +0300 Committer: Aleksandr Kovalenko <[email protected]> Committed: Thu Jun 5 20:01:48 2014 +0300 ---------------------------------------------------------------------- .../controllers/global/cluster_controller.js | 115 ++++++++++--------- .../main/dashboard/widgets/hbase_links.hbs | 34 +++--- .../main/dashboard/widgets/hdfs_links.hbs | 32 +++--- .../main/dashboard/widgets/mapreduce_links.hbs | 34 +++--- ambari-web/app/templates/main/host/summary.hbs | 6 +- .../app/templates/main/service/info/summary.hbs | 12 +- ambari-web/app/templates/main/service/item.hbs | 34 +++--- ambari-web/app/utils/ajax/ajax.js | 4 + .../app/views/common/quick_view_link_view.js | 48 +++++--- 9 files changed, 191 insertions(+), 128 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/4a11ff28/ambari-web/app/controllers/global/cluster_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js index 8f609d4..76bc5ca 100644 --- a/ambari-web/app/controllers/global/cluster_controller.js +++ b/ambari-web/app/controllers/global/cluster_controller.js @@ -29,6 +29,25 @@ App.ClusterController = Em.Controller.extend({ * Whether we need to update statuses automatically or not */ isWorking: false, + isGangliaUrlLoaded: false, + isNagiosUrlLoaded: false, + + /** + * Provides the URL to use for Ganglia server. This URL + * is helpful in populating links in UI. + * + * If null is returned, it means GANGLIA service is not installed. + */ + gangliaUrl: null, + + /** + * Provides the URL to use for NAGIOS server. This URL + * is helpful in getting alerts data from server and also + * in populating links in UI. + * + * If null is returned, it means NAGIOS service is not installed. + */ + nagiosUrl: null, updateLoadStatus: function (item) { var loadList = this.get('dataLoadList'); var loaded = true; @@ -130,71 +149,63 @@ App.ClusterController = Em.Controller.extend({ return (App.testMode) ? testUrl : App.apiPrefix + '/clusters/' + this.get('clusterName') + url; }, - /** - * Provides the URL to use for Ganglia server. This URL - * is helpful in populating links in UI. - * - * If null is returned, it means GANGLIA service is not installed. - */ - gangliaUrl: function () { + setGangliaUrl: function () { if (App.testMode) { return 'http://gangliaserver/ganglia/?t=yes'; } else { // We want live data here - var svcs = App.Service.find(); - var gangliaSvc = svcs.findProperty("serviceName", "GANGLIA"); - if (gangliaSvc) { - var svcComponents = gangliaSvc.get('hostComponents'); - if (svcComponents) { - var gangliaSvcComponent = svcComponents.findProperty("componentName", "GANGLIA_SERVER"); - if (gangliaSvcComponent) { - var hostName = gangliaSvcComponent.get('host.hostName'); - if (hostName) { - var host = App.Host.find(hostName); - if (host) { - hostName = host.get('publicHostName'); - } - return this.get('gangliaWebProtocol') + "://" + (App.singleNodeInstall ? App.singleNodeAlias + ":42080" : hostName) + "/ganglia"; - } - } - } + if (this.get('isLoaded')) { + this.set('isGangliaUrlLoaded', true); + App.ajax.send({ + name: 'hosts.for_quick_links', + sender: this, + data: { + clusterName: App.get('clusterName'), + masterComponents: 'GANGLIA_SERVER' + }, + success: 'setGangliaUrlSuccessCallback' + }); } - return null; } - }.property('App.router.updateController.isUpdated', 'dataLoadList.hosts', 'gangliaWebProtocol'), + }.observes('App.router.updateController.isUpdated', 'dataLoadList.hosts', 'gangliaWebProtocol', 'isLoaded'), - /** - * Provides the URL to use for NAGIOS server. This URL - * is helpful in getting alerts data from server and also - * in populating links in UI. - * - * If null is returned, it means NAGIOS service is not installed. - */ - nagiosUrl: function () { + setGangliaUrlSuccessCallback: function (response) { + var url = null; + if (response.items.length > 0) { + url = this.get('gangliaWebProtocol') + "://" + (App.singleNodeInstall ? App.singleNodeAlias + ":42080" : response.items[0].Hosts.public_host_name) + "/ganglia"; + } + this.set('gangliaUrl', url); + this.set('isGangliaUrlLoaded', true); + }, + + setNagiosUrl: function () { if (App.testMode) { return 'http://nagiosserver/nagios'; } else { // We want live data here - var nagiosSvc = App.Service.find("NAGIOS"); - if (nagiosSvc) { - var svcComponents = nagiosSvc.get('hostComponents'); - if (svcComponents) { - var nagiosSvcComponent = svcComponents.findProperty("componentName", "NAGIOS_SERVER"); - if (nagiosSvcComponent) { - var hostName = nagiosSvcComponent.get('host.hostName'); - if (hostName) { - var host = App.Host.find(hostName); - if (host) { - hostName = host.get('publicHostName'); - } - return this.get('nagiosWebProtocol') + "://" + (App.singleNodeInstall ? App.singleNodeAlias + ":42080" : hostName) + "/nagios"; - } - } - } + if (this.get('isLoaded')) { + this.set('isNagiosUrlLoaded', false); + App.ajax.send({ + name: 'hosts.for_quick_links', + sender: this, + data: { + clusterName: App.get('clusterName'), + masterComponents: 'NAGIOS_SERVER' + }, + success: 'setNagiosUrlSuccessCallback' + }); } - return null; } - }.property('App.router.updateController.isUpdated', 'dataLoadList.serviceMetrics', 'dataLoadList.hosts', 'nagiosWebProtocol'), + }.observes('App.router.updateController.isUpdated', 'dataLoadList.serviceMetrics', 'dataLoadList.hosts', 'nagiosWebProtocol', 'isLoaded'), + + setNagiosUrlSuccessCallback: function (response) { + var url = null; + if (response.items.length > 0) { + url = this.get('nagiosWebProtocol') + "://" + (App.singleNodeInstall ? App.singleNodeAlias + ":42080" : response.items[0].Hosts.public_host_name) + "/nagios"; + } + this.set('nagiosUrl', url); + this.set('isNagiosUrlLoaded', true); + }, nagiosWebProtocol: function () { var properties = this.get('ambariProperties'); http://git-wip-us.apache.org/repos/asf/ambari/blob/4a11ff28/ambari-web/app/templates/main/dashboard/widgets/hbase_links.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/dashboard/widgets/hbase_links.hbs b/ambari-web/app/templates/main/dashboard/widgets/hbase_links.hbs index 10ab753..d7501f4 100644 --- a/ambari-web/app/templates/main/dashboard/widgets/hbase_links.hbs +++ b/ambari-web/app/templates/main/dashboard/widgets/hbase_links.hbs @@ -60,22 +60,26 @@ <span class="caret"></span> </a> <ul class="dropdown-menu"> - {{#if view.quickLinksArray}} - <!--there are multiple masters eg, HBase multiple masters or HDFS HA enabled--> - {{#each quickLinks in view.quickLinksArray}} - <li class="dropdown-submenu"> - <a href="javascript:void(null)">{{quickLinks.publicHostNameLabel}} </a> - <ul class="dropdown-menu"> - {{#each quickLinks}} - <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li> - {{/each}} - </ul> - </li> - {{/each}} - {{else}} - {{#each view.quickLinks}} + {{#if view.isLoaded}} + {{#if view.quickLinksArray}} + <!--there are multiple masters eg, HBase multiple masters or HDFS HA enabled--> + {{#each quickLinks in view.quickLinksArray}} + <li class="dropdown-submenu"> + <a href="javascript:void(null)">{{quickLinks.publicHostNameLabel}} </a> + <ul class="dropdown-menu"> + {{#each quickLinks}} + <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li> + {{/each}} + </ul> + </li> + {{/each}} + {{else}} + {{#each view.quickLinks}} <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li> - {{/each}} + {{/each}} + {{/if}} + {{else}} + <div class="spinner"></div> {{/if}} </ul> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/4a11ff28/ambari-web/app/templates/main/dashboard/widgets/hdfs_links.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/dashboard/widgets/hdfs_links.hbs b/ambari-web/app/templates/main/dashboard/widgets/hdfs_links.hbs index 5b5100b..98340a2 100644 --- a/ambari-web/app/templates/main/dashboard/widgets/hdfs_links.hbs +++ b/ambari-web/app/templates/main/dashboard/widgets/hdfs_links.hbs @@ -86,22 +86,26 @@ <span class="caret"></span> </a> <ul class="dropdown-menu"> - {{#if view.quickLinksArray}} + {{#if view.isLoaded}} + {{#if view.quickLinksArray}} <!--there are multiple masters eg, HBase multiple masters or HDFS HA enabled--> - {{#each quickLinks in view.quickLinksArray}} - <li class="dropdown-submenu"> - <a href="javascript:void(null)">{{quickLinks.publicHostNameLabel}} </a> - <ul class="dropdown-menu"> - {{#each quickLinks}} - <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li> - {{/each}} - </ul> - </li> - {{/each}} - {{else}} - {{#each view.quickLinks}} + {{#each quickLinks in view.quickLinksArray}} + <li class="dropdown-submenu"> + <a href="javascript:void(null)">{{quickLinks.publicHostNameLabel}} </a> + <ul class="dropdown-menu"> + {{#each quickLinks}} + <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li> + {{/each}} + </ul> + </li> + {{/each}} + {{else}} + {{#each view.quickLinks}} <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li> - {{/each}} + {{/each}} + {{/if}} + {{else}} + <div class="spinner"></div> {{/if}} </ul> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/4a11ff28/ambari-web/app/templates/main/dashboard/widgets/mapreduce_links.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/dashboard/widgets/mapreduce_links.hbs b/ambari-web/app/templates/main/dashboard/widgets/mapreduce_links.hbs index abb9da1..85365e7 100644 --- a/ambari-web/app/templates/main/dashboard/widgets/mapreduce_links.hbs +++ b/ambari-web/app/templates/main/dashboard/widgets/mapreduce_links.hbs @@ -42,21 +42,25 @@ </div> <div class="link-button"> - {{#if view.model.quickLinks.length}} - {{#view App.QuickViewLinks contentBinding="view.model"}} - <div class="btn-group"> - <a class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#"> - {{t common.more}} - <span class="caret"></span> - </a> - <ul class="dropdown-menu"> - {{#each view.quickLinks}} - <li><a {{bindAttr href="url"}} target="_blank">{{label}}</a></li> - {{/each}} - </ul> - </div> - {{/view}} - {{/if}} + {{#if view.model.quickLinks.length}} + {{#view App.QuickViewLinks contentBinding="view.model"}} + {{#if view.isLoaded}} + <div class="btn-group"> + <a class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#"> + {{t common.more}} + <span class="caret"></span> + </a> + <ul class="dropdown-menu"> + {{#each view.quickLinks}} + <li><a {{bindAttr href="url"}} target="_blank">{{label}}</a></li> + {{/each}} + </ul> + </div> + {{else}} + <div class="spinner"></div> + {{/if}} + {{/view}} + {{/if}} </div> </li> </ul> http://git-wip-us.apache.org/repos/asf/ambari/blob/4a11ff28/ambari-web/app/templates/main/host/summary.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/summary.hbs b/ambari-web/app/templates/main/host/summary.hbs index f34b15d..49e2909 100644 --- a/ambari-web/app/templates/main/host/summary.hbs +++ b/ambari-web/app/templates/main/host/summary.hbs @@ -131,7 +131,11 @@ <div class="box-header"> <h4>{{t hosts.host.summary.hostMetrics}}</h4> <div class="btn-group"> - <a class="btn" rel="tooltip" title="Go to Ganglia" {{action "showGangliaCharts" target="view"}}><i class="icon-link"></i></a> + {{#if App.router.clusterController.isGangliaUrlLoaded}} + <a class="btn" rel="tooltip" title="Go to Ganglia" {{action "showGangliaCharts" target="view"}}><i class="icon-link"></i></a> + {{else}} + <div class="spinner"></div> + {{/if}} </div> </div> <div> http://git-wip-us.apache.org/repos/asf/ambari/blob/4a11ff28/ambari-web/app/templates/main/service/info/summary.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/service/info/summary.hbs b/ambari-web/app/templates/main/service/info/summary.hbs index f1bd71e..5b4b4ee 100644 --- a/ambari-web/app/templates/main/service/info/summary.hbs +++ b/ambari-web/app/templates/main/service/info/summary.hbs @@ -93,7 +93,11 @@ <h4>{{t services.alerts.headingOfList}}</h4> {{#if controller.isNagiosInstalled}} <div class="btn-group"> - <a class="btn" target="_blank" rel="tooltip" title="Go to Nagios" {{bindAttr href="controller.nagiosUrl"}}><i class="icon-link"></i></a> + {{#if App.router.clusterController.isNagiosUrlLoaded}} + <a class="btn" target="_blank" rel="tooltip" title="Go to Nagios" {{bindAttr href="controller.nagiosUrl"}}><i class="icon-link"></i></a> + {{else}} + <div class="spinner"></div> + {{/if}} </div> {{/if}} </div> @@ -161,7 +165,11 @@ <h4>{{controller.content.label}} {{t common.metrics}}</h4> {{#if controller.isGangliaInstalled}} <div class="btn-group"> - <a class="btn" target="_blank" rel="tooltip" title="Go to Ganglia" {{bindAttr href="view.gangliaUrl"}}><i class="icon-link"></i></a> + {{#if App.router.clusterController.isGangliaUrlLoaded}} + <a class="btn" target="_blank" rel="tooltip" title="Go to Ganglia" {{bindAttr href="view.gangliaUrl"}}><i class="icon-link"></i></a> + {{else}} + <div class="spinner"></div> + {{/if}} </div> {{/if}} </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/4a11ff28/ambari-web/app/templates/main/service/item.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/service/item.hbs b/ambari-web/app/templates/main/service/item.hbs index 1ba484e..1fd017a 100644 --- a/ambari-web/app/templates/main/service/item.hbs +++ b/ambari-web/app/templates/main/service/item.hbs @@ -24,22 +24,26 @@ <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">{{t common.quickLinks}}<b class="caret"></b></a> <ul class="dropdown-menu"> - {{#if view.quickLinksArray}} - <!--there are multiple masters eg, HBase multiple masters or HDFS HA enabled--> - {{#each quickLinks in view.quickLinksArray}} - <li class="dropdown-submenu"> - <a href="javascript:void(null)">{{quickLinks.publicHostNameLabel}} </a> - <ul class="dropdown-menu"> - {{#each quickLinks}} - <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li> - {{/each}} - </ul> - </li> - {{/each}} + {{#if view.isLoaded}} + {{#if view.quickLinksArray}} + <!--there are multiple masters eg, HBase multiple masters or HDFS HA enabled--> + {{#each quickLinks in view.quickLinksArray}} + <li class="dropdown-submenu"> + <a href="javascript:void(null)">{{quickLinks.publicHostNameLabel}} </a> + <ul class="dropdown-menu"> + {{#each quickLinks}} + <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li> + {{/each}} + </ul> + </li> + {{/each}} + {{else}} + {{#each view.quickLinks}} + <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li> + {{/each}} + {{/if}} {{else}} - {{#each view.quickLinks}} - <li><a {{bindAttr href="url"}} {{bindAttr target="view.linkTarget"}}>{{label}}</a></li> - {{/each}} + <div class="spinner"></div> {{/if}} </ul> </li> http://git-wip-us.apache.org/repos/asf/ambari/blob/4a11ff28/ambari-web/app/utils/ajax/ajax.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js index b46b76a..3bc98c3 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -2135,6 +2135,10 @@ var urls = { 'real': '/clusters/{clusterName}/hosts?fields=Hosts/public_host_name&minimal_response=true', 'mock': '' }, + 'hosts.for_quick_links': { + 'real': '/clusters/{clusterName}/hosts?host_components/HostRoles/component_name.in({masterComponents})&fields=Hosts/public_host_name,host_components&minimal_response=true', + 'mock': '' + }, 'hosts.confirmed.install': { 'real': '/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true', 'mock': '' http://git-wip-us.apache.org/repos/asf/ambari/blob/4a11ff28/ambari-web/app/views/common/quick_view_link_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/quick_view_link_view.js b/ambari-web/app/views/common/quick_view_link_view.js index e07e35e..a70cd8b 100644 --- a/ambari-web/app/views/common/quick_view_link_view.js +++ b/ambari-web/app/views/common/quick_view_link_view.js @@ -21,6 +21,8 @@ var stringUtils = require('utils/string_utils'); App.QuickViewLinks = Em.View.extend({ + isLoaded: false, + loadTags: function () { App.ajax.send({ name: 'config.tags.sync', @@ -73,12 +75,25 @@ App.QuickViewLinks = Em.View.extend({ this.setQuickLinks(); }, - findComponentHost: function (componentName) { - var components = this.get('content.hostComponents'); - return App.singleNodeInstall ? App.singleNodeAlias : components.findProperty('componentName', componentName).get('host.publicHostName') + findComponentHost: function (components, componentName) { + return App.singleNodeInstall ? App.singleNodeAlias : components.find(function (item) { + return item.host_components.mapProperty('HostRoles.component_name').contains(componentName); + }).Hosts.public_host_name }, setQuickLinks: function () { + App.ajax.send({ + name: 'hosts.for_quick_links', + sender: this, + data: { + clusterName: App.get('clusterName'), + masterComponents: App.StackServiceComponent.find().filterProperty('isMaster', true).mapProperty('componentName').join(',') + }, + success: 'setQuickLinksSuccessCallback' + }); + }.observes('App.currentStackVersionNumber', 'App.singleNodeInstall'), + + setQuickLinksSuccessCallback: function (response) { this.loadTags(); var serviceName = this.get('content.serviceName'); var components = this.get('content.hostComponents'); @@ -91,12 +106,14 @@ App.QuickViewLinks = Em.View.extend({ var otherHost; if (this.get('content.snameNode')) { // not HA - hosts[0] = this.findComponentHost('NAMENODE'); + hosts[0] = this.findComponentHost(response.items, 'NAMENODE'); } else { // HA enabled, need both two namenodes hosts - var nameNodes = components.filterProperty('componentName', 'NAMENODE'); + var nameNodes = response.items.filter(function (item) { + return item.host_components.mapProperty('HostRoles.component_name').contains('NAMENODE'); + }); nameNodes.forEach(function(item) { - hosts.push({'publicHostName': item.get('host.publicHostName')}); + hosts.push({'publicHostName': item.Hosts.public_host_name}); }); // assign each namenode status label if (this.get('content.activeNameNode')) { @@ -132,17 +149,17 @@ App.QuickViewLinks = Em.View.extend({ // need all hbase_masters hosts in quick links if (activeMaster) { activeMaster.forEach(function(item) { - hosts.push({'publicHostName': item.get('host.publicHostName'), 'status': Em.I18n.t('quick.links.label.active')}); + hosts.push({'publicHostName': response.items.mapProperty('Hosts').findProperty('host_name', item.get('host.hostName')).public_host_name, 'status': Em.I18n.t('quick.links.label.active')}); }); } if (standbyMasters) { standbyMasters.forEach(function(item) { - hosts.push({'publicHostName': item.get('host.publicHostName'), 'status': Em.I18n.t('quick.links.label.standby')}); + hosts.push({'publicHostName': response.items.mapProperty('Hosts').findProperty('host_name', item.get('host.hostName')).public_host_name, 'status': Em.I18n.t('quick.links.label.standby')}); }); } if (otherMasters) { otherMasters.forEach(function(item) { - hosts.push({'publicHostName': item.get('host.publicHostName')}); + hosts.push({'publicHostName': response.items.mapProperty('Hosts').findProperty('host_name', item.get('host.hostName')).public_host_name}); }); } } else { @@ -151,16 +168,16 @@ App.QuickViewLinks = Em.View.extend({ } break; case "YARN": - hosts[0] = this.findComponentHost('RESOURCEMANAGER'); + hosts[0] = this.findComponentHost(response.items, 'RESOURCEMANAGER'); break; case "MAPREDUCE2": - hosts[0] = this.findComponentHost('HISTORYSERVER'); + hosts[0] = this.findComponentHost(response.items, 'HISTORYSERVER'); break; case "FALCON": - hosts[0] = this.findComponentHost('FALCON_SERVER'); + hosts[0] = this.findComponentHost(response.items, 'FALCON_SERVER'); break; case "STORM": - hosts[0] = this.findComponentHost('STORM_UI_SERVER'); + hosts[0] = this.findComponentHost(response.items, 'STORM_UI_SERVER'); break; } if (!hosts) { @@ -171,6 +188,7 @@ App.QuickViewLinks = Em.View.extend({ } ]; this.set('quickLinks', quickLinks); + this.set('isLoaded', true); } else if (hosts.length == 1) { quickLinks = this.get('content.quickLinks').map(function (item) { @@ -182,6 +200,7 @@ App.QuickViewLinks = Em.View.extend({ return item; }); this.set('quickLinks', quickLinks); + this.set('isLoaded', true); } else { // multiple hbase masters or HDFS HA enabled var quickLinksArray = []; @@ -207,7 +226,8 @@ App.QuickViewLinks = Em.View.extend({ this.set('quickLinksArray', quickLinksArray); } - }.observes('App.currentStackVersionNumber', 'App.singleNodeInstall'), + + }, setProtocol: function (service_id) { var properties = this.ambariProperties();
