From 9eb51a3004f6cd379321039dbc142d7e5f6fc415 Mon Sep 17 00:00:00 2001 From: Sunil G Date: Tue, 8 May 2018 10:35:19 +0530 Subject: [PATCH] =?UTF-8?q?YARN-5151.=20[UI2]=20Support=20kill=20applicati?= =?UTF-8?q?on=20from=20new=20YARN=20UI.=20Contributed=20by=20Gergely=20Nov?= =?UTF-8?q?=C3=A1k.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 9832265e1deeefaa6d58f9f62052c8ef6a8e82b7) --- .../src/main/webapp/app/adapters/yarn-app.js | 13 ++++++- .../main/webapp/app/controllers/yarn-app.js | 35 ++++++++++++++++++ .../main/webapp/app/templates/yarn-app.hbs | 37 +++++++++++++++---- 3 files changed, 76 insertions(+), 9 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app.js index 111e468f9cc..d29dff460d5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-app.js @@ -16,9 +16,9 @@ * limitations under the License. */ -import AbstractAdapter from './abstract'; +import RESTAbstractAdapter from './restabstract'; -export default AbstractAdapter.extend({ +export default RESTAbstractAdapter.extend({ address: "rmWebAddress", restNameSpace: "cluster", serverName: "RM", @@ -38,4 +38,13 @@ export default AbstractAdapter.extend({ pathForType(/*modelName*/) { return 'apps'; // move to some common place, return path by modelname. }, + + sendKillApplication(id) { + var url = this._buildURL(); + url += '/apps/' + id + '/state'; + var data = { + "state": "KILLED" + }; + return this.ajax(url, "PUT", { data: data }); + } }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-app.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-app.js index d80f172cde0..45201a1e7f5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-app.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-app.js @@ -81,6 +81,33 @@ export default Ember.Controller.extend({ }); }, + showKillApplicationConfirm() { + this.set('actionResponse', null); + Ember.$("#killApplicationConfirmDialog").modal('show'); + }, + + killApplication() { + var self = this; + Ember.$("#killApplicationConfirmDialog").modal('hide'); + const adapter = this.store.adapterFor('yarn-app'); + self.set('isLoading', true); + adapter.sendKillApplication(this.model.app.id).then(function () { + self.set('actionResponse', { + msg: 'Application killed successfully. Auto refreshing in 5 seconds.', + type: 'success' + }); + Ember.run.later(self, function () { + this.set('actionResponse', null); + this.send("refresh"); + }, 5000); + }, function (err) { + let message = err.diagnostics || 'Error: Kill application failed!'; + self.set('actionResponse', { msg: message, type: 'error' }); + }).finally(function () { + self.set('isLoading', false); + }); + }, + resetActionResponse() { this.set('actionResponse', null); } @@ -125,5 +152,13 @@ export default Ember.Controller.extend({ amHostAddress = 'http://' + amHostAddress; } return amHostAddress; + }), + + isKillable: Ember.computed("model.app.state", function () { + if (this.get("model.app.applicationType") === 'yarn-service') { + return false; + } + const killableStates = ['NEW', 'NEW_SAVING', 'SUBMITTED', 'ACCEPTED', 'RUNNING']; + return killableStates.indexOf(this.get("model.app.state")) > -1; }) }); 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 62e9350a081..156f83c42e4 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 @@ -18,6 +18,15 @@ {{breadcrumb-bar breadcrumbs=breadcrumbs}} +{{#if actionResponse}} +
+ +
+{{/if}} +
@@ -64,18 +73,26 @@