Преглед изворни кода

AMBARI-6583. RM HA: Create Step4. (akovalenko)

Aleksandr Kovalenko пре 11 година
родитељ
комит
e72900f578

+ 6 - 4
ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js

@@ -33,6 +33,7 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle
   POLL_INTERVAL: 4000,
   isSubmitDisabled: true,
   isRollback: false,
+  tasksMessagesPrefix: 'admin.highAvailability.wizard.step',
 
   loadStep: function () {
     console.warn('func: loadStep');
@@ -53,17 +54,18 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle
   initializeTasks: function () {
     console.warn('func: initializeTasks');
     var commands = this.get('commands');
-    var currentStep = App.router.get('highAvailabilityWizardController.currentStep');
+    var currentStep = App.router.get(this.get('content.controllerName') + '.currentStep');
+    var tasksMessagesPrefix = this.get('tasksMessagesPrefix');
     for (var i = 0; i < commands.length; i++) {
       this.get('tasks').pushObject(Ember.Object.create({
-        title: Em.I18n.t('admin.highAvailability.wizard.step' + currentStep + '.task' + i + '.title'),
+        title: Em.I18n.t(tasksMessagesPrefix + currentStep + '.task' + i + '.title'),
         status: 'PENDING',
         id: i,
         command: commands[i],
         showRetry: false,
         showRollback: false,
-        name: Em.I18n.t('admin.highAvailability.wizard.step' + currentStep + '.task' + i + '.title'),
-        displayName: Em.I18n.t('admin.highAvailability.wizard.step' + currentStep + '.task' + i + '.title'),
+        name: Em.I18n.t(tasksMessagesPrefix + currentStep + '.task' + i + '.title'),
+        displayName: Em.I18n.t(tasksMessagesPrefix + currentStep + '.task' + i + '.title'),
         progress: 0,
         isRunning: false,
         requestIds: []

+ 97 - 2
ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step4_controller.js

@@ -20,7 +20,102 @@ var App = require('app');
 
 require('controllers/main/admin/misc_controller');
 
-App.RMHighAvailabilityWizardStep4Controller = Em.Controller.extend({
-  name:"rMHighAvailabilityWizardStep4Controller"
+App.RMHighAvailabilityWizardStep4Controller = App.HighAvailabilityProgressPageController.extend({
+
+  name: "rMHighAvailabilityWizardStep4Controller",
+
+  isRMHA: true,
+
+  clusterDeployState: 'RM_HIGH_AVAILABILITY_DEPLOY',
+
+  commands: ['stopRequiredServices', 'installResourceManager', 'reconfigureYARN', 'startAllServices'],
+
+  tasksMessagesPrefix: 'admin.rm_highAvailability.wizard.step',
+
+  stopRequiredServices: function () {
+    var list = App.Service.find().mapProperty("serviceName").without("HDFS").join(',');
+    App.ajax.send({
+      name: 'common.services.update',
+      sender: this,
+      data: {
+        "context": "Stop without HDFS",
+        "ServiceInfo": {
+          "state": "INSTALLED"
+        },
+        urlParams: "ServiceInfo/service_name.in(" + list + ")"},
+      success: 'startPolling',
+      error: 'onTaskError'
+    });
+  },
+
+  installResourceManager: function () {
+    var hostName = this.get('content.rmHosts.additionalRM');
+    this.createComponent('RESOURCEMANAGER', hostName, "YARN");
+  },
+
+  reconfigureYARN: function () {
+    this.loadConfigsTags();
+  },
+
+  loadConfigsTags: function () {
+    App.ajax.send({
+      name: 'config.tags',
+      sender: this,
+      success: 'onLoadConfigsTags',
+      error: 'onTaskError'
+    });
+  },
+
+  onLoadConfigsTags: function (data) {
+    App.ajax.send({
+      name: 'reassign.load_configs',
+      sender: this,
+      data: {
+        urlParams: '(type=yarn-site&tag=' + data.Clusters.desired_configs['yarn-site'].tag + ')'
+      },
+      success: 'onLoadConfigs',
+      error: 'onTaskError'
+    });
+  },
+
+  onLoadConfigs: function (data) {
+    var propertiesToAdd = this.get('content.configs');
+    var configs = data.items[0].properties;
+
+    propertiesToAdd.forEach(function (property) {
+      configs[property.name] = property.value;
+    });
+
+    App.ajax.send({
+      name: 'reassign.save_configs',
+      sender: this,
+      data: {
+        siteName: 'yarn-site',
+        properties: configs
+      },
+      success: 'onSaveConfigs',
+      error: 'onTaskError'
+    });
+  },
+
+  onSaveConfigs: function () {
+    this.onTaskCompleted();
+  },
+
+  startAllServices: function () {
+    App.ajax.send({
+      name: 'common.services.update',
+      sender: this,
+      data: {
+        "context": "Start all services",
+        "ServiceInfo": {
+          "state": "STARTED"
+        },
+        urlParams: "params/run_smoke_test=true"
+      },
+      success: 'startPolling',
+      error: 'onTaskError'
+    });
+  }
 });
 

+ 51 - 0
ambari-web/app/controllers/main/admin/highAvailability/resourceManager/wizard_controller.js

@@ -56,6 +56,53 @@ App.RMHighAvailabilityWizardController = App.WizardController.extend({
     this.set('content.rmHosts', rmHosts);
   },
 
+  /**
+   * Save configs to load and apply them on Configure Components step
+   * @param configs
+   */
+  saveConfigs: function (configs) {
+    this.set('content.configs', configs);
+    this.setDBProperty('configs', configs);
+  },
+
+  /**
+   * Load configs to apply them on Configure Components step
+   */
+  loadConfigs: function() {
+    var configs = this.getDBProperty('configs');
+    this.set('content.configs', configs);
+  },
+
+  saveTasksStatuses: function (tasksStatuses) {
+    this.set('content.tasksStatuses', tasksStatuses);
+    this.setDBProperty('tasksStatuses', tasksStatuses);
+  },
+
+  loadTasksStatuses: function() {
+    var tasksStatuses = this.getDBProperty('tasksStatuses');
+    this.set('content.tasksStatuses', tasksStatuses);
+  },
+
+  saveTasksRequestIds: function (tasksRequestIds) {
+    this.set('content.tasksRequestIds', tasksRequestIds);
+    this.setDBProperty('tasksRequestIds', tasksRequestIds);
+  },
+
+  loadTasksRequestIds: function() {
+    var tasksRequestIds = this.getDBProperty('tasksRequestIds');
+    this.set('content.tasksRequestIds', tasksRequestIds);
+  },
+
+  saveRequestIds: function (requestIds) {
+    this.set('content.requestIds', requestIds);
+    this.setDBProperty('requestIds', requestIds);
+  },
+
+  loadRequestIds: function() {
+    var requestIds = this.getDBProperty('requestIds');
+    this.set('content.requestIds', requestIds);
+  },
+
   /**
    * Load data for all steps until <code>current step</code>
    */
@@ -63,6 +110,10 @@ App.RMHighAvailabilityWizardController = App.WizardController.extend({
     var step = this.get('currentStep');
     switch (step) {
       case '4':
+        this.loadTasksStatuses();
+        this.loadTasksRequestIds();
+        this.loadRequestIds();
+        this.loadConfigs();
       case '3':
         this.loadRmHosts();
       case '2':

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

@@ -994,6 +994,12 @@ Em.I18n.translations = {
   'admin.rm_highAvailability.wizard.step3.currentRM': 'Current ResourceManager',
   'admin.rm_highAvailability.wizard.step3.additionalRM': 'Additional ResourceManager',
   'admin.rm_highAvailability.wizard.step4.header': 'Configure Components',
+  'admin.rm_highAvailability.wizard.step4.task0.title': 'Stop Required Services',
+  'admin.rm_highAvailability.wizard.step4.task1.title': 'Install Additional ResourceManager',
+  'admin.rm_highAvailability.wizard.step4.task2.title': 'Reconfigure YARN',
+  'admin.rm_highAvailability.wizard.step4.task3.title': 'Start All Services',
+  'admin.rm_highAvailability.wizard.step4.notice.inProgress':'Please wait while ResourceManager HA is being deployed.',
+  'admin.rm_highAvailability.wizard.step4.notice.completed':'NameNode HA has been enabled successfully.',
 
   'admin.security.title':'Kerberos security has not been enabled',
   'admin.security.enabled': 'Kerberos security is enabled',

+ 6 - 1
ambari-web/app/routes/rm_high_availability_routes.js

@@ -131,18 +131,23 @@ module.exports = App.WizardRoute.extend({
       return false;
     },
     next: function (router) {
+      var wizardController = router.get('rMHighAvailabilityWizardController');
+      var stepController = router.get('rMHighAvailabilityWizardStep3Controller');
+      var configs = stepController.get('selectedService.configs');
+      wizardController.saveConfigs(configs);
       router.transitionTo('step4');
     },
     back: Em.Router.transitionTo('step2')
   }),
 
   step4: Em.Route.extend({
-    route: '/step9',
+    route: '/step4',
     connectOutlets: function (router) {
       var controller = router.get('rMHighAvailabilityWizardController');
       controller.setCurrentStep('4');
       controller.setLowerStepsDisable(4);
       controller.dataLoading().done(function () {
+        controller.loadAllPriorSteps();
         controller.connectOutlet('rMHighAvailabilityWizardStep4',  controller.get('content'));
       })
     },

+ 1 - 1
ambari-web/app/templates/main/admin/highAvailability/progress.hbs

@@ -22,7 +22,7 @@
   {{#each task in controller.tasks}}
   {{#view view.taskView contentBinding="task"}}
     <div class="item">
-      <div {{bindAttr class=":pull-left view.linkClass controller.isHA:span4 controller.isRollback:span3 controller.isReassign:span5"}}>
+      <div {{bindAttr class=":pull-left view.linkClass controller.isHA:span4 controller.isRMHA:span5 controller.isRollback:span3 controller.isReassign:span5"}}>
         <i {{bindAttr class="view.icon view.iconColor"}}></i>
         <a {{action "showHostProgressPopup" task target="controller"}} >{{task.title}}</a>
       </div>

+ 1 - 7
ambari-web/app/templates/main/admin/highAvailability/resourceManager/step4.hbs

@@ -15,10 +15,4 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 }}
-<div>
-  <h2>{{t admin.rm_highAvailability.wizard.step4.header}}</h2>
-
-  <div class="btn-area">
-    <a class="btn btn-success pull-right" {{action next}}>{{t common.complete}}</a>
-  </div>
-</div>
+{{template "templates/main/admin/highAvailability/progress"}}

+ 10 - 2
ambari-web/app/views/main/admin/highAvailability/resourceManager/step4_view.js

@@ -19,8 +19,16 @@
 
 var App = require('app');
 
-App.RMHighAvailabilityWizardStep4View = Em.View.extend({
+App.RMHighAvailabilityWizardStep4View = App.HighAvailabilityProgressPageView.extend({
 
-  templateName: require('templates/main/admin/highAvailability/resourceManager/step4')
+  templateName: require('templates/main/admin/highAvailability/resourceManager/step4'),
+
+  headerTitle: Em.I18n.t('admin.rm_highAvailability.wizard.step4.header'),
+
+  noticeInProgress: Em.I18n.t('admin.rm_highAvailability.wizard.step4.notice.inProgress'),
+
+  noticeCompleted: Em.I18n.t('admin.rm_highAvailability.wizard.step4.notice.completed'),
+
+  submitButtonText: Em.I18n.t('common.complete')
 
 });

+ 42 - 3
ambari-web/app/views/main/admin/highAvailability/resourceManager/wizard_view.js

@@ -21,8 +21,6 @@ var App = require('app');
 
 App.RMHighAvailabilityWizardView = Em.View.extend({
 
-  isLoaded: true,
-
   didInsertElement: function() {
     var currentStep = this.get('controller.currentStep');
     if (currentStep > 3) {
@@ -50,6 +48,47 @@ App.RMHighAvailabilityWizardView = Em.View.extend({
 
   isStepDisabled: function (index) {
     return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
-  }
+  },
+
+  isLoaded: false,
+
+  willInsertElement: function() {
+    this.set('isLoaded', false);
+    this.loadHosts();
+  },
 
+  /**
+   * load hosts from server
+   */
+  loadHosts: function () {
+    App.ajax.send({
+      name: 'hosts.high_availability.wizard',
+      data: {},
+      sender: this,
+      success: 'loadHostsSuccessCallback',
+      error: 'loadHostsErrorCallback'
+    });
+  },
+
+  loadHostsSuccessCallback: function (data, opt, params) {
+    var hosts = {};
+
+    data.items.forEach(function (item) {
+      hosts[item.Hosts.host_name] = {
+        name: item.Hosts.host_name,
+        cpu: item.Hosts.cpu_count,
+        memory: item.Hosts.total_mem,
+        disk_info: item.Hosts.disk_info,
+        bootStatus: "REGISTERED",
+        isInstalled: true
+      };
+    });
+    App.db.setHosts(hosts);
+    this.set('controller.content.hosts', hosts);
+    this.set('isLoaded', true);
+  },
+
+  loadHostsErrorCallback: function(){
+    this.set('isLoaded', true);
+  }
 });