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 @@