Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F383B114AE for ; Fri, 19 Sep 2014 17:19:10 +0000 (UTC) Received: (qmail 75593 invoked by uid 500); 19 Sep 2014 17:19:10 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 75497 invoked by uid 500); 19 Sep 2014 17:19:10 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 75421 invoked by uid 99); 19 Sep 2014 17:19:10 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Sep 2014 17:19:10 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9581F935C42; Fri, 19 Sep 2014 17:19:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jonathanhurley@apache.org To: commits@ambari.apache.org Date: Fri, 19 Sep 2014 17:19:23 -0000 Message-Id: <797016d73064445d88602deddb36ef5a@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [15/29] git commit: AMBARI-7400. Slider View: Most view parameters should be made required. (onechiporenko) AMBARI-7400. Slider View: Most view parameters should be made required. (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d62147ed Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d62147ed Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d62147ed Branch: refs/heads/branch-alerts-dev Commit: d62147ed37864f7f9f321448c3036ade0eeb681f Parents: d7b09b6 Author: Oleg Nechiporenko Authored: Fri Sep 19 13:13:34 2014 +0300 Committer: Oleg Nechiporenko Committed: Fri Sep 19 13:13:34 2014 +0300 ---------------------------------------------------------------------- .../app/assets/data/resource/cluster_name.json | 12 - .../assets/data/resource/components_hosts.json | 16 - .../ui/app/assets/data/resource/empty_json.json | 1 + .../assets/data/resource/service_configs.json | 38 - .../assets/data/resource/service_status.json | 95 -- .../assets/data/resource/slider-properties.json | 7 +- .../createAppWizard/step1_controller.js | 90 +- .../ui/app/controllers/slider_controller.js | 308 +--- .../src/main/resources/ui/app/helpers/ajax.js | 119 +- .../src/main/resources/ui/app/initialize.js | 9 +- .../ui/app/mappers/slider_apps_mapper.js | 7 + .../resources/ui/app/models/slider_config.js | 51 + .../src/main/resources/ui/app/routes/main.js | 16 + .../resources/ui/app/templates/application.hbs | 4 +- .../ui/app/templates/slider_title_tooltip.hbs | 2 +- .../src/main/resources/ui/app/translations.js | 7 +- .../resources/ui/app/views/application_view.js | 13 +- .../slider/src/main/resources/ui/config.js | 1 + .../resources/ui/vendor/scripts/common/tv4.js | 1605 ++++++++++++++++++ .../views/slider/src/main/resources/view.xml | 21 +- 20 files changed, 1815 insertions(+), 607 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/cluster_name.json ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/cluster_name.json b/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/cluster_name.json deleted file mode 100644 index f559483..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/cluster_name.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "href" : "http://162.216.151.215:8080/api/v1/clusters?_=1409232826826", - "items" : [ - { - "href" : "http://162.216.151.215:8080/api/v1/clusters/mycluster", - "Clusters" : { - "cluster_name" : "mycluster", - "version" : "HDP-2.1" - } - } - ] -} http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/components_hosts.json ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/components_hosts.json b/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/components_hosts.json deleted file mode 100644 index eaf72b4..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/components_hosts.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "items" : [ - { - "Hosts" : { - "host_name" : "myHost" - }, - "host_components" : [ - { - "HostRoles" : { - "component_name" : "" - } - } - ] - } - ] -} http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/empty_json.json ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/empty_json.json b/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/empty_json.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/empty_json.json @@ -0,0 +1 @@ +{} http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/service_configs.json ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/service_configs.json b/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/service_configs.json deleted file mode 100644 index 24c1a31..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/service_configs.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "items" : [ - { - "cluster_name" : "cl", - "configurations" : [ - { - "Config" : { - "cluster_name" : "cl" - }, - "type" : "ganglia-env", - "tag" : "version1410432304443", - "version" : 1, - "properties" : { - "rrdcached_timeout" : "3600", - "gmetad_user" : "nobody", - "rrdcached_base_dir" : "/var/lib/ganglia/rrds", - "rrdcached_write_threads" : "4", - "rrdcached_delay" : "1800", - "rrdcached_flush_timeout" : "7200", - "gmond_user" : "nobody", - "ganglia_runtime_dir" : "/var/run/ganglia/hdp", - "additional_clusters": "'HBaseCluster1','7000','AccumuloCluster1','7001','HBaseCluster2','7002'" - }, - "properties_attributes" : { } - } - ], - "createtime" : 1410432307174, - "group_id" : -1, - "group_name" : "default", - "hosts" : [ ], - "is_current" : true, - "service_config_version" : 1, - "service_config_version_note" : "Initial configurations for Ganglia", - "service_name" : "GANGLIA", - "user" : "admin" - } - ] -} http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/service_status.json ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/service_status.json b/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/service_status.json deleted file mode 100644 index 861f7cd..0000000 --- a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/service_status.json +++ /dev/null @@ -1,95 +0,0 @@ - -{ - "items" : [ - { - "ServiceInfo" : { - "service_name" : "FALCON", - "state" : "STARTED" - } - }, - { - "ServiceInfo" : { - "service_name" : "FLUME", - "state" : "STARTED" - } - }, - { - "ServiceInfo" : { - "service_name" : "GANGLIA", - "state" : "STARTED" - } - }, - { - "ServiceInfo" : { - "service_name" : "HBASE", - "state" : "STARTED" - } - }, - { - "ServiceInfo" : { - "service_name" : "HDFS", - "state" : "STARTED" - } - }, - { - "ServiceInfo" : { - "service_name" : "HIVE", - "state" : "INSTALLED" - } - }, - { - "ServiceInfo" : { - "service_name" : "MAPREDUCE2", - "state" : "STARTED" - } - }, - { - "ServiceInfo" : { - "service_name" : "NAGIOS", - "state" : "STARTED" - } - }, - { - "ServiceInfo" : { - "service_name" : "OOZIE", - "state" : "STARTED" - } - }, - { - "ServiceInfo" : { - "service_name" : "PIG", - "state" : "INSTALLED" - } - }, - { - "ServiceInfo" : { - "service_name" : "SQOOP", - "state" : "INSTALLED" - } - }, - { - "ServiceInfo" : { - "service_name" : "STORM", - "state" : "STARTED" - } - }, - { - "ServiceInfo" : { - "service_name" : "TEZ", - "state" : "INSTALLED" - } - }, - { - "ServiceInfo" : { - "service_name" : "YARN", - "state" : "STARTED" - } - }, - { - "ServiceInfo" : { - "service_name" : "ZOOKEEPER", - "state" : "STARTED" - } - } - ] -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/slider-properties.json ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/slider-properties.json b/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/slider-properties.json index 53a3331..c9b0781 100644 --- a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/slider-properties.json +++ b/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/slider-properties.json @@ -16,7 +16,10 @@ "hdfs.address" : "hdfs://slider-1.c.pramod-thangali.internal:8020", "yarn.resourcemanager.address" : "slider-2.c.pramod-thangali.internal:8050", "yarn.resourcemanager.scheduler.address" : "slider-2.c.pramod-thangali.internal:8030", - "zookeeper.quorum" : "slider-1.c.pramod-thangali.internal:2181,slider-2.c.pramod-thangali.internal:2181,slider-3.c.pramod-thangali.internal:2181" + "zookeeper.quorum" : "slider-1.c.pramod-thangali.internal:2181,slider-2.c.pramod-thangali.internal:2181,slider-3.c.pramod-thangali.internal:2181", + "ganglia.server.hostname" : "bvc", + "ganglia.custom.clusters" : "'HBaseCluster1','7000','AccumuloCluster1','7001','HBaseCluster2','7002'", + "slider.user" : "John Dow" } }, "resources" : [ @@ -61,4 +64,4 @@ "view_name" : "SLIDER" } ] -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js index 8583443..c04b7b3 100644 --- a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js +++ b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js @@ -81,81 +81,37 @@ App.CreateAppWizardStep1Controller = Ember.Controller.extend({ * @method loadStep */ loadStep: function () { - this.loadGangliaHost(); - this.loadGangliaClusters(); + var sliderConfigs = App.SliderApp.store.all('sliderConfig'), + gangliaClusters = sliderConfigs.findBy('viewConfigName', 'ganglia.custom.clusters'), + gangliaHost = sliderConfigs.findBy('viewConfigName', 'ganglia.server.hostname'); + App.set('gangliaClusters', this.formatGangliaClusters(gangliaClusters.get('value'))); + App.set('gangliaHost', gangliaHost.get('value')); this.initializeNewApp(); this.loadAvailableTypes(); }, /** - * Load ganglia server host - * @method loadGangliaHost + * Format value for gangliaClusters + * @param {string} prop + * @returns {Array} + * @method formatGangliaClusters */ - loadGangliaHost: function () { - return App.ajax.send({ - name: 'components_hosts', - sender: this, - data: { - componentName: "GANGLIA_SERVER", - urlPrefix: '/api/v1/' - }, - success: 'loadGangliaHostSuccessCallback' - }); - }, - - /** - * Success callback for hosts-request - * Save host name to gangliaHost - * @param {Object} data - * @method loadGangliaHostSuccessCallback - */ - loadGangliaHostSuccessCallback: function (data) { - if(data.items[0]){ - App.set('gangliaHost', Em.get(data.items[0], 'Hosts.host_name')); - } - }, - - /** - * Load ganglia clusters - * @method loadGangliaClusters - */ - loadGangliaClusters: function () { - return App.ajax.send({ - name: 'service_current_configs', - sender: this, - data: { - serviceName: "GANGLIA", - urlPrefix: '/api/v1/' - }, - success: 'loadGangliaClustersSuccessCallback' - }); - }, - - /** - * Success callback for config property - * Save cluster to gangliaClusters - * @param {Object} data - * @method loadGangliaClustersSuccessCallback - */ - loadGangliaClustersSuccessCallback: function (data) { + formatGangliaClusters: function(prop) { var gangliaCustomClusters = []; - - if (data.items[0]) { - var prop = Em.get(data.items[0].configurations[0].properties, 'additional_clusters'); - if (prop) { - //parse CSV string with cluster names and ports - prop.replace(/\'/g, "").split(',').forEach(function(item, index){ - if (index % 2 === 0) { - gangliaCustomClusters.push({ - name: item - }) - } else { - gangliaCustomClusters[gangliaCustomClusters.length - 1].port = parseInt(item); - } - }); - App.set('gangliaClusters', gangliaCustomClusters); - } + //parse CSV string with cluster names and ports + if (!Em.isNone(prop)) { + prop.replace(/\'/g, "").split(',').forEach(function(item, index){ + if (index % 2 === 0) { + gangliaCustomClusters.push({ + name: item + }) + } + else { + gangliaCustomClusters[gangliaCustomClusters.length - 1].port = parseInt(item); + } + }); } + return gangliaCustomClusters; }, /** http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js index eb2762e..401c86d 100644 --- a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js +++ b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js @@ -17,55 +17,11 @@ */ /** - * Checks Slider-properties. - * If they are not available, uses Ambari-configs to populate them: - * - Load cluster name - * - Load hostName for GANGLIA_SERVER - * - Load hostName for NAGIOS_SERVER - * - Load hostNames for ZOOKEEPER_SERVER - * - Load config tags - * - Load configs - * - Save Slider-properties - * If Slider-properties exists: - * - Load cluster name - * - Load hostNames - * After whole data has been loaded set App.sliderConfigs and enable/disable Slider + * Load Slider-properties. + * After this set App.sliderConfig-models and enable/disable Slider * @type {Ember.Controller} */ -App.SliderController = Ember.Controller.extend(App.RunPeriodically, { - - /** - * Map for Slider-errors - * If some config is empty, service isn't installed - * @type {object} - */ - serviceConfigMap: { - HDFS: 'hdfsAddress', - YARN: 'yarnResourceManager', - ZOOKEEPER: 'zookeeperQuorum' - }, - - /** - * List of Slider-properties mapped from Ambari-configs - * Key-names used in Slider-Title-Popup, so don't change it pls - * @type {Em.Object} - */ - initialValuesToLoad: Em.Object.create({ - ambariAddress: null, - clusterName: null, - hdfsAddress: null, - yarnResourceManager: null, - yarnResourceManagerScheduler: null, - zookeeperQuorum: null, - gangliaServer: null, - gangliaClusters: null - }), - - /** - * List of host names with ZOOKEEPER_SERVER installed - * @type {string[]} - */ - zookeeperHosts: [], +App.SliderController = Ember.Controller.extend({ /** * Load resources on controller initialization @@ -81,12 +37,12 @@ App.SliderController = Ember.Controller.extend(App.RunPeriodically, { * @returns {$.ajax} * @method getParametersFromViewProperties */ - getParametersFromViewProperties: function() { + getParametersFromViewProperties: function () { return App.ajax.send({ name: 'slider.getViewParams', sender: this, success: 'getParametersFromViewPropertiesSuccessCallback', - error: 'getParametersFromViewPropertiesErrorCallback' + error: 'finishSliderConfiguration' }); }, @@ -97,262 +53,36 @@ App.SliderController = Ember.Controller.extend(App.RunPeriodically, { * @param {object} data * @method getParametersFromViewPropertiesSuccessCallback */ - getParametersFromViewPropertiesSuccessCallback: function(data) { + getParametersFromViewPropertiesSuccessCallback: function (data) { var properties = Em.get(data, 'ViewInstanceInfo.properties'), - initialValuesToLoad = this.get('initialValuesToLoad'); - if (properties == null || properties['hdfs.address'] == null - || properties['yarn.resourcemanager.address'] == null - || properties['yarn.resourcemanager.scheduler.address'] == null - || properties['zookeeper.quorum'] == null) { - this.getClusterName(); - } else { - // TODO remove below line as it is a temporary hack - this.getClusterName(); - - initialValuesToLoad.setProperties({ - ambariAddress: location.protocol + "//" + document.location.host, - hdfsAddress: properties['hdfs.address'], - yarnResourceManager: properties['yarn.resourcemanager.address'], - yarnResourceManagerScheduler: properties['yarn.resourcemanager.scheduler.address'], - zookeeperQuorum: properties['zookeeper.quorum'], - gangliaServer: properties['ganglia.server.hostname'], - gangliaClusters: properties['ganglia.custom.clusters'] - }); - App.set('gangliaHost', properties['ganglia.server.hostname']); - this.finishSliderConfiguration(); - } - }, - - /** - * Error-callback for Slider-parameters request - * @method getParametersFromViewPropertiesErrorCallback - */ - getParametersFromViewPropertiesErrorCallback: function() { - this.getClusterName(); - }, - - /** - * Get cluster name from server - * @returns {$.ajax} - * @method getClusterName - */ - getClusterName: function () { - return App.ajax.send({ - name: 'cluster_name', - sender: this, - data: { - urlPrefix: '/api/v1/' - }, - success: 'getClusterNameSuccessCallback' - }); - }, - - /** - * Success callback for clusterName-request - * @param {object} data - * @param {object} opt - * @param {object} params - * @method getClusterNameSuccessCallback - */ - getClusterNameSuccessCallback: function (data, opt, params) { - var clusterName = Em.get(data.items[0], 'Clusters.cluster_name'); - App.set('clusterName', clusterName); - this.loadComponentHost({componentName: "GANGLIA_SERVER", callback: "loadGangliaHostSuccessCallback"}); - this.loadComponentHost({componentName: "NAGIOS_SERVER", callback: "loadNagiosHostSuccessCallback"}); - this.loadComponentHost({componentName: "ZOOKEEPER_SERVER", callback: "setZookeeperQuorum"}); - this.loadConfigsTags(); - }, - - /** - * Load config tags from server - * @returns {$.ajax} - * @method loadConfigsTags - */ - loadConfigsTags: function () { - return App.ajax.send({ - name: 'config.tags', - sender: this, - data: { - urlPrefix: '/api/v1/' - }, - success: 'onLoadConfigsTags' - }); - }, - - /** - * Success callback for loadConfigsTags - * Get configs for selected tags - * @param {object} data - * @method onLoadConfigsTags - */ - onLoadConfigsTags: function (data) { - var urlParams = []; - if (data.Clusters.desired_configs['yarn-site'] && data.Clusters.desired_configs['zookeeper-env']) { - var coreSiteTag = data.Clusters.desired_configs['core-site'].tag; - var yarnSiteTag = data.Clusters.desired_configs['yarn-site'].tag; - var zookeeperTag = data.Clusters.desired_configs['zookeeper-env'].tag; - urlParams.push('(type=core-site&tag=' + coreSiteTag + ')'); - urlParams.push('(type=yarn-site&tag=' + yarnSiteTag + ')'); - urlParams.push('(type=zookeeper-env&tag=' + zookeeperTag + ')'); - - App.ajax.send({ - name: 'get_all_configurations', - sender: this, - data: { - urlParams: urlParams.join('|'), - urlPrefix: '/api/v1/' - }, - success: 'onLoadConfigs' - }); - } - }, - - /** - * Success callback for onLoadConfigs - * Set properties for initialValuesToLoad using loaded configs - * @param {object} data - * @method onLoadConfigs - */ - onLoadConfigs: function (data) { - var hdfs = data.items.findProperty('type', 'core-site'), - yarn = data.items.findProperty('type', 'yarn-site'), - zookeeper = data.items.findProperty('type', 'zookeeper-env'), - initialValuesToLoad = this.get('initialValuesToLoad'); - initialValuesToLoad.set('ambariAddress', location.protocol + "//" + document.location.host); - initialValuesToLoad.set('clusterName', App.get('clusterName')); - initialValuesToLoad.set('hdfsAddress', hdfs.properties['fs.defaultFS']); - initialValuesToLoad.set('yarnResourceManager', yarn.properties['yarn.resourcemanager.address']); - initialValuesToLoad.set('yarnResourceManagerScheduler', yarn.properties['yarn.resourcemanager.scheduler.address']); - initialValuesToLoad.set('zookeeperQuorum', zookeeper.properties.clientPort); - this.setZookeeperQuorum(); - }, - - /** - * Set value for initialValuesToLoad.zookeeperQuorum - * Also do request to save Slider-properties - * @param {object} data - * @method setZookeeperQuorum - */ - setZookeeperQuorum: function (data) { - var zookeeperHosts = this.get('zookeeperHosts'), - hosts = [], - initialValuesToLoad = this.get('initialValuesToLoad'); - - //done - if (!Em.isNone(initialValuesToLoad.zookeeperQuorum)) { - if (data) { - hosts = data.items.map(function (item) { - return item.Hosts.host_name + ":" + initialValuesToLoad.zookeeperQuorum; - }); - initialValuesToLoad.set('zookeeperQuorum', hosts.join(',')); - this.sendInitialValues(); - } - else { - if (zookeeperHosts.length > 0) { - hosts = zookeeperHosts.map(function (host) { - return host + ":" + initialValuesToLoad.zookeeperQuorum; - }); - initialValuesToLoad.set('zookeeperQuorum', hosts.join(',')); - this.sendInitialValues(); - } - } - } - else { - this.set('zookeeperHosts', data.items.mapProperty('Hosts.host_name')); - } - }, - - /** - * Send request to server to save initialValues - * @return {$.ajax} - * @method sendInitialValues - */ - sendInitialValues: function () { - var initialValues = this.get('initialValuesToLoad'); - return App.ajax.send({ - name: 'saveInitialValues', - sender: this, - data: { - data: { - ViewInstanceInfo: { - properties: { - 'hdfs.address': initialValues.get('hdfsAddress'), - 'yarn.resourcemanager.address': initialValues.get('yarnResourceManager'), - 'yarn.resourcemanager.scheduler.address': initialValues.get('yarnResourceManagerScheduler'), - 'zookeeper.quorum': initialValues.get('zookeeperQuorum') - } - } - } - }, - success: 'finishSliderConfiguration' + initialValuesToLoad = this.get('initialValuesToLoad'), + sliderConfigs = App.SliderApp.store.all('sliderConfig'), + self = this; + sliderConfigs.forEach(function (model) { + var key = model.get('viewConfigName'); + model.set('value', properties[key]); }); + self.finishSliderConfiguration(); }, /** * After all Slider-configs are loaded, application should check self status * @method finishSliderConfiguration */ - finishSliderConfiguration: function() { + finishSliderConfiguration: function () { //check if all services exist - var serviceConfigMap = this.get('serviceConfigMap'), - initialValuesToLoad = this.get('initialValuesToLoad'), - services = Em.keys(serviceConfigMap), - errors = []; - services.forEach(function(serviceName) { - var configName = Em.get(serviceConfigMap, serviceName); - if (Em.isEmpty(initialValuesToLoad[configName])) { - errors.push(Em.I18n.t('error.no' + serviceName)); + var errors = []; + App.SliderApp.store.all('sliderConfig').forEach(function (model) { + if (Em.isEmpty(model.get('value')) && model.get('required')) { + errors.push(Em.I18n.t('error.config_is_empty').format(model.get('viewConfigName'))); } }); + errors.uniq(); App.setProperties({ viewErrors: errors, viewEnabled: errors.length === 0, - sliderConfigs: initialValuesToLoad, mapperTime: new Date().getTime() }); - }, - - /** - * Load host for component - * @param {{componentName: string, callback: string}} params - * @return {$.ajax} - * @method loadGangliaHost - */ - loadComponentHost: function (params) { - return App.ajax.send({ - name: 'components_hosts', - sender: this, - data: { - componentName: params.componentName, - urlPrefix: '/api/v1/' - }, - success: params.callback - }); - - }, - - /** - * Success callback for hosts-request - * Save host name to GANGLIA_SERVER (set in App.gangliaHost) - * @param {Object} data - * @method loadGangliaHostSuccessCallback - */ - loadGangliaHostSuccessCallback: function (data) { - if (data.items[0]) { - App.set('gangliaHost', Em.get(data.items[0], 'Hosts.host_name')); - } - }, - - /** - * Success callback for hosts-request - * Save host name to NAGIOS_SERVER (set in App.nagiosHost) - * @param {Object} data - * @method loadGangliaHostSuccessCallback - */ - loadNagiosHostSuccessCallback: function (data) { - if (data.items[0]) { - App.set('nagiosHost', Em.get(data.items[0], 'Hosts.host_name')); - } } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js b/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js index 0a14842..ba7fbce 100644 --- a/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js +++ b/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js @@ -24,7 +24,7 @@ * real - real url (without API prefix) * type - request type (also may be defined in the format method) * format - function for processing ajax params after default formatRequest. May be called with one or two parameters (data, opt). Return ajax-params object - * testInProduction - can this request be executed on production tests (used only in tests) + * schema - basic validation schema (tv4) for response (optional) * * @type {Object} */ @@ -36,6 +36,14 @@ var urls = { headers: { Accept: "text/plain; charset=utf-8", "Content-Type": "text/plain; charset=utf-8" + }, + schema: { + required: ['ViewInstanceInfo'], + properties: { + ViewInstanceInfo: { + required: ['properties'] + } + } } }, @@ -45,6 +53,28 @@ var urls = { headers: { Accept: "text/plain; charset=utf-8", "Content-Type": "text/plain; charset=utf-8" + }, + schema: { + required: ['items'], + properties: { + items: { + type: 'array', + items: { + required: ['id', 'typeComponents', 'typeConfigs'], + properties: { + typeConfigs: { + type: 'object' + }, + typeComponents: { + type: 'array', + items: { + required: ['id', 'name', 'category', 'displayName'] + } + } + } + } + } + } } }, @@ -54,6 +84,23 @@ var urls = { headers: { Accept: "text/plain; charset=utf-8", "Content-Type": "text/plain; charset=utf-8" + }, + schema: { + required: ['items'], + properties: { + items: { + type: 'array', + items: { + required: ['id', 'description', 'diagnostics', 'name', 'user', 'state', 'type', 'components', 'configs'], + alerts: { + type: 'object', + detail: { + type: 'array' + } + } + } + } + } } }, @@ -64,6 +111,7 @@ var urls = { 'saveInitialValues': { real: '', + mock: '/data/resource/empty_json.json', headers: { "Content-Type": "text/plain; charset=utf-8" }, @@ -126,58 +174,6 @@ var urls = { } }, - 'service_status': { - real: 'clusters/{clusterName}/services?fields=ServiceInfo/state&minimal_response=true', - mock: '/data/resource/service_status.json', - headers: { - Accept: "text/plain; charset=utf-8", - "Content-Type": "text/plain; charset=utf-8" - } - }, - - 'components_hosts': { - real: 'clusters/{clusterName}/hosts?host_components/HostRoles/component_name={componentName}&minimal_response=true', - mock: '/data/resource/components_hosts.json', - headers: { - Accept: "text/plain; charset=utf-8", - "Content-Type": "text/plain; charset=utf-8" - } - }, - - 'service_current_configs': { - real: 'clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&is_current=true', - mock: '/data/resource/service_configs.json', - headers: { - Accept: "text/plain; charset=utf-8", - "Content-Type": "text/plain; charset=utf-8" - } - }, - - 'config.tags': { - 'real': 'clusters/{clusterName}?fields=Clusters/desired_configs', - headers: { - Accept: "text/plain; charset=utf-8", - "Content-Type": "text/plain; charset=utf-8" - } - }, - - 'get_all_configurations': { - 'real': 'clusters/{clusterName}/configurations?{urlParams}', - headers: { - Accept: "text/plain; charset=utf-8", - "Content-Type": "text/plain; charset=utf-8" - } - }, - - 'cluster_name': { - real: 'clusters', - mock: '/data/resource/cluster_name.json', - headers: { - Accept: "text/plain; charset=utf-8", - "Content-Type": "text/plain; charset=utf-8" - } - }, - 'metrics': { real: 'apps/{id}/metrics/{metric}', mock: '/data/metrics/metric.json' @@ -248,11 +244,11 @@ var formatRequest = function (data) { } var url = formatUrl(this.real, data); opt.url = prefix + (url ? url : ''); + if (this.format) { + jQuery.extend(opt, this.format(data, opt)); + } } - if (this.format) { - jQuery.extend(opt, this.format(data, opt)); - } return opt; }; @@ -305,6 +301,17 @@ var ajax = Em.Object.extend({ opt.success = function (data) { console.log("TRACE: The url is: " + opt.url); + + // validate response if needed + if (urls[config.name].schema) { + var result = tv4.validateMultiple(data, urls[config.name].schema); + if (!result.valid) { + result.errors.forEach(function (error) { + console.warn('Request: ' + config.name, 'WARNING: ', error.message, error.dataPath); + }); + } + } + if (config.success) { config.sender[config.success](data, opt, params); } http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/initialize.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/initialize.js b/contrib/views/slider/src/main/resources/ui/app/initialize.js index fd34ebe..5428c3d 100755 --- a/contrib/views/slider/src/main/resources/ui/app/initialize.js +++ b/contrib/views/slider/src/main/resources/ui/app/initialize.js @@ -105,20 +105,13 @@ App.initializer({ gangliaClusters: null, /** - * View-configs set from ambari-admin - * Loaded in App.SliderController - * @type {null|object} - */ - sliderConfigs: null, - - /** * Last time when mapper ran * @type {null|number} */ mapperTime: null }); - application.SliderController.proto().loop('initResources'); + application.SliderController.proto().initResources(); application.ApplicationTypeMapper.loop('load'); application.SliderAppsMapper.loop('load'); } http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js b/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js index a8ebbff..7312f86 100644 --- a/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js +++ b/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js @@ -161,6 +161,12 @@ App.SliderAppsMapper = App.Mapper.createWithMixins(App.RunPeriodically, { }); }, + /** + * Concatenate supportedMetrics into one string + * @param {object} app + * @returns {string} + * @method parseMetricNames + */ parseMetricNames : function(app) { if (app.supportedMetrics) { return app.supportedMetrics.join(","); @@ -185,6 +191,7 @@ App.SliderAppsMapper = App.Mapper.createWithMixins(App.RunPeriodically, { quickLinks = self.parseQuickLinks(app), alerts = self.parseAlerts(app), jmx = self.parseObject(app.jmx), + metricNames = self.parseMetricNames(app), masterActiveTime = jmx.findProperty('key', 'MasterActiveTime'), masterStartTime = jmx.findProperty('key', 'MasterStartTime'); if (masterActiveTime) { http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/models/slider_config.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_config.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_config.js new file mode 100644 index 0000000..a079faf --- /dev/null +++ b/contrib/views/slider/src/main/resources/ui/app/models/slider_config.js @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Slider config-property (see Ambari-Admin view-settings) + * Also see view.xml + * @type {DS.Model} + */ +App.SliderConfig = DS.Model.extend({ + + /** + * Name in the Ambari-Admin + * @type {string} + */ + viewConfigName: DS.attr('string'), + + /** + * Shown name + * @type {string} + */ + displayName: DS.attr('string'), + + /** + * @type {null|string} + */ + value: null, + + /** + * Is property required + * @type {bool} + */ + required: DS.attr('bool') + +}); + +App.SliderConfig.FIXTURES = []; http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/routes/main.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/routes/main.js b/contrib/views/slider/src/main/resources/ui/app/routes/main.js index 80d2de5..d1e0bb7 100644 --- a/contrib/views/slider/src/main/resources/ui/app/routes/main.js +++ b/contrib/views/slider/src/main/resources/ui/app/routes/main.js @@ -46,6 +46,22 @@ App.SliderAppsRoute = Ember.Route.extend({ return this.store.all('sliderApp'); }, + + setupController: function(controller, model) { + controller.set('model', model); + + // Load sliderConfigs to storage + App.SliderApp.store.pushMany('sliderConfig', Em.A([ + Em.Object.create({id: 1, required: true, viewConfigName: 'hdfs.address', displayName: 'hdfsAddress', linkedService: 'HDFS'}), + Em.Object.create({id: 2, required: true, viewConfigName: 'yarn.resourcemanager.address', displayName: 'yarnResourceManager', linkedService: 'YARN'}), + Em.Object.create({id: 3, required: true, viewConfigName: 'yarn.resourcemanager.scheduler.address', displayName: 'yarnResourceManagerScheduler'}), + Em.Object.create({id: 4, required: true, viewConfigName: 'zookeeper.quorum', displayName: 'zookeeperQuorum', linkedService: 'ZOOKEEPER'}), + Em.Object.create({id: 5, required: false, viewConfigName: 'ganglia.server.hostname', displayName: 'gangliaServer'}), + Em.Object.create({id: 6, required: false, viewConfigName: 'ganglia.custom.clusters', displayName: 'gangliaClusters'}), + Em.Object.create({id: 7, required: false, viewConfigName: 'slider.user', displayName: 'sliderUser'}) + ])); + }, + actions: { createApp: function () { this.transitionTo('createAppWizard'); http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/templates/application.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/templates/application.hbs b/contrib/views/slider/src/main/resources/ui/app/templates/application.hbs index 625eaca..da828bf 100755 --- a/contrib/views/slider/src/main/resources/ui/app/templates/application.hbs +++ b/contrib/views/slider/src/main/resources/ui/app/templates/application.hbs @@ -20,12 +20,12 @@ {{#view view.SliderTitleView}}

{{t slider.apps.title}} - {{App.instance}}

{{/view}} + {{outlet bs-tooltip-box}} {{#if App.viewEnabled}} {{outlet}} - {{outlet bs-tooltip-box}} {{else}} {{#each error in App.viewErrors}} -

{{error}}

+

{{{error}}}

{{/each}} {{/if}} http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/templates/slider_title_tooltip.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/templates/slider_title_tooltip.hbs b/contrib/views/slider/src/main/resources/ui/app/templates/slider_title_tooltip.hbs index 1b80aa2..39cecd1 100644 --- a/contrib/views/slider/src/main/resources/ui/app/templates/slider_title_tooltip.hbs +++ b/contrib/views/slider/src/main/resources/ui/app/templates/slider_title_tooltip.hbs @@ -22,7 +22,7 @@ {{#each config in view.content}}
-
{{humanize config.name}}
+
{{humanize config.displayName}}
{{formatWordBreak config.value devider=','}}
{{/each}} http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/translations.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/translations.js b/contrib/views/slider/src/main/resources/ui/app/translations.js index d7ab3eb..4336ddc 100644 --- a/contrib/views/slider/src/main/resources/ui/app/translations.js +++ b/contrib/views/slider/src/main/resources/ui/app/translations.js @@ -53,12 +53,7 @@ Em.I18n.translations = { 'send': 'Send' }, - 'error.noHDFS': 'Slider applications view requires HDFS service.', - 'error.startHDFS': 'Slider applications view requires HDFS service to be started.', - 'error.noYARN': 'Slider applications view requires YARN service.', - 'error.startYARN': 'Slider applications view requires YARN service to be started.', - 'error.noZOOKEEPER': 'Slider applications view requires ZooKeeper service.', - 'error.startZOOKEEPER': 'Slider applications view requires ZooKeeper service to be started.', + 'error.config_is_empty': 'Config {0} should not be empty', 'popup.confirmation.commonHeader': 'Confirmation', 'question.sure':'Are you sure?', http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/app/views/application_view.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/views/application_view.js b/contrib/views/slider/src/main/resources/ui/app/views/application_view.js index bae82e9..1860944 100644 --- a/contrib/views/slider/src/main/resources/ui/app/views/application_view.js +++ b/contrib/views/slider/src/main/resources/ui/app/views/application_view.js @@ -38,19 +38,8 @@ App.ApplicationView = Ember.View.extend({ * @method sliderConfigsChecker */ sliderConfigsChecker: function() { - var configs = App.get('sliderConfigs'), - res = [], - excludedConfigs = ['ambariAddress', 'clusterName']; - if (configs) { - Em.keys(configs).forEach(function(c) { - if (!excludedConfigs.contains(c)) { - res.push({name: c, value: configs[c]}); - } - }); - } - this.set('content', res); var template = this.createChildView(App.SliderTitleTooltipView, { - content: res + content: App.SliderApp.store.all('sliderConfig') }); this.set('popover.template', template.renderToBuffer().string()); }.observes('App.mapperTime') http://git-wip-us.apache.org/repos/asf/ambari/blob/d62147ed/contrib/views/slider/src/main/resources/ui/config.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/config.js b/contrib/views/slider/src/main/resources/ui/config.js index e464128..4c6a023 100755 --- a/contrib/views/slider/src/main/resources/ui/config.js +++ b/contrib/views/slider/src/main/resources/ui/config.js @@ -29,6 +29,7 @@ exports.config = { order: { before: [ 'vendor/scripts/common/d3.v2.js', + 'vendor/scripts/common/tv4.js', 'vendor/scripts/common/cubism.v1.js', 'vendor/scripts/common/rickshaw.js', 'vendor/scripts/common/console-polyfill.js',