Browse Source

AMBARI-3143 NameNode HA Wizard: Add check to make sure that the JournalNodes have been initialized. (atkach)

atkach 12 years ago
parent
commit
5700280279

+ 51 - 1
ambari-web/app/controllers/main/admin/highAvailability/step6_controller.js

@@ -20,7 +20,57 @@ var App = require('app');
 
 App.HighAvailabilityWizardStep6Controller = Em.Controller.extend({
 
-  name:"highAvailabilityWizardStep6Controller"
+  name:"highAvailabilityWizardStep6Controller",
+
+  POLL_INTERVAL: 1000,
+
+  isNextEnabled: function(){
+    //only 3 JournalNodes could be installed
+    return (this.get('initJnCounter') === 3);
+  }.property('initJnCounter'),
+
+  initJnCounter: 0,
+
+  pullCheckPointStatus: function () {
+    this.set('initJnCounter', 0);
+    var hostNames = this.get('content.masterComponentHosts').filterProperty('component', "JOURNALNODE").mapProperty('hostName');
+    hostNames.forEach(function (hostName) {
+      this.pullEachJnStatus(hostName);
+    }, this);
+  },
+
+  pullEachJnStatus: function(hostName){
+    App.ajax.send({
+      name: 'admin.high_availability.getJnCheckPointStatus',
+      sender: this,
+      data: {
+        hostName: hostName
+      },
+      success: 'checkJnCheckPointStatus'
+    });
+  },
+
+  checkJnCheckPointStatus: function (data) {
+    var self = this;
+    var journalStatusInfo;
+    if (data.metrics) {
+      journalStatusInfo = $.parseJSON(data.metrics.dfs.journalnode.journalsStatus);
+      if (journalStatusInfo[this.get('content.nameServiceId')] && journalStatusInfo[this.get('content.nameServiceId')].Formatted === "true") {
+        this.set("initJnCounter", (this.get('initJnCounter') + 1));
+        return;
+      }
+    }
+
+    window.setTimeout(function () {
+      self.pullEachJnStatus(data.HostRoles.host_name);
+    }, self.POLL_INTERVAL);
+  },
+
+  done: function () {
+    if (this.get('isNextEnabled')) {
+      App.router.send('next');
+    }
+  }
 
 })
 

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

@@ -699,6 +699,7 @@ Em.I18n.translations = {
   'admin.highAvailability.wizard.step4.ckNotCreated':'Checkpoint not created yet',
   'admin.highAvailability.wizard.step4.ckCreated':'Checkpoint created',
   'admin.highAvailability.wizard.step6.jsNoInit':'JournalNodes not initialized yet',
+  'admin.highAvailability.wizard.step6.jsInit':'JournalNodes initialized',
   'admin.highAvailability.wizard.step8.metaNoInit':'Metadata not initialized yet',
 
   'admin.highAvailability.rollback.header':'Disable NameNode HA Wizard',

+ 2 - 2
ambari-web/app/templates/main/admin/highAvailability/step6.hbs

@@ -21,7 +21,7 @@
     {{{view.step6BodyText}}}
   </div>
   <div class="btn-area">
-    <a class="btn btn-success pull-right" {{action next}}>{{t common.next}} &rarr;</a>
-    <span class="pull-right btn-extra-info">{{t admin.highAvailability.wizard.step6.jsNoInit}}</span>
+    <a {{bindAttr class="controller.isNextEnabled::disabled :btn :btn-success :pull-right"}} {{action done target="controller"}}>{{t common.next}} &rarr;</a>
+    <span class="pull-right btn-extra-info">{{view.jnCheckPointText}}</span>
   </div>
 </div>

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

@@ -621,6 +621,10 @@ var urls = {
     'mock': '',
     'type': 'GET'
   },
+  'admin.high_availability.getJnCheckPointStatus': {
+    'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
+    'mock': ''
+  },
   'admin.high_availability.create_component': {
     'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
     'mock': '',

+ 14 - 1
ambari-web/app/views/main/admin/highAvailability/step6_view.js

@@ -23,9 +23,22 @@ App.HighAvailabilityWizardStep6View = Em.View.extend({
 
   templateName: require('templates/main/admin/highAvailability/step6'),
 
+  didInsertElement: function() {
+    this.get('controller').pullCheckPointStatus();
+  },
+
   step6BodyText: function () {
     var nN = this.get('controller.content.masterComponentHosts').findProperty('isCurNameNode', true);
     return Em.I18n.t('admin.highAvailability.wizard.step6.body').format(this.get('controller.content.hdfsUser'), nN.hostName);
-  }.property('controller.content.masterComponentHosts')
+  }.property('controller.content.masterComponentHosts'),
+
+  jnCheckPointText: function () {
+    var curStatus = this.get('controller.isNextEnabled');
+    if (curStatus) {
+      return Em.I18n.t('admin.highAvailability.wizard.step6.jsInit');
+    } else {
+      return Em.I18n.t('admin.highAvailability.wizard.step6.jsNoInit');
+    }
+  }.property('controller.isNextEnabled')
 
 });