From 022592ae7941607091fa85e4a9e8608ba53f3814 Mon Sep 17 00:00:00 2001 From: Rohith Sharma K S Date: Fri, 3 Aug 2018 13:59:34 +0530 Subject: [PATCH] YARN-8608. [UI2] No information available per application appAttempt about 'Total Outstanding Resource Requests'. Contributed by Akhil PB. --- .../webapp/app/controllers/yarn-app/info.js | 45 +++++++++++++------ .../main/webapp/app/templates/yarn-app.hbs | 11 +++-- .../webapp/app/templates/yarn-app/info.hbs | 19 ++++++-- 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-app/info.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-app/info.js index bd8d50ac025..68954ce173d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-app/info.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-app/info.js @@ -35,16 +35,16 @@ export default Ember.Controller.extend({ Ember.$("#stopServiceConfirmDialog").modal('hide'); var adapter = this.store.adapterFor('yarn-servicedef'); self.set('isLoading', true); - adapter.stopService(this.get('service'), this.get('model.app.user')).then(function() { - self.set('actionResponse', {msg: 'Service stopped successfully. Auto refreshing in 5 seconds.', type: 'success'}); - Ember.run.later(self, function() { + adapter.stopService(this.get('service'), this.get('model.app.user')).then(function () { + self.set('actionResponse', { msg: 'Service stopped successfully. Auto refreshing in 5 seconds.', type: 'success' }); + Ember.run.later(self, function () { this.set('actionResponse', null); this.send("refresh"); }, 5000); - }, function(errr) { + }, function (errr) { let messg = errr.diagnostics || 'Error: Stop service failed!'; - self.set('actionResponse', {msg: messg, type: 'error'}); - }).finally(function() { + self.set('actionResponse', { msg: messg, type: 'error' }); + }).finally(function () { self.set('isLoading', false); }); }, @@ -59,16 +59,16 @@ export default Ember.Controller.extend({ Ember.$("#deleteServiceConfirmDialog").modal('hide'); var adapter = this.store.adapterFor('yarn-servicedef'); self.set('isLoading', true); - adapter.deleteService(this.get('service'), this.get('model.app.user')).then(function() { - self.set('actionResponse', {msg: 'Service deleted successfully. Redirecting to services in 5 seconds.', type: 'success'}); - Ember.run.later(self, function() { + adapter.deleteService(this.get('service'), this.get('model.app.user')).then(function () { + self.set('actionResponse', { msg: 'Service deleted successfully. Redirecting to services in 5 seconds.', type: 'success' }); + Ember.run.later(self, function () { this.set('actionResponse', null); this.transitionToRoute("yarn-services"); }, 5000); - }, function(errr) { + }, function (errr) { let messg = errr.diagnostics || 'Error: Delete service failed!'; - self.set('actionResponse', {msg: messg, type: 'error'}); - }).finally(function() { + self.set('actionResponse', { msg: messg, type: 'error' }); + }).finally(function () { self.set('isLoading', false); }); }, @@ -78,15 +78,32 @@ export default Ember.Controller.extend({ } }, - isRunningService: Ember.computed('model.serviceName', 'model.app.state', function() { + isRunningService: Ember.computed('model.serviceName', 'model.app.state', function () { return this.get('service') !== undefined && this.get('model.app.state') === 'RUNNING'; }), - amHostHttpAddressFormatted: Ember.computed('model.app.amHostHttpAddress', function() { + amHostHttpAddressFormatted: Ember.computed('model.app.amHostHttpAddress', function () { var amHostAddress = this.get('model.app.amHostHttpAddress'); if (amHostAddress && amHostAddress.indexOf('://') < 0) { amHostAddress = 'http://' + amHostAddress; } return amHostAddress; + }), + + totalOutstandingResourceRequests: Ember.computed('model.app.resourceRequests', function() { + const resourceRequests = this.get('model.app.resourceRequests'); + if (resourceRequests) { + const totatResourceRequests = { memory: 0, vCores: 0 }; + [].forEach.call(resourceRequests, resource => { + if (resource.resourceName === '*') { + const totalMemory = resource.capability.resourceInformations.resourceInformation[0].value * resource.numContainers; + const totalVCores = resource.capability.resourceInformations.resourceInformation[1].value * resource.numContainers; + totatResourceRequests.memory += totalMemory; + totatResourceRequests.vCores += totalVCores; + } + }); + return totatResourceRequests; + } + return null; }) }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-app.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-app.hbs index aac93c09383..cb28f82e67d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-app.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-app.hbs @@ -75,8 +75,9 @@