From 3946b6e62ba7a2b93ba0509b36c2b67a6361109e Mon Sep 17 00:00:00 2001 From: Sunil G Date: Wed, 7 Feb 2018 16:07:18 +0530 Subject: [PATCH] YARN-7827 --- .../src/main/webapp/app/adapters/yarn-servicedef.js | 9 ++++++--- .../src/main/webapp/app/components/deploy-service.js | 12 +++++++++--- .../src/main/webapp/app/controllers/yarn-app.js | 4 ++-- .../src/main/webapp/app/controllers/yarn-app/info.js | 4 ++-- .../src/main/webapp/app/controllers/yarn-deploy-service.js | 12 ++++++------ .../main/webapp/app/templates/components/deploy-service.hbs | 10 ++++++++++ .../src/main/webapp/app/templates/yarn-app.hbs | 4 ++-- .../src/main/webapp/app/templates/yarn-app/info.hbs | 4 ++-- .../hadoop-yarn-ui/src/main/webapp/app/utils/info-seeder.js | 3 ++- .../hadoop-yarn-ui/src/main/webapp/config/default-config.js | 2 +- 10 files changed, 42 insertions(+), 22 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-servicedef.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-servicedef.js index 3fb4a818925..03685fb22c7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-servicedef.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-servicedef.js @@ -24,21 +24,24 @@ export default RESTAbstractAdapter.extend({ restNameSpace: "dashService", serverName: "DASH", - deployService(request) { + deployService(request, user) { var url = this.buildURL(); + url += "/?user.name=" + user; return this.ajax(url, "POST", {data: request}); }, - stopService(serviceName) { + stopService(serviceName, user) { var url = this.buildURL(); url += "/" + serviceName; + url += "/?user.name=" + user; var data = {"state": "STOPPED", "name": serviceName}; return this.ajax(url, "PUT", {data: data}); }, - deleteService(serviceName) { + deleteService(serviceName, user) { var url = this.buildURL(); url += "/" + serviceName; + url += "/?user.name=" + user; return this.ajax(url, "DELETE", {data: {}}); } }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/deploy-service.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/deploy-service.js index 90e10e59557..36895d72f1b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/deploy-service.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/deploy-service.js @@ -27,6 +27,7 @@ export default Ember.Component.extend({ customServiceDef: '', serviceResp: null, isLoading: false, + userName: '', actions: { showSaveTemplateModal() { @@ -36,11 +37,11 @@ export default Ember.Component.extend({ deployService() { this.set('serviceResp', null); if (this.get('isStandardViewType')) { - this.sendAction("deployServiceDef", this.get('serviceDef')); + this.sendAction("deployServiceDef", this.get('serviceDef'), this.get('userName')); } else { try { var parsed = JSON.parse(this.get('customServiceDef')); - this.sendAction("deployServiceJson", parsed); + this.sendAction("deployServiceJson", parsed, this.get('userName')); } catch (err) { this.set('serviceResp', {type: 'error', message: 'Invalid JSON: ' + err.message}); throw err; @@ -148,16 +149,21 @@ export default Ember.Component.extend({ isValidTemplateName: Ember.computed.notEmpty('savedTemplateName'), + isUserNameGiven: Ember.computed.empty('userName'), + isValidServiceDef: Ember.computed('serviceDef.name', 'serviceDef.queue', 'serviceDef.serviceComponents.[]', function () { return this.get('serviceDef').isValidServiceDef(); }), isValidCustomServiceDef: Ember.computed.notEmpty('customServiceDef'), - enableSaveOrDeployBtn: Ember.computed('isValidServiceDef', 'isValidCustomServiceDef', 'viewType', 'isLoading', function() { + enableSaveOrDeployBtn: Ember.computed('isValidServiceDef', 'isValidCustomServiceDef', 'viewType', 'isLoading', 'isUserNameGiven', function() { if (this.get('isLoading')) { return false; } + if (this.get('isUserNameGiven')) { + return false; + } if (this.get('isStandardViewType')) { return this.get('isValidServiceDef'); } else { 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 b2b99b14f85..d80f172cde0 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 @@ -43,7 +43,7 @@ export default Ember.Controller.extend({ Ember.$("#stopServiceConfirmDialog").modal('hide'); var adapter = this.store.adapterFor('yarn-servicedef'); self.set('isLoading', true); - adapter.stopService(this.model.serviceName).then(function () { + adapter.stopService(this.model.serviceName, 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); @@ -67,7 +67,7 @@ export default Ember.Controller.extend({ Ember.$("#deleteServiceConfirmDialog").modal('hide'); var adapter = this.store.adapterFor('yarn-servicedef'); self.set('isLoading', true); - adapter.deleteService(this.model.serviceName).then(function () { + adapter.deleteService(this.model.serviceName, 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); 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 3de6687b8d6..bd8d50ac025 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,7 +35,7 @@ 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')).then(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); @@ -59,7 +59,7 @@ 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')).then(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); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-deploy-service.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-deploy-service.js index 25d575fbccb..97cb66ff515 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-deploy-service.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-deploy-service.js @@ -36,13 +36,13 @@ export default Ember.Controller.extend({ isLoading: false, actions: { - deployServiceDef(serviceDef) { + deployServiceDef(serviceDef, userName) { var defjson = serviceDef.getServiceJSON(); - this.deployServiceApp(defjson); + this.deployServiceApp(defjson, userName); }, - deployServiceJson(json) { - this.deployServiceApp(json); + deployServiceJson(json, userName) { + this.deployServiceApp(json, userName); } }, @@ -53,11 +53,11 @@ export default Ember.Controller.extend({ }, 1000); }, - deployServiceApp(requestJson) { + deployServiceApp(requestJson, userName) { var self = this; var adapter = this.store.adapterFor('yarn-servicedef'); this.set('isLoading', true); - adapter.deployService(requestJson).then(function() { + adapter.deployService(requestJson, userName).then(function() { self.set('serviceResponse', {message: 'Service has been accepted successfully. Redirecting to services in a second.', type: 'success'}); self.gotoServices(); }, function(errmsg) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/deploy-service.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/deploy-service.hbs index a098ec3b8fa..720074e0c4c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/deploy-service.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/deploy-service.hbs @@ -29,6 +29,16 @@ {{/if}} +
+
+
+ + + {{input type="text" class="form-control" placeholder="User Name" value=userName}} +
+
+
+
{{#if isLoading}} Loading... 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 d29ec4dbf36..a42dcd353b5 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 @@ -140,12 +140,12 @@ {{confirm-dialog dialogId="stopServiceConfirmDialog" - message=(concat 'Are you sure you want to stop service "' model.serviceName '" ?') + message=(concat 'Are you sure you want to stop service "' model.serviceName '" for user "' model.app.user '" ?') action="stopService" }} {{confirm-dialog dialogId="deleteServiceConfirmDialog" - message=(concat 'Are you sure you want to delete service "' model.serviceName '" ?') + message=(concat 'Are you sure you want to delete service "' model.serviceName '" for user "' model.app.user '" ?') action="deleteService" }} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-app/info.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-app/info.hbs index a4937cc4ba7..beae7d3bafa 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-app/info.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-app/info.hbs @@ -128,12 +128,12 @@ {{confirm-dialog dialogId="stopServiceConfirmDialog" - message=(concat 'Are you sure you want to stop service "' model.serviceName '" ?') + message=(concat 'Are you sure you want to stop service "' model.serviceName '" for user "' model.app.user '" ?') action="stopService" }} {{confirm-dialog dialogId="deleteServiceConfirmDialog" - message=(concat 'Are you sure you want to delete service "' model.serviceName '" ?') + message=(concat 'Are you sure you want to delete service "' model.serviceName '" for user "' model.app.user '" ?') action="deleteService" }} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/utils/info-seeder.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/utils/info-seeder.js index d63b3c56c36..3d013917493 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/utils/info-seeder.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/utils/info-seeder.js @@ -22,5 +22,6 @@ export default { lifetime: "Life time (in seconds) of the application from the time it reaches the STARTED state (after which it is automatically destroyed by YARN). For unlimited lifetime do not set a lifetime value.", components: "One or more components of the application. If the application is HBase say, then the component can be a simple role like master or regionserver. If the application is a complex business webapp then a component can be other applications say Kafka or Storm. Thereby it opens up the support for complex and nested applications.", configurations: "Set of configuration properties that can be injected into the application components via envs, files and custom pluggable helper docker containers. Files of several standard formats like xml, properties, json, yaml and templates will be supported.", - fileConfigs: "Set of file configurations that needs to be created and made available as a volume in an application component container." + fileConfigs: "Set of file configurations that needs to be created and made available as a volume in an application component container.", + userName: "Name of the user who launches the service." }; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js index e916361b5ab..ff95115e907 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js @@ -30,7 +30,7 @@ module.exports = { // YARN UI App configurations cluster: 'ws/v1/cluster', metrics: 'ws/v1/cluster/metrics', timelineV2: 'ws/v2/timeline', - dashService: 'ws/v1/services', + dashService: 'app/v1/services', node: '{nodeAddress}/ws/v1/node' }, }; -- 2.14.3 (Apple Git-98)