瀏覽代碼

AMBARI-16729. When selecting cluster capacity to 100% for llap queue, user is not shown warning (alexantonenko)

Alex Antonenko 9 年之前
父節點
當前提交
5e2fe569d6

+ 1 - 0
ambari-web/app/messages.js

@@ -3004,6 +3004,7 @@ Em.I18n.translations = {
   'config.infoMessage.wrong.value.for.widget': 'Configuration value cannot be converted into UI control value',
   'config.warnMessage.outOfBoundaries.greater': 'Values greater than {0} are not recommended',
   'config.warnMessage.outOfBoundaries.less': 'Values smaller than {0} are not recommended',
+  'config.warnMessage.llap_queue_capacity.max': 'LLAP will consume entire Yarn queue',
 
   'errorMessage.config.required': 'This is required',
   'errorMessage.config.number.integer': 'Must contain digits only',

+ 7 - 0
ambari-web/app/models/configs/objects/service_config_property.js

@@ -318,6 +318,13 @@ App.ServiceConfigProperty = Em.Object.extend({
       this.set('errorMessage', ''); // do not perform validation for not editable configs
     } else if ((typeof this.get('value') != 'object') && ((this.get('value') + '').length === 0)) {
       this.set('errorMessage', (this.get('isRequired') && this.get('widgetType') != 'test-db-connection') ? Em.I18n.t('errorMessage.config.required') : '');
+    } else if (this.get('name') === 'llap_queue_capacity') {
+      if (!isNaN(parseInt(this.get('value'), 10)) && parseInt(this.get('value'), 10) === 100) {
+        this.set('warnMessage', Em.I18n.t('config.warnMessage.llap_queue_capacity.max'));
+      } else {
+        this.set('warnMessage', '');
+        this.set('errorMessage', this.validator(this.get('value'), this.get('name'), this.get('retypedPassword')));
+      }
     } else {
       this.set('errorMessage', this.validator(this.get('value'), this.get('name'), this.get('retypedPassword')));
     }

+ 5 - 1
ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js

@@ -645,7 +645,11 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
           return false;
         }
       }
-      this.updateWarningsForCompatibilityWithWidget('');
+      if (this.get('config.name') === 'llap_queue_capacity') {
+        this.get('config').validate();
+      } else {
+        this.updateWarningsForCompatibilityWithWidget('');
+      }
       return true;
     }
     return false;

+ 24 - 1
ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js

@@ -581,7 +581,7 @@ describe('App.SliderConfigWidgetView', function () {
     var stackConfigProperty = null;
 
     beforeEach(function() {
-      viewInt.set('config', {});
+      viewInt.set('config', App.ServiceConfigProperty.create({}));
       stackConfigProperty = {name: 'p1', widget: { units: [ { 'unit-name': "int"}]}, valueAttributes: {minimum: 1, maximum: 10, increment_step: 4, type: 'int'}};
       viewInt.set('config.stackConfigProperty', stackConfigProperty);
       viewInt.set('config.isValid', true);
@@ -634,6 +634,29 @@ describe('App.SliderConfigWidgetView', function () {
       expect(viewInt.get('warnMessage')).to.equal('');
       expect(viewInt.get('issueMessage')).to.equal('');
     });
+
+    describe('llap_queue_capacity property', function() {
+      beforeEach(function() {
+        viewInt.set('config.name', 'llap_queue_capacity');
+      });
+      it('should validate and warn about llap issue when value is 100%', function() {
+        viewInt.set('config.stackConfigProperty.valueAttributes.maximum', 100);
+        viewInt.set('config.value', '100');
+        viewInt.set('config.errorMessage', '');
+        viewInt.set('config.warnMessage', '');
+        assert.isTrue(viewInt.isValueCompatibleWithWidget(), 'value should be compatible with widget');
+        assert.equal(viewInt.get('config.warnMessage'), Em.I18n.t('config.warnMessage.llap_queue_capacity.max'), 'warn message validation');
+      });
+
+      it('should pass validation because llap < 100', function() {
+        viewInt.set('config.stackConfigProperty.valueAttributes.maximum', 100);
+        viewInt.set('config.value', '99');
+        viewInt.set('config.errorMessage', '');
+        viewInt.set('config.warnMessage', '');
+        assert.isTrue(viewInt.isValueCompatibleWithWidget(), 'value should be compatible with widget');
+        assert.equal(viewInt.get('config.warnMessage'), '', 'warn message validation');
+      });
+    });
   });
 
   describe('#formatTickLabel', function () {