瀏覽代碼

AMBARI-2991. NameNode HA Wizard: Prompt for Nameservice ID in Get Started page. (Aleksandr Kovalenko)

Yusaku Sako 11 年之前
父節點
當前提交
20a73bf9dd

+ 12 - 1
ambari-web/app/controllers/main/admin/highAvailability/step1_controller.js

@@ -21,6 +21,17 @@ var App = require('app');
 require('controllers/main/admin/misc_controller');
 
 App.HighAvailabilityWizardStep1Controller = App.MainAdminMiscController.extend({
-  name:"highAvailabilityWizardStep1Controller"
+  name: "highAvailabilityWizardStep1Controller",
+
+  isNameServiceIdValid: function () {
+    return /^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])$/.test(this.get('content.nameServiceId'));
+  }.property('content.nameServiceId'),
+
+  next: function () {
+    if (this.get('isNameServiceIdValid')) {
+      App.router.send('next');
+    }
+  }
+
 });
 

+ 10 - 9
ambari-web/app/controllers/main/admin/highAvailability/step5_controller.js

@@ -105,23 +105,24 @@ App.HighAvailabilityWizardStep5Controller = App.HighAvailabilityProgressPageCont
     var newNameNodeHost = this.get('content.masterComponentHosts').findProperty('isAddNameNode').hostName;
     var journalNodeHosts = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
     var zooKeeperHosts = this.get('content.masterComponentHosts').filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName');
+    var nameServiceId = this.get('content.nameServiceId');
 
     //hdfs-site configs changes
-    hdfsSiteProperties['dfs.nameservices'] = 'mycluster';
-    hdfsSiteProperties['dfs.ha.namenodes.mycluster'] = 'nn1,nn2';
-    hdfsSiteProperties['dfs.namenode.rpc-address.mycluster.nn1'] = currentNameNodeHost + ':8020';
-    hdfsSiteProperties['dfs.namenode.rpc-address.mycluster.nn2'] = newNameNodeHost + ':8020';
-    hdfsSiteProperties['dfs.namenode.http-address.mycluster.nn1'] = currentNameNodeHost + ':50070';
-    hdfsSiteProperties['dfs.namenode.http-address.mycluster.nn2'] = newNameNodeHost + ':50070';
-    hdfsSiteProperties['dfs.namenode.shared.edits.dir'] = 'qjournal://' + journalNodeHosts[0] + ':8485;' + journalNodeHosts[1] + ':8485;' + journalNodeHosts[2] + ':8485/mycluster';
-    hdfsSiteProperties['dfs.client.failover.proxy.provider.mycluster'] = 'org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider';
+    hdfsSiteProperties['dfs.nameservices'] = nameServiceId;
+    hdfsSiteProperties['dfs.ha.namenodes.' + nameServiceId] = 'nn1,nn2';
+    hdfsSiteProperties['dfs.namenode.rpc-address.' + nameServiceId + '.nn1'] = currentNameNodeHost + ':8020';
+    hdfsSiteProperties['dfs.namenode.rpc-address.' + nameServiceId + '.nn2'] = newNameNodeHost + ':8020';
+    hdfsSiteProperties['dfs.namenode.http-address.' + nameServiceId + '.nn1'] = currentNameNodeHost + ':50070';
+    hdfsSiteProperties['dfs.namenode.http-address.' + nameServiceId + '.nn2'] = newNameNodeHost + ':50070';
+    hdfsSiteProperties['dfs.namenode.shared.edits.dir'] = 'qjournal://' + journalNodeHosts[0] + ':8485;' + journalNodeHosts[1] + ':8485;' + journalNodeHosts[2] + ':8485/' + nameServiceId;
+    hdfsSiteProperties['dfs.client.failover.proxy.provider.' + nameServiceId] = 'org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider';
     hdfsSiteProperties['dfs.ha.fencing.methods'] = 'shell(/bin/true)';
     hdfsSiteProperties['dfs.journalnode.edits.dir'] = '/grid/0/hdfs/journal';
     hdfsSiteProperties['dfs.ha.automatic-failover.enabled'] = 'true';
 
     //core-site configs changes
     coreSiteProperties['ha.zookeeper.quorum'] = zooKeeperHosts[0] + ':2181,' + zooKeeperHosts[1] + ':2181,' + zooKeeperHosts[2] + ':2181';
-    coreSiteProperties['fs.defaultFS'] = 'hdfs://mycluster';
+    coreSiteProperties['fs.defaultFS'] = 'hdfs://' + nameServiceId;
     this.set('configsSaved', false);
     App.ajax.send({
       name: 'admin.high_availability.save_configs',

+ 13 - 1
ambari-web/app/controllers/main/admin/highAvailability/wizard_controller.js

@@ -38,7 +38,8 @@ App.HighAvailabilityWizardController = App.WizardController.extend({
     slaveComponentHosts: null,
     masterComponentHosts: null,
     serviceName: 'MISC',
-    hdfsUser:"hdfs"
+    hdfsUser:"hdfs",
+    nameServiceId: ''
   }),
 
   /**
@@ -172,6 +173,16 @@ App.HighAvailabilityWizardController = App.WizardController.extend({
     this.set('content.requestIds', requestIds);
   },
 
+  saveNameServiceId: function(nameServiceId){
+    App.db.setHighAvailabilityWizardNameServiceId(nameServiceId);
+    this.set('content.nameServiceId', nameServiceId);
+  },
+
+  loadNameServiceId: function(){
+    var nameServiceId = App.db.getHighAvailabilityWizardNameServiceId();
+    this.set('content.nameServiceId', nameServiceId);
+  },
+
   /**
    * Load data for all steps until <code>current step</code>
    */
@@ -183,6 +194,7 @@ App.HighAvailabilityWizardController = App.WizardController.extend({
       case '7':
       case '6':
       case '5':
+        this.loadNameServiceId();
         this.loadTasksStatuses();
         this.loadRequestIds();
       case '4':

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

@@ -649,6 +649,9 @@ Em.I18n.translations = {
   'admin.highAvailability.wizard.progressPage.notice.failed':'You can click on the Retry button to retry failed tasks.',
   'admin.highAvailability.wizard.progressPage.header':'Deploy',
   'admin.highAvailability.wizard.step1.header':'Get Started',
+  'admin.highAvailability.wizard.step1.nameserviceid.tooltip.title':'Nameservice ID',
+  'admin.highAvailability.wizard.step1.nameserviceid.tooltip.content':'This will be the ID for the NameNode HA cluster. For example, if you set Nameservice ID to <b>mycluster</b>, the logical URI for HDFS will be <b>hdfs://mycluster</b>.',
+  'admin.highAvailability.wizard.step1.nameserviceid':'Nameservice ID',
   'admin.highAvailability.wizard.step2.header':'Select Hosts',
   'admin.highAvailability.wizard.step3.header':'Review',
   'admin.highAvailability.wizard.step4.header':'Create Checkpoint',

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

@@ -73,6 +73,8 @@ module.exports = Em.Route.extend({
       })
     },
     next: function (router) {
+      var controller = router.get('highAvailabilityWizardController');
+      controller.saveNameServiceId(router.get('highAvailabilityWizardStep1Controller.content.nameServiceId'));
       router.transitionTo('step2');
     }
   }),

+ 5 - 0
ambari-web/app/styles/application.less

@@ -475,6 +475,11 @@ h1 {
       margin-left: 0;
     }
   }
+  #ha-step1 {
+    .nameserviceid-input {
+      display: inline-block;
+    }
+  }
 }
 
 #stack-upgrade {

+ 17 - 6
ambari-web/app/templates/main/admin/highAvailability/step1.hbs

@@ -15,11 +15,22 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 }}
+<div id="ha-step1">
+  <h2>{{t admin.highAvailability.wizard.step1.header}}</h2>
 
-<h2>{{t admin.highAvailability.wizard.step1.header}}</h2>
-<p class="alert alert-info">
-  {{t admin.highAvailability.wizard.step1.body}}
-</p>
-<div class="btn-area">
-  <a class="btn btn-success pull-right" {{action next}}>{{t common.next}} &rarr;</a>
+  <p class="alert alert-info">
+    {{t admin.highAvailability.wizard.step1.body}}
+  </p>
+
+  <div {{bindAttr class=":control-group view.showInputError:error :form-horizontal :nameserviceid-input"}} rel="popover" {{translateAttr title="admin.highAvailability.wizard.step1.nameserviceid.tooltip.title"
+       data-content="admin.highAvailability.wizard.step1.nameserviceid.tooltip.content"}}>
+    <label class="control-label">{{t admin.highAvailability.wizard.step1.nameserviceid}}:</label>
+
+    <div class="controls">
+      {{view Ember.TextField valueBinding="content.nameServiceId"}}
+    </div>
+  </div>
+  <div class="btn-area">
+    <a {{bindAttr class=":btn controller.isNameServiceIdValid::disabled :btn-success :pull-right"}} {{action next target="controller"}}>{{t common.next}} &rarr;</a>
+  </div>
 </div>

+ 11 - 0
ambari-web/app/utils/db.js

@@ -362,6 +362,12 @@ App.db.setHighAvailabilityWizardRequestIds = function (requestIds) {
   localStorage.setObject('ambari', App.db.data);
 };
 
+App.db.setHighAvailabilityWizardNameServiceId = function (nameServiceId) {
+  App.db.data = localStorage.getObject('ambari');
+  App.db.data.HighAvailabilityWizard.nameServiceId = nameServiceId;
+  localStorage.setObject('ambari', App.db.data);
+};
+
 /*
  *  getter methods
  */
@@ -585,4 +591,9 @@ App.db.getHighAvailabilityWizardRequestIds = function () {
   return App.db.data.HighAvailabilityWizard.requestIds;
 };
 
+App.db.getHighAvailabilityWizardNameServiceId = function () {
+  App.db.data = localStorage.getObject('ambari');
+  return App.db.data.HighAvailabilityWizard.nameServiceId;
+};
+
 module.exports = App.db;

+ 6 - 1
ambari-web/app/views/main/admin/highAvailability/step1_view.js

@@ -24,7 +24,12 @@ App.HighAvailabilityWizardStep1View = Em.View.extend({
   templateName: require('templates/main/admin/highAvailability/step1'),
 
   didInsertElement: function() {
+    App.popover($("[rel=popover]"), {'placement': 'right', 'trigger': 'hover'});
     this.get('controller').loadUsers();
-  }
+  },
+
+  showInputError: function () {
+    return !this.get('controller.isNameServiceIdValid') && this.get('controller.content.nameServiceId').length;
+  }.property('controller.isNameServiceIdValid', 'controller.nameServiceId')
 
 });