Kaynağa Gözat

AMBARI-6594. Create mapper for ahsWebPort. (onechiporenko)

Oleg Nechiporenko 11 yıl önce
ebeveyn
işleme
3367667cd1

+ 14 - 0
contrib/views/jobs/src/main/resources/ui/app/scripts/assets/configurations.json

@@ -0,0 +1,14 @@
+{
+  "items" : [
+    {
+      "tag" : "version1406204965090",
+      "type" : "yarn-site",
+      "Config" : {
+        "cluster_name" : "tdk"
+      },
+      "properties" : {
+        "yarn.timeline-service.webapp.address" : "host1:8188"
+      }
+    }
+  ]
+}

+ 20 - 0
contrib/views/jobs/src/main/resources/ui/app/scripts/assets/desired_configs.json

@@ -0,0 +1,20 @@
+{
+  "Clusters" : {
+    "cluster_name" : "tdk",
+    "version" : "HDP-2.1",
+    "desired_configs" : {
+      "yarn-env" : {
+        "user" : "admin",
+        "tag" : "version1406204965090"
+      },
+      "yarn-log4j" : {
+        "user" : "admin",
+        "tag" : "version1406204965090"
+      },
+      "yarn-site" : {
+        "user" : "admin",
+        "tag" : "version1406204965090"
+      }
+    }
+  }
+}

+ 1 - 1
contrib/views/jobs/src/main/resources/ui/app/scripts/controllers/jobs_controller.js

@@ -430,7 +430,7 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
         sender: this,
         data: {
           historyServerHostName: historyServerHostName,
-          ahsWebPort: '',
+          ahsWebPort: yarnService.get('ahsWebPort'),
           filtersLink: this.get('filterObject').createJobsFiltersLink()
         },
         success: 'loadJobsSuccessCallback',

+ 10 - 0
contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/ajax.js

@@ -60,6 +60,16 @@ var urls = {
   'components_hosts': {
     real: 'clusters/{clusterName}/hosts?host_components/HostRoles/component_name={componentName}&minimal_response=true',
     mock: '/scripts/assets/components_hosts.json'
+  },
+
+  'config_tags': {
+    real: 'clusters/{clusterName}/?fields=Clusters/desired_configs',
+    mock: '/scripts/assets/desired_configs.json'
+  },
+
+  'configurations': {
+    real: 'clusters/{clusterName}/configurations?{params}',
+    mock: '/scripts/assets/configurations.json'
   }
 
 };

+ 88 - 11
contrib/views/jobs/src/main/resources/ui/app/scripts/mappers/application_status_mapper.js

@@ -59,6 +59,18 @@ App.ApplicationStatusMapper = Em.Object.createWithMixins(App.RunPeriodically, {
     }
   },
 
+  /**
+   * Is ATS host loaded
+   * @type {bool}
+   */
+  hostForComponentIsLoaded: false,
+
+  /**
+   * Is <code>ahsWebPort</code> loaded
+   * @type {bool}
+   */
+  portIsLoaded: false,
+
   /**
    * Start mapping when <code>App.clusterName</code> is loaded
    * @method mapInit
@@ -78,7 +90,10 @@ App.ApplicationStatusMapper = Em.Object.createWithMixins(App.RunPeriodically, {
     var self = this;
     this.getServices().then(function() {
       self.getComponents().then(function() {
-        self.getHostsForComponents();
+        if (!self.get('hostForComponentIsLoaded'))
+          self.getHostsForComponents();
+        if (!self.get('portIsLoaded'))
+          self.getDesiredConfigs();
       });
     });
   },
@@ -183,16 +198,14 @@ App.ApplicationStatusMapper = Em.Object.createWithMixins(App.RunPeriodically, {
    * @method getHostsForComponents
    */
   getHostsForComponents: function() {
-    if (!App.HiveJob.store.getById('component', 'APP_TIMELINE_SERVER').get('hostName')) {
-      return App.ajax.send({
-        name: 'components_hosts',
-        sender: this,
-        data: {
-          componentName: 'APP_TIMELINE_SERVER'
-        },
-        success: 'getHostsForComponentsSuccessCallback'
-      });
-    }
+    return App.ajax.send({
+      name: 'components_hosts',
+      sender: this,
+      data: {
+        componentName: 'APP_TIMELINE_SERVER'
+      },
+      success: 'getHostsForComponentsSuccessCallback'
+    });
   },
 
   /**
@@ -203,6 +216,70 @@ App.ApplicationStatusMapper = Em.Object.createWithMixins(App.RunPeriodically, {
    */
   getHostsForComponentsSuccessCallback: function(data) {
     App.HiveJob.store.getById('component', 'APP_TIMELINE_SERVER').set('hostName', Em.get(data.items[0], 'Hosts.host_name'));
+    this.set('hostForComponentIsLoaded', true);
+  },
+
+  /**
+   * Get Ambari desired configs
+   * @returns {$.ajax}
+   * @method getDesiredConfigs
+   */
+  getDesiredConfigs: function() {
+    return App.ajax.send({
+      name: 'config_tags',
+      sender: this,
+      success: 'getDesiredConfigsSuccessCallback'
+    });
+  },
+
+  /**
+   * Success callback for Ambari desired configs request
+   * Make request for YARN configs
+   * @param {object} data
+   * @returns {$.ajax|null}
+   * @method getDesiredConfigsSuccessCallback
+   */
+  getDesiredConfigsSuccessCallback: function(data) {
+    var c = Em.get(data, 'Clusters.desired_configs')['yarn-site'];
+    if (!Em.isNone(c)) {
+      return this.getConfigurations(c);
+    }
+  },
+
+  /**
+   * Get YARN configs
+   * @param {{user: string, tag: string}} config
+   * @returns {$.ajax}
+   * @method getConfigurations
+   */
+  getConfigurations: function(config) {
+    return App.ajax.send({
+      name: 'configurations',
+      sender: this,
+      data: {
+        params: '(type=yarn-site&tag=%@1)'.fmt(config.tag)
+      },
+      success: 'getConfigurationSuccessCallback'
+    });
+  },
+
+  /**
+   * Success callback for YARN configs
+   * Set <code>ahsWebPort</code> property using <code>yarn.timeline-service.webapp.address</code> or '8188' as default
+   * @param {object} data
+   * @method getConfigurationSuccessCallback
+   */
+  getConfigurationSuccessCallback: function(data) {
+    var c = data.items.findBy('type', 'yarn-site');
+    if (!Em.isNone(c)) {
+      var properties = Em.get(c, 'properties'),
+        port = '8188';
+      if (!Em.isNone(properties)) {
+        port = properties['yarn.timeline-service.webapp.address'].match(/:(\d+)/)[1];
+      }
+      App.HiveJob.store.getById('service', 'YARN').set('ahsWebPort', port);
+      this.set('portIsLoaded', true);
+    }
   }
 
 });

+ 1 - 1
contrib/views/jobs/src/main/resources/ui/app/scripts/models/service.js

@@ -33,7 +33,7 @@ App.Service = DS.Model.extend({
    *
    * @type {string}
    */
-  ahsWebPort: '8088'
+  ahsWebPort: '8188'
 
 });