Sfoglia il codice sorgente

AMBARI-10568. Rolling Restart: batch size is fixed and cannot be changed. (akovalenko)

Aleksandr Kovalenko 10 anni fa
parent
commit
77e77010c8

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

@@ -2478,6 +2478,7 @@ Em.I18n.translations = {
   'rollingrestart.dialog.err.invalid.batchsize': 'Invalid restart batch size: {0}',
   'rollingrestart.dialog.err.invalid.waitTime': 'Invalid wait time between batches: {0}',
   'rollingrestart.dialog.err.invalid.toleratesize': 'Invalid failure toleration count: {0}',
+  'rollingrestart.dialog.warn.datanode.batch.size': 'Restarting more than one DataNode at a time is not recommended. Doing so can lead to data unavailability and/or possible loss of data being actively written to HFDS.',
   'rollingrestart.dialog.msg.serviceNotInMM':'Note: This will trigger alerts. To suppress alerts, turn on Maintenance Mode for {0} prior to triggering a rolling restart',
   'rollingrestart.dialog.msg.staleConfigsOnly': 'Only restart {0}s with stale configs',
   'rollingrestart.rest.context': 'Rolling Restart of {0}s - batch {1} of {2}',

+ 10 - 1
ambari-web/app/templates/common/rolling_restart_view.hbs

@@ -71,7 +71,7 @@
     <div class="spinner"></div>
   {{/if}}
   {{#if view.errors}}
-    <div class="alert alert-warn">
+    <div class="alert alert-error">
       <ul>
       {{#each error in view.errors}}
         <li>{{error}}</li>
@@ -79,4 +79,13 @@
       </ul>
     </div>
   {{/if}}
+  {{#if view.warnings}}
+    <div class="alert alert-warn">
+      <ul>
+      {{#each warning in view.warnings}}
+        <li>{{warning}}</li>
+      {{/each}}
+      </ul>
+    </div>
+  {{/if}}
 </div>

+ 21 - 4
ambari-web/app/views/common/rolling_restart_view.js

@@ -91,6 +91,11 @@ App.RollingRestartView = Em.View.extend({
    * @type {Array}
    */
   errors : [],
+  /**
+   * List of warnings in batch-request properties, do not disable submit button
+   * @type {Array}
+   */
+  warnings : [],
   /**
    * Set initial values for batch-request properties
    */
@@ -98,7 +103,7 @@ App.RollingRestartView = Em.View.extend({
     if (this.get('batchSize') == -1 && this.get('interBatchWaitTimeSeconds') == -1 && this.get('tolerateSize') == -1) {
       var restartCount = this.get('restartHostComponents.length');
       var batchSize = 1;
-      if (restartCount > 10) {
+      if (restartCount > 10 && this.get('hostComponentName') !== 'DATANODE') {
         batchSize = Math.ceil(restartCount / 10);
       }
       var tolerateCount = batchSize;
@@ -115,16 +120,27 @@ App.RollingRestartView = Em.View.extend({
    */
   validate : function() {
     var displayName = this.get('hostComponentDisplayName');
+    var componentName = this.get('hostComponentName');
     var totalCount = this.get('restartHostComponents.length');
     var bs = this.get('batchSize');
     var ts = this.get('tolerateSize');
     var wait = this.get('interBatchWaitTimeSeconds');
     var errors = [];
+    var warnings = [];
+    var bsError, tsError, waitError;
     if (totalCount < 1) {
       errors.push(Em.I18n.t('rollingrestart.dialog.msg.noRestartHosts').format(displayName));
     } else {
-      var bsError = numberUtils.validateInteger(bs, 1, totalCount);
-      var tsError = numberUtils.validateInteger(ts, 0, totalCount);
+      if (componentName === 'DATANODE') {
+        // specific case for DataNodes batch size is more than 1
+        if (bs > 1) {
+          warnings.push(Em.I18n.t('rollingrestart.dialog.warn.datanode.batch.size'));
+        }
+        bsError = numberUtils.validateInteger(bs, 1, NaN);
+      } else {
+        bsError = numberUtils.validateInteger(bs, 1, totalCount);
+      }
+      tsError = numberUtils.validateInteger(ts, 0, totalCount);
       if (bsError != null) {
         errors.push(Em.I18n.t('rollingrestart.dialog.err.invalid.batchsize').format(bsError));
       }
@@ -132,11 +148,12 @@ App.RollingRestartView = Em.View.extend({
         errors.push(Em.I18n.t('rollingrestart.dialog.err.invalid.toleratesize').format(tsError));
       }
     }
-    var waitError = numberUtils.validateInteger(wait, 0, NaN);
+    waitError = numberUtils.validateInteger(wait, 0, NaN);
     if (waitError != null) {
       errors.push(Em.I18n.t('rollingrestart.dialog.err.invalid.waitTime').format(waitError));
     }
     this.set('errors', errors);
+    this.set('warnings', warnings);
   }.observes('batchSize', 'interBatchWaitTimeSeconds', 'tolerateSize', 'restartHostComponents', 'hostComponentDisplayName'),
 
   /**

+ 12 - 0
ambari-web/test/views/common/rolling_restart_view_test.js

@@ -35,6 +35,7 @@ describe('App.RollingRestartView', function () {
         }
       },
       {
+        hostComponentName: 'NOT_DATANODE',
         restartHostComponents: new Array(10),
         result: {
           batchSize: 1,
@@ -42,6 +43,7 @@ describe('App.RollingRestartView', function () {
         }
       },
       {
+        hostComponentName: 'NOT_DATANODE',
         restartHostComponents: new Array(11),
         result: {
           batchSize: 2,
@@ -49,11 +51,20 @@ describe('App.RollingRestartView', function () {
         }
       },
       {
+        hostComponentName: 'NOT_DATANODE',
         restartHostComponents: new Array(20),
         result: {
           batchSize: 2,
           tolerateSize: 2
         }
+      },
+      {
+        hostComponentName: 'DATANODE',
+        restartHostComponents: new Array(20),
+        result: {
+          batchSize: 1,
+          tolerateSize: 1
+        }
       }
     ];
 
@@ -62,6 +73,7 @@ describe('App.RollingRestartView', function () {
         view.set('batchSize', -1);
         view.set('interBatchWaitTimeSeconds', -1);
         view.set('tolerateSize', -1);
+        view.set('hostComponentName', test.hostComponentName);
         view.set('restartHostComponents', test.restartHostComponents);
         view.initialize();
         expect(view.get('batchSize')).to.equal(test.result.batchSize);