Parcourir la source

AMBARI-5432. Add service wizard to add missing service-components for other services. (srimanth)

Srimanth Gunturi il y a 11 ans
Parent
commit
12ba97fd3c

+ 4 - 0
ambari-web/app/app.js

@@ -70,6 +70,10 @@ module.exports = Em.Application.create({
     return (stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.0") === 1 ||
       stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.0") === 0)
   }.property('currentStackVersionNumber'),
+  isHadoop21Stack: function(){
+    return (stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.1") === 1 ||
+      stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.1") === 0)
+  }.property('currentStackVersionNumber'),
 
   /**
    * If High Availability is enabled

+ 40 - 0
ambari-web/app/controllers/wizard/step8_controller.js

@@ -969,6 +969,46 @@ App.WizardStep8Controller = Em.Controller.extend({
         data: JSON.stringify({"components": componentsData})
       });
     }, this);
+
+    if (this.get('content.controllerName') == 'addServiceController' && !App.testMode) {
+      // Add service-components which show up in newer versions but did not
+      // exist in older ones.
+      var self = this;
+      var newServiceComponents = {}
+      if (App.get('isHadoop21Stack')) {
+        newServiceComponents['APP_TIMELINE_SERVER'] = 'YARN';
+      }
+      for (var componentName in newServiceComponents) {
+        var serviceName = newServiceComponents[componentName];
+        // Create only if it doesnt exist
+        var serviceComponentChecker = {
+          success: function(){},
+          error: function(){
+            var componentsData = [{
+              "ServiceComponentInfo": {
+                "component_name": componentName
+              }
+            }];
+            self.addRequestToAjaxQueue({
+              type: 'POST',
+              url: App.apiPrefix + '/clusters/' + self.get('clusterName') + '/services?ServiceInfo/service_name=' + serviceName,
+              data: JSON.stringify({"components": componentsData})
+            });
+          }
+        }
+        App.ajax.send({
+          name: 'service.service_component',
+          sender: serviceComponentChecker,
+          data: {
+            serviceName: serviceName,
+            componentName: componentName,
+            async: false
+          },
+          success: 'success',
+          error: 'error'
+        });
+      }
+    }
   },
 
   /**

+ 9 - 0
ambari-web/app/utils/ajax.js

@@ -508,6 +508,15 @@ var urls = {
     'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}?fields=host_components/{metricName}',
     'mock': '/data/cluster_metrics/cpu_1hr.json'
   },
+  'service.service_component': {
+    'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}',
+    'mock': '',
+    'format': function(data) {
+      return {
+        async: data.async
+      };
+    }
+  },
   'service.metrics.flume.channel_fill_percent': {
     'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
     'mock': '/data/services/metrics/flume/channelFillPct.json',

+ 43 - 0
ambari-web/test/app_test.js

@@ -23,6 +23,49 @@ require('models/stack_service_component');
 
 describe('#App', function() {
 
+  describe('App.isHadoop21Stack', function() {
+    var tests = [{
+      v:'',
+      e:false
+    }, {
+      v:'HDP',
+      e: false
+    }, {
+      v:'HDP1',
+      e: false
+    }, {
+      v:'HDP-1',
+      e: false
+    }, {
+      v:'HDP-2.0',
+      e: false
+    }, {
+      v:'HDP-2.0.1000',
+      e: false
+    }, {
+      v:'HDP-2.1',
+      e: true
+    }, {
+      v:'HDP-2.1.3434',
+      e: true
+    }, {
+      v:'HDP-2.2',
+      e: true
+    }, {
+      v:'HDP-2.2.1212',
+      e: true
+    }];
+    tests.forEach(function(test){
+      it(test.v, function() {
+        App.QuickViewLinks.prototype.setQuickLinks = function(){};
+        App.set('currentStackVersion', test.v);
+        var calculated = App.get('isHadoop21Stack');
+        var expected = test.e;
+        expect(calculated).to.equal(expected);
+      });
+    });
+  });
+
   describe('Disable/enable components', function() {
 
     var testableComponent =  Em.Object.create({