Browse Source

AMBARI-3038. NameNode HA Wizard: Add check to make sure that the checkpoint has been created in Create Checkpoint Page. (alexantonenko via yusaku)

Yusaku Sako 11 years ago
parent
commit
7d968d3929

+ 39 - 1
ambari-web/app/controllers/main/admin/highAvailability/step4_controller.js

@@ -22,7 +22,45 @@ require('controllers/main/admin/misc_controller');
 
 App.HighAvailabilityWizardStep4Controller = Em.Controller.extend({
 
-  name:"highAvailabilityWizardStep4Controller"
+  name:"highAvailabilityWizardStep4Controller",
+
+  POLL_INTERVAL: 1000,
+
+  isNextEnabled: false,
+
+  pullCheckPointStatus: function () {
+    var hostName = this.get('content.masterComponentHosts').findProperty('isCurNameNode', true).hostName;
+    App.ajax.send({
+      name: 'admin.high_availability.getNnCheckPointStatus',
+      sender: this,
+      data: {
+        hostName: hostName
+      },
+      success: 'checkNnCheckPointStatus'
+    });
+  },
+
+  checkNnCheckPointStatus: function (data) {
+    var self = this;
+    var journalTransactionInfo =  $.parseJSON(data.metrics.dfs.namenode.JournalTransactionInfo);
+    journalTransactionInfo = parseInt(journalTransactionInfo.LastAppliedOrWrittenTxId) - parseInt(journalTransactionInfo.MostRecentCheckpointTxId);
+    if(journalTransactionInfo <= 1){
+      this.set("isNextEnabled", true);
+      return;
+    }
+
+    window.setTimeout(function () {
+      self.pullCheckPointStatus()
+    }, self.POLL_INTERVAL);
+  },
+
+  done: function () {
+    if (this.get('isNextEnabled')) {
+      App.router.send('next');
+    }
+  }
+
+
 
 })
 

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

@@ -687,6 +687,7 @@ Em.I18n.translations = {
   'admin.highAvailability.wizard.step3.sn':'Existing Secondary NameNode on {0} will be disabled.',
   'admin.highAvailability.wizard.step3.jn':'JournalNode will be installed on following hosts:',
   '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.step8.metaNoInit':'Metadata not initialized yet',
 

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

@@ -21,7 +21,7 @@
     {{{view.step4BodyText}}}
   </p>
   <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.step4.ckNotCreated}}</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.nnCheckPointText}}</span>
   </div>
 </div>

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

@@ -606,6 +606,11 @@ var urls = {
     'mock': '',
     'type': 'GET'
   },
+  'admin.high_availability.getNnCheckPointStatus': {
+    'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
+    'mock': '',
+    'type': 'GET'
+  },
   'admin.high_availability.create_component': {
     'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
     'mock': '',

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

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