Преглед на файлове

AMBARI-3546. NameNode HA Rollback: Create Step 1 (alexantonenko)

Alex Antonenko преди 11 години
родител
ревизия
e676819f5e

+ 39 - 94
ambari-web/app/controllers/main/admin/rollbackHA/rollback_wizard_controller.js

@@ -33,16 +33,24 @@ App.RollbackHighAvailabilityWizardController = App.WizardController.extend({
   content: Em.Object.create({
     controllerName: 'RollbackHighAvailabilityWizardController',
     cluster: null,
-    hosts: null,
-    services: null,
-    slaveComponentHosts: null,
     masterComponentHosts: null,
     serviceName: 'MISC',
     hdfsUser:"hdfs",
     nameServiceId: '',
-    failedTask : null
+    selectedAddNNHost : null,
+    selectedSNNHost : null
   }),
 
+  setCurrentStep: function (currentStep, completed) {
+    this._super(currentStep, completed);
+    App.clusterStatus.setClusterStatus({
+      clusterName: this.get('content.cluster.name'),
+      clusterState: 'ROLLBACK_HIGH_AVAILABILITY',
+      wizardControllerName: 'rollbackHighAvailabilityWizardController',
+      localdb: App.db.data
+    });
+  },
+
   /**
    * return new object extended from clusterStatusTemplate
    * @return Object
@@ -51,68 +59,6 @@ App.RollbackHighAvailabilityWizardController = App.WizardController.extend({
     return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.router.getClusterName()});
   },
 
-  /**
-   * Load services data from server.
-   */
-  loadServicesFromServer: function() {
-    var displayOrderConfig = require('data/services');
-    var apiUrl = App.get('stack2VersionURL');
-    var apiService = this.loadServiceComponents(displayOrderConfig, apiUrl);
-    //
-    apiService.forEach(function(item, index){
-      apiService[index].isSelected = App.Service.find().someProperty('id', item.serviceName);
-      apiService[index].isDisabled = apiService[index].isSelected;
-      apiService[index].isInstalled = apiService[index].isSelected;
-    });
-    this.set('content.services', apiService);
-    App.db.setService(apiService);
-  },
-
-  /**
-   * Load confirmed hosts.
-   * Will be used at <code>Assign Masters(step5)</code> step
-   */
-  loadConfirmedHosts: function(){
-    var hosts = App.db.getHosts();
-    if(!hosts || !hosts.length){
-      var hosts = {};
-
-      App.Host.find().forEach(function(item){
-        hosts[item.get('id')] = {
-          name: item.get('id'),
-          cpu: item.get('cpu'),
-          memory: item.get('memory'),
-          disk_info: item.get('diskInfo'),
-          bootStatus: "REGISTERED",
-          isInstalled: true
-        };
-      });
-      App.db.setHosts(hosts);
-    }
-
-    this.set('content.hosts', hosts);
-    console.log('ReassignMasterController.loadConfirmedHosts: loaded hosts', hosts);
-  },
-
-  /**
-   * Load master component hosts data for using in required step controllers
-   */
-  loadMasterComponentHosts: function () {
-    var masterComponentHosts = App.db.getMasterComponentHosts();
-    if(!masterComponentHosts){
-      masterComponentHosts = [];
-      App.HostComponent.find().filterProperty('isMaster', true).forEach(function(item){
-        masterComponentHosts.push({
-          component: item.get('componentName'),
-          hostName: item.get('host.hostName'),
-          isInstalled: true
-        })
-      });
-
-    }
-    this.set("content.masterComponentHosts", masterComponentHosts);
-    console.log("ReassignMasterController.loadMasterComponentHosts: loaded hosts ", masterComponentHosts);
-  },
 
   /**
    * save status of the cluster.
@@ -132,38 +78,11 @@ App.RollbackHighAvailabilityWizardController = App.WizardController.extend({
     this.save('cluster');
   },
 
-  /**
-   * Save Master Component Hosts data to Main Controller
-   * @param stepController App.WizardStep5Controller
-   */
-  saveMasterComponentHosts: function (stepController) {
-    var obj = stepController.get('selectedServicesMasters');
-    var masterComponentHosts = [];
-    obj.forEach(function (_component) {
-      masterComponentHosts.push({
-        display_name: _component.get('display_name'),
-        component: _component.get('component_name'),
-        hostName: _component.get('selectedHost'),
-        serviceId: _component.get('serviceId'),
-        isCurNameNode: _component.get('isCurNameNode'),
-        isAddNameNode: _component.get('isAddNameNode'),
-        isInstalled: true
-      });
-    });
-    App.db.setMasterComponentHosts(masterComponentHosts);
-    this.set('content.masterComponentHosts', masterComponentHosts);
-  },
-
   saveTasksStatuses: function(statuses){
     App.db.setRollbackHighAvailabilityWizardTasksStatuses(statuses);
     this.set('content.tasksStatuses', statuses);
   },
 
-  loadTasksStatuses: function(){
-    var statuses = App.db.getRollbackHighAvailabilityWizardTasksStatuses();
-    this.set('content.tasksStatuses', statuses);
-  },
-
   saveRequestIds: function(requestIds){
     App.db.setRollbackHighAvailabilityWizardRequestIds(requestIds);
     this.set('content.requestIds', requestIds);
@@ -174,6 +93,31 @@ App.RollbackHighAvailabilityWizardController = App.WizardController.extend({
     this.set('content.logs', logs);
   },
 
+  saveSelectedSNN: function(addNN){
+    App.db.setRollBackHighAvailabilityWizardSelectedSNN(addNN);
+    this.set('content.selectedAddNN', addNN);
+  },
+
+  saveSelectedAddNN: function(sNN){
+    App.db.setRollBackHighAvailabilityWizardSelectedAddNN(sNN);
+    this.set('content.selectedSNN', sNN);
+  },
+
+  loadAddNNHost: function () {
+    var addNNHost = App.db.getRollBackHighAvailabilityWizardAddNNHost();
+    this.set('content.addNNHost', addNNHost);
+  },
+
+  loadSNNHost: function () {
+    var sNNHost = App.db.getRollBackHighAvailabilityWizardSNNHost();
+    this.set('content.sNNHost', sNNHost);
+  },
+
+  loadTasksStatuses: function(){
+    var sNNHost = App.db.getRollbackHighAvailabilityWizardTasksStatuses();
+    this.set('content.tasksStatuses', sNNHost);
+  },
+
   loadRequestIds: function(){
     var requestIds = App.db.getRollbackHighAvailabilityWizardRequestIds();
     this.set('content.requestIds', requestIds);
@@ -194,8 +138,9 @@ App.RollbackHighAvailabilityWizardController = App.WizardController.extend({
       case '2':
         //this.loadServicesFromServer();
         //this.loadMasterComponentHosts();
-        //this.loadConfirmedHosts();
       case '1':
+        this.loadSNNHost();
+        this.loadAddNNHost();
         this.load('cluster');
     }
   },

+ 2 - 0
ambari-web/app/controllers/main/admin/rollbackHA/step1_controller.js

@@ -19,6 +19,8 @@
 var App = require('app');
 
 App.RollbackHighAvailabilityWizardStep1Controller = Em.Controller.extend({
+
   name:"rollbackHighAvailabilityWizardStep1Controller"
+
 });
 

+ 11 - 17
ambari-web/app/routes/high_availability_routes.js

@@ -54,28 +54,22 @@ module.exports = Em.Route.extend({
         onClose: function () {
           var currStep = App.router.get('highAvailabilityWizardController.currentStep');
           var highAvailabilityProgressPageController = App.router.get('highAvailabilityProgressPageController');
-          if (currStep == "6" && App.supports.autoRollbackHA){
-            highAvailabilityProgressPageController.tasks.push({
-              command: "startZooKeeperServers",
-              status: "FAILED"
-            })
-            highAvailabilityProgressPageController.rollback();
-          }else if(currStep == "8" && App.supports.autoRollbackHA){
-            highAvailabilityProgressPageController.tasks.push({
-              command: "startSecondNameNode",
-              status: "FAILED"
-            })
-            highAvailabilityProgressPageController.rollback();
-          }else{
-            if(parseInt(currStep) > 4 && !App.supports.autoRollbackHA){
+
+          if(parseInt(currStep) > 4){
+            if(!App.supports.autoRollbackHA){
               highAvailabilityProgressPageController.manualRollback();
-            }else {
+            }else{
               this.hide();
               App.router.get('highAvailabilityWizardController').setCurrentStep('1');
-              App.router.get('updateController').set('isWorking', true);
-              App.router.transitionTo('main.admin.adminHighAvailability');
+              App.router.transitionTo('rollbackHighAvailability');
             }
+          }else {
+            this.hide();
+            App.router.get('highAvailabilityWizardController').setCurrentStep('1');
+            App.router.get('updateController').set('isWorking', true);
+            App.router.transitionTo('main.admin.adminHighAvailability');
           }
+
         },
         didInsertElement: function () {
           this.fitHeight();

+ 9 - 7
ambari-web/app/routes/rollbackHA_routes.js

@@ -35,7 +35,12 @@ module.exports = Em.Route.extend({
         showFooter: false,
         secondary: null,
         hideCloseButton: function () {
-          this.set('showCloseButton', false);
+          var currStep = App.router.get('rollbackHighAvailabilityWizardController.currentStep');
+          if(currStep == 3){
+            this.set('showCloseButton', false);
+          }else{
+            this.set('showCloseButton', true);
+          }
         }.observes('App.router.rollbackHighAvailabilityWizardController.currentStep'),
 
         onClose: function () {
@@ -81,6 +86,9 @@ module.exports = Em.Route.extend({
       return false;
     },
     next: function (router) {
+      var controller = router.get('rollbackHighAvailabilityWizardController');
+      controller.saveSelectedAddNN(controller.get('content.selectedAddNNHost'));
+      controller.saveSelectedSNN(controller.get('content.selectedSNNHost'));
       router.transitionTo('step2');
     }
   }),
@@ -89,12 +97,6 @@ module.exports = Em.Route.extend({
     route: '/step2',
     connectOutlets: function (router) {
       var controller = router.get('rollbackHighAvailabilityWizardController');
-      App.clusterStatus.setClusterStatus({
-        clusterName: router.get('content.cluster.name'),
-        clusterState: 'ROLLBACK_HIGH_AVAILABILITY',
-        wizardControllerName: 'rollbackHighAvailabilityWizardController',
-        localdb: App.db.data
-      });
       controller.setCurrentStep('2');
       controller.dataLoading().done(function () {
         controller.loadAllPriorSteps();

+ 22 - 3
ambari-web/app/templates/main/admin/rollbackHA/step1.hbs

@@ -15,10 +15,29 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 }}
-<div id="ha-step1">
+<div>
   <h2>{{t admin.rollbackHighAvailability.wizard.step1.header}}</h2>
-
+  <div class="alert alert-info">
+    <p>
+      Select Additional NameNode host:
+      {{view Ember.Select
+        contentBinding="view.addNNHosts"
+        valueBinding="view.selectedAddNNHost"
+      }}
+    </p>
+    <div class="code-snippet">Tip: Suggested host <b>{{view.tipAddNNHost}}</b></div></li>
+  </div>
+  <div class="alert alert-info">
+    <p>
+      Select Secondary NameNode host:
+      {{view Ember.Select
+        contentBinding="view.sNNHosts"
+        valueBinding="view.selectedSNNHost"
+      }}
+    </p>
+    <div class="code-snippet">Tip: Suggested host <b>{{view.tipSNNHost}}</b></div></li>
+  </div>
   <div class="btn-area">
-    <a {{bindAttr class=":btn controller.isNameServiceIdValid::disabled :btn-success :pull-right"}} {{action next}}>{{t common.next}} &rarr;</a>
+    <a {{bindAttr class=":btn controller.isNameServiceIdValid::disabled :btn-success :pull-right"}} {{action done target="view"}}>{{t common.next}} &rarr;</a>
   </div>
 </div>

+ 1 - 1
ambari-web/app/templates/main/admin/rollbackHA/step2.hbs

@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 }}
-<div id="ha-step1">
+<div>
   <h2>{{t admin.rollbackHighAvailability.wizard.step2.header}}</h2>
 
 

+ 1 - 1
ambari-web/app/templates/main/admin/rollbackHA/step3.hbs

@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 }}
-<div id="ha-step1">
+<div>
   <h2>{{t admin.rollbackHighAvailability.wizard.step3.header}}</h2>
 
   <div class="btn-area">

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

@@ -416,6 +416,18 @@ App.db.setRollBackHighAvailabilityWizardSNNHost = function (host) {
   localStorage.setObject('ambari', App.db.data);
 };
 
+App.db.setRollBackHighAvailabilityWizardSelectedAddNN = function (host) {
+  App.db.data = localStorage.getObject('ambari');
+  App.db.data.RollbackHighAvailabilityWizard.selectedAddNN = host;
+  localStorage.setObject('ambari', App.db.data);
+};
+
+App.db.setRollBackHighAvailabilityWizardSelectedSNN = function (host) {
+  App.db.data = localStorage.getObject('ambari');
+  App.db.data.RollbackHighAvailabilityWizard.selectedSNNH = host;
+  localStorage.setObject('ambari', App.db.data);
+};
+
 App.db.setRollbackHighAvailabilityWizardTasksStatuses = function (tasksStatuses) {
   App.db.data = localStorage.getObject('ambari');
   App.db.data.RollbackHighAvailabilityWizard.tasksStatuses = tasksStatuses;
@@ -726,6 +738,16 @@ App.db.getRollbackHighAvailabilityWizardLogs = function () {
   return App.db.data.RollbackHighAvailabilityWizard.logs;
 };
 
+App.db.getRollBackHighAvailabilityWizardAddNNHost = function (host) {
+  App.db.data = localStorage.getObject('ambari');
+  return App.db.data.RollbackHighAvailabilityWizard.addNNHost;
+};
+
+App.db.getRollBackHighAvailabilityWizardSNNHost = function (host) {
+  App.db.data = localStorage.getObject('ambari');
+  return App.db.data.RollbackHighAvailabilityWizard.sNNHost;
+};
+
 App.db.getReassignMasterWizardRequestIds = function () {
   App.db.data = localStorage.getObject('ambari');
   return App.db.data.ReassignMaster.requestIds;

+ 31 - 0
ambari-web/app/views/main/admin/rollbackHA/step1_view.js

@@ -23,8 +23,39 @@ App.RollbackHighAvailabilityWizardStep1View = Em.View.extend({
 
   templateName: require('templates/main/admin/rollbackHA/step1'),
 
+  addNNHosts: null,
+  sNNHosts: null,
+  selectedSNNHost: null,
+  selectedAddNNHost: null,
+
   didInsertElement: function() {
+    var addNNHosts = App.HostComponent.find().filterProperty('componentName','NAMENODE');
+    this.secondaryNNHosts = [];
+
+    this.set('selectedSNNHost', this.get('controller.content.sNNHost'));
+    this.set('selectedAddNNHost', this.get('controller.content.addNNHost'));
+
+    if(addNNHosts.length == 2){
+      this.set('addNNHosts', addNNHosts.mapProperty('host.hostName'));
+    }
+    App.Host.find().forEach(function(host){
+      this.secondaryNNHosts.push(host.get('id'));
+    },this);
+    this.set('sNNHosts', this.secondaryNNHosts);
+  },
+
+  tipAddNNHost: function () {
+    return this.get('controller.content.addNNHost');
+  }.property('controller.content.addNNHost'),
+
+  tipSNNHost: function () {
+    return this.get('controller.content.sNNHost');
+  }.property('controller.content.sNNHost'),
 
+  done: function () {
+    this.get('controller.content').set('selectedSNNHost', this.get('selectedSNNHost'));
+    this.get('controller.content').set('selectedAddNNHost', this.get('selectedAddNNHost'));
+    App.router.send('next');
   }
 
 });