Browse Source

AMBARI-9155. Ambari Metrics service to be checked for install by default, warn if unchecked. (akovalenko)

Aleksandr Kovalenko 10 years ago
parent
commit
06f4a89fd5

+ 39 - 1
ambari-web/app/controllers/wizard/step4_controller.js

@@ -77,6 +77,24 @@ App.WizardStep4Controller = Em.ArrayController.extend({
 	  return  dfsServices.length > 1;
   },
 
+  /**
+   * Check whether user selected Ambari Metrics service to install and go to next step
+   * @method ambariMetricsValidation
+   */
+  ambariMetricsValidation: function () {
+    //TODO Change 'AMS' to the actual serviceName after it's changed
+    var ambariMetricsService = this.findProperty('serviceName', 'AMS');
+    if (ambariMetricsService) {
+      if (!ambariMetricsService.get('isSelected')) {
+        this.addValidationError({
+          id: 'ambariMetricsCheck',
+          type: 'WARNING',
+          callback: this.ambariMetricsCheckPopup
+        });
+      }
+    }
+  },
+
   /**
    * Onclick handler for <code>Next</code> button.
    * @method submit
@@ -111,6 +129,9 @@ App.WizardStep4Controller = Em.ArrayController.extend({
   validate: function() {
     this.serviceDependencyValidation();
     this.fileSystemServiceValidation();
+    if (this.get('wizardController.name') == 'installerController') {
+      this.ambariMetricsValidation();
+    }
     if (!!this.get('errorStack').filterProperty('isShown', false).length) {
       this.showError(this.get('errorStack').findProperty('isShown', false));
       return false;
@@ -322,6 +343,23 @@ App.WizardStep4Controller = Em.ArrayController.extend({
         this.hide();
       }
     });
-  }
+  },
 
+  /**
+   * Show popup with info about not selected Ambari Metrics service
+   * @return {App.ModalPopup}
+   * @method ambariMetricsCheckPopup
+   */
+  ambariMetricsCheckPopup: function () {
+    var self = this;
+    return App.ModalPopup.show({
+      header: Em.I18n.t('installer.step4.ambariMetricsCheck.popup.header'),
+      body: Em.I18n.t('installer.step4.ambariMetricsCheck.popup.body'),
+      primary: Em.I18n.t('common.proceedAnyway'),
+      onPrimary: function () {
+        self.onPrimaryPopupCallback();
+        this.hide();
+      }
+    });
+  }
 });

+ 2 - 2
ambari-web/app/messages.js

@@ -651,8 +651,8 @@ Em.I18n.translations = {
   'installer.step4.multipleDFS.popup.body':'You selected more than one file system. We will automatically select only {0}. Is this OK?',
   'installer.step4.serviceCheck.popup.header':'{0} Needed',
   'installer.step4.serviceCheck.popup.body':'You did not select {0}, but it is needed by other services you selected. We will automatically add {0}. Is this OK?',
-  'installer.step4.monitoringCheck.popup.header':'Limited Functionality Warning',
-  'installer.step4.monitoringCheck.popup.body':'You did not select {0}. If {1} is not selected, monitoring and alerts will not function properly. Is this OK?',
+  'installer.step4.ambariMetricsCheck.popup.header':'Limited Functionality Warning',
+  'installer.step4.ambariMetricsCheck.popup.body':'Ambari Metrics collects metrics from the cluster and makes them available to Ambari.  If you do not install Ambari Metrics service, metrics will not be accessible from Ambari.  Are you sure you want to proceed without Ambari Metrics?',
 
   'installer.step5.header':'Assign Masters',
   'installer.step5.reassign.header':'Select Target Host',

+ 2 - 0
ambari-web/app/routes/add_service_routes.js

@@ -104,6 +104,8 @@ module.exports = App.WizardRoute.extend({
       controller.set('hideBackButton', true);
       controller.dataLoading().done(function () {
         controller.loadAllPriorSteps();
+        var wizardStep4Controller = router.get('wizardStep4Controller');
+        wizardStep4Controller.set('wizardController', controller);
         controller.connectOutlet('wizardStep4', controller.get('content.services').filterProperty('isInstallable', true));
       });
     },

+ 2 - 0
ambari-web/app/routes/installer.js

@@ -237,6 +237,8 @@ module.exports = Em.Route.extend({
       var controller = router.get('installerController');
       controller.setCurrentStep('4');
       controller.loadAllPriorSteps().done(function () {
+        var wizardStep4Controller = router.get('wizardStep4Controller');
+        wizardStep4Controller.set('wizardController', controller);
         controller.connectOutlet('wizardStep4', App.StackService.find().filterProperty('isInstallable', true));
       });
     },

+ 133 - 44
ambari-web/test/controllers/wizard/step4_test.js

@@ -25,7 +25,7 @@ describe('App.WizardStep4Controller', function () {
 
   var services = [
     'HDFS', 'NAGIOS', 'GANGLIA', 'OOZIE', 'HIVE', 'HBASE', 'PIG', 'SCOOP', 'ZOOKEEPER',
-    'YARN', 'MAPREDUCE2', 'FALCON', 'TEZ', 'STORM'
+    'YARN', 'MAPREDUCE2', 'FALCON', 'TEZ', 'STORM', 'AMS'
   ];
 
   var controller = App.WizardStep4Controller.create();
@@ -227,50 +227,100 @@ describe('App.WizardStep4Controller', function () {
 
   describe('#validate()', function() {
     var tests = [
-      {
-        services: ['HDFS','ZOOKEEPER'],
-        errorsExpected: []
-      },
-      {
-        services: ['ZOOKEEPER'],
-        errorsExpected: []
-      },
-      {
-        services: ['HDFS'],
-        errorsExpected: ['serviceCheck_ZOOKEEPER']
-      },
-      {
-        services: ['HDFS', 'TEZ', 'ZOOKEEPER'],
-        errorsExpected: ['serviceCheck_YARN']
-      },
-      {
-        services: ['HDFS', 'ZOOKEEPER', 'FALCON', 'NAGIOS'],
-        errorsExpected: ['serviceCheck_OOZIE']
-      },
-      {
-        services: ['HDFS', 'ZOOKEEPER', 'GANGLIA', 'NAGIOS', 'HIVE'],
-        errorsExpected: ['serviceCheck_YARN']
-      },
-      {
-        services: ['HDFS', 'GLUSTERFS', 'ZOOKEEPER', 'HIVE'],
-        errorsExpected: ['serviceCheck_YARN', 'multipleDFS']
-      },
-      {
-        services: ['HDFS','ZOOKEEPER', 'NAGIOS', 'GANGLIA'],
-        errorsExpected: []
-      }
-    ];
+        {
+          services: ['HDFS','ZOOKEEPER'],
+          errorsExpected: ['ambariMetricsCheck']
+        },
+        {
+          services: ['ZOOKEEPER'],
+          errorsExpected: ['ambariMetricsCheck']
+        },
+        {
+          services: ['HDFS'],
+          errorsExpected: ['serviceCheck_ZOOKEEPER', 'ambariMetricsCheck']
+        },
+        {
+          services: ['HDFS', 'TEZ', 'ZOOKEEPER'],
+          errorsExpected: ['serviceCheck_YARN', 'ambariMetricsCheck']
+        },
+        {
+          services: ['HDFS', 'ZOOKEEPER', 'FALCON', 'NAGIOS'],
+          errorsExpected: ['serviceCheck_OOZIE', 'ambariMetricsCheck']
+        },
+        {
+          services: ['HDFS', 'ZOOKEEPER', 'GANGLIA', 'NAGIOS', 'HIVE'],
+          errorsExpected: ['serviceCheck_YARN', 'ambariMetricsCheck']
+        },
+        {
+          services: ['HDFS', 'GLUSTERFS', 'ZOOKEEPER', 'HIVE'],
+          errorsExpected: ['serviceCheck_YARN', 'multipleDFS', 'ambariMetricsCheck']
+        },
+        {
+          services: ['HDFS','ZOOKEEPER', 'NAGIOS', 'GANGLIA'],
+          errorsExpected: ['ambariMetricsCheck']
+        },
+        {
+          services: ['HDFS','ZOOKEEPER', 'AMS'],
+          errorsExpected: []
+        },
+        {
+          services: ['ZOOKEEPER', 'AMS'],
+          errorsExpected: []
+        },
+        {
+          services: ['HDFS', 'AMS'],
+          errorsExpected: ['serviceCheck_ZOOKEEPER']
+        },
+        {
+          services: ['HDFS', 'TEZ', 'ZOOKEEPER', 'AMS'],
+          errorsExpected: ['serviceCheck_YARN']
+        },
+        {
+          services: ['HDFS', 'ZOOKEEPER', 'FALCON', 'NAGIOS', 'AMS'],
+          errorsExpected: ['serviceCheck_OOZIE']
+        },
+        {
+          services: ['HDFS', 'ZOOKEEPER', 'GANGLIA', 'NAGIOS', 'HIVE', 'AMS'],
+          errorsExpected: ['serviceCheck_YARN']
+        },
+        {
+          services: ['HDFS', 'GLUSTERFS', 'ZOOKEEPER', 'HIVE', 'AMS'],
+          errorsExpected: ['serviceCheck_YARN', 'multipleDFS']
+        },
+        {
+          services: ['HDFS','ZOOKEEPER', 'NAGIOS', 'GANGLIA', 'AMS'],
+          errorsExpected: []
+        }
+      ],
+      controllerNames = ['installerController', 'addServiceController'],
+      wizardNames = {
+        installerController: 'Install Wizard',
+        addServiceController: 'Add Service Wizard'
+      };
+
+    controllerNames.forEach(function (name) {
+      tests.forEach(function(test) {
+        var errorsExpected = test.errorsExpected;
+        if (name != 'installerController') {
+          errorsExpected = test.errorsExpected.without('ambariMetricsCheck');
+        }
+        var message = '{0}, {1} selected validation should be {2}, errors: {3}'
+          .format(wizardNames[name], test.services.join(','), errorsExpected.length ? 'passed' : 'failed',
+            errorsExpected.length ? errorsExpected.join(',') : 'absent');
+        it(message, function() {
+          controller.clear();
+          controller.setProperties({
+            content: generateSelectedServicesContent(test.services),
+            wizardController: Em.Object.create({
+              name: name
+            })
+          });
+          controller.validate();
+          expect(controller.get('errorStack').mapProperty('id')).to.eql(errorsExpected.toArray());
+        });
+      })
+    });
 
-    tests.forEach(function(test) {
-      var message = '{0} selected validation should be {1}, errors with ids: {2} present'
-        .format(test.services.join(','), !!test.validationPassed ? 'passed' : 'failed', test.errorsExpected.join(','));
-      it(message, function() {
-        controller.clear();
-        controller.set('content', generateSelectedServicesContent(test.services));
-        controller.validate();
-        expect(controller.get('errorStack').mapProperty('id')).to.be.eql(test.errorsExpected);
-      });
-    })
   });
 
   describe('#onPrimaryPopupCallback()', function() {
@@ -467,4 +517,43 @@ describe('App.WizardStep4Controller', function () {
     })
   });
 
+  describe('#ambariMetricsValidation', function () {
+
+    var cases = [
+      {
+        services: ['HDFS'],
+        isAmbariMetricsWarning: false,
+        title: 'Ambari Metrics not available'
+      },
+      {
+        services: ['AMS'],
+        isAmbariMetricsSelected: false,
+        isAmbariMetricsWarning: true,
+        title: 'Ambari Metrics not selected'
+      },
+      {
+        services: ['AMS'],
+        isAmbariMetricsSelected: true,
+        isAmbariMetricsWarning: false,
+        title: 'Ambari Metrics selected'
+      }
+    ];
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        controller.clear();
+        controller.set('content', generateSelectedServicesContent(item.services));
+        var ams = controller.findProperty('serviceName', 'AMS');
+        if (item.services.contains('AMS')) {
+          ams.set('isSelected', item.isAmbariMetricsSelected);
+        } else {
+          controller.removeObject(ams);
+        }
+        controller.ambariMetricsValidation();
+        expect(controller.get('errorStack').mapProperty('id').contains('ambariMetricsCheck')).to.equal(item.isAmbariMetricsWarning);
+      });
+    });
+
+  });
+
 });