Browse Source

AMBARI-3509. Reassign Master: Restart services should be the part of Reassign master wizard. (akovalenko)

Aleksandr Kovalenko 11 years ago
parent
commit
150f949aaa

+ 15 - 39
ambari-web/app/controllers/main/service/reassign/step4_controller.js

@@ -30,15 +30,12 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro
 
   hostComponents: [],
 
-  serviceNames: [],
-
   loadStep: function () {
     if (this.get('content.reassign.component_name') === 'NAMENODE' && !App.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE')) {
       this.get('hostComponents').pushObjects(['NAMENODE', 'ZKFC']);
     } else {
       this.get('hostComponents').pushObject(this.get('content.reassign.component_name'));
     }
-    this.get('serviceNames').pushObject(this.get('content.reassign.service_id'));
     this._super();
   },
 
@@ -46,17 +43,14 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro
     var commands = this.get('commands');
     var currentStep = App.router.get('reassignMasterController.currentStep');
     var hostComponentsNames = '';
-    var serviceNames = '';
+
     this.get('hostComponents').forEach(function (comp, index) {
       hostComponentsNames += index ? ', ' : '';
       hostComponentsNames += App.format.role(comp);
     }, this);
-    this.get('serviceNames').forEach(function (service, index) {
-      serviceNames += index ? ', ' : '';
-      serviceNames += App.Service.find().findProperty('serviceName', service).get('displayName');
-    }, this);
+
     for (var i = 0; i < commands.length; i++) {
-      var title = Em.I18n.t('services.reassign.step4.task' + i + '.title').format(hostComponentsNames, serviceNames);
+      var title = Em.I18n.t('services.reassign.step4.task' + i + '.title').format(hostComponentsNames);
       this.get('tasks').pushObject(Ember.Object.create({
         title: title,
         status: 'PENDING',
@@ -92,21 +86,12 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro
   },
 
   stopServices: function () {
-    this.set('multiTaskCounter', 0);
-    var serviceNames = this.get('serviceNames');
-    for (var i = 0; i < serviceNames.length; i++) {
-      App.ajax.send({
-        name: 'reassign.stop_service',
-        sender: this,
-        data: {
-          serviceName: serviceNames[i],
-          displayName: App.Service.find().findProperty('serviceName', serviceNames[i]).get('displayName'),
-          taskNum: serviceNames.length
-        },
-        success: 'startPolling',
-        error: 'onTaskError'
-      });
-    }
+    App.ajax.send({
+      name: 'reassign.stop_services',
+      sender: this,
+      success: 'startPolling',
+      error: 'onTaskError'
+    });
   },
 
   createHostComponents: function () {
@@ -294,21 +279,12 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro
   },
 
   startServices: function () {
-    this.set('multiTaskCounter', 0);
-    var serviceNames = this.get('serviceNames');
-    for (var i = 0; i < serviceNames.length; i++) {
-      App.ajax.send({
-        name: 'reassign.start_components',
-        sender: this,
-        data: {
-          serviceName: serviceNames[i],
-          displayName: App.Service.find().findProperty('serviceName', serviceNames[i]).get('displayName'),
-          taskNum: serviceNames.length
-        },
-        success: 'startPolling',
-        error: 'onTaskError'
-      });
-    }
+    App.ajax.send({
+      name: 'reassign.start_services',
+      sender: this,
+      success: 'startPolling',
+      error: 'onTaskError'
+    });
   },
 
   deleteHostComponents: function () {

+ 41 - 18
ambari-web/app/controllers/main/service/reassign/step6_controller.js

@@ -26,12 +26,29 @@ App.ReassignMasterWizardStep6Controller = App.HighAvailabilityProgressPageContro
 
   clusterDeployState: 'REASSIGN_MASTER_INSTALLING',
 
+  multiTaskCounter: 0,
+
+  hostComponents: [],
+
+  loadStep: function () {
+    if (this.get('content.reassign.component_name') === 'NAMENODE' && !App.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE')) {
+      this.get('hostComponents').pushObjects(['NAMENODE', 'ZKFC']);
+    } else {
+      this.get('hostComponents').pushObject(this.get('content.reassign.component_name'));
+    }
+    this._super();
+  },
+
   initializeTasks: function () {
     var commands = this.get('commands');
+    var hostComponentsNames = '';
+    this.get('hostComponents').forEach(function (comp, index) {
+      hostComponentsNames += index ? ', ' : '';
+      hostComponentsNames += App.format.role(comp);
+    }, this);
     var currentStep = App.router.get('reassignMasterController.currentStep');
     for (var i = 0; i < commands.length; i++) {
-      var title = Em.I18n.t('services.reassign.step6.task' + i + '.title').format(App.format.role(this.get('content.reassign.component_name')),
-          App.Service.find().findProperty('serviceName', this.get('content.reassign.service_id')).get('displayName'));
+      var title = Em.I18n.t('services.reassign.step6.task' + i + '.title').format(hostComponentsNames);
       this.get('tasks').pushObject(Ember.Object.create({
         title: title,
         status: 'PENDING',
@@ -55,31 +72,37 @@ App.ReassignMasterWizardStep6Controller = App.HighAvailabilityProgressPageContro
     }
   }.observes('tasks.@each.showRollback'),
 
+  onComponentsTasksSuccess: function () {
+    this.set('multiTaskCounter', this.get('multiTaskCounter') + 1);
+    if (this.get('multiTaskCounter') >= this.get('hostComponents').length) {
+      this.onTaskCompleted();
+    }
+  },
+
   startServices: function () {
-    var serviceName = this.get('content.reassign.service_id');
     App.ajax.send({
-      name: 'reassign.start_components',
+      name: 'reassign.start_services',
       sender: this,
-      data: {
-        serviceName: serviceName,
-        displayName: App.Service.find().findProperty('serviceName', serviceName).get('displayName')
-      },
       success: 'startPolling',
       error: 'onTaskError'
     });
   },
 
   deleteHostComponents: function () {
+    this.set('multiTaskCounter', 0);
+    var hostComponents = this.get('hostComponents');
     var hostName = this.get('content.reassignHosts.source');
-    App.ajax.send({
-      name: 'reassign.remove_component',
-      sender: this,
-      data: {
-        hostName: hostName,
-        componentName: this.get('content.reassign.component_name')
-      },
-      success: 'onTaskCompleted',
-      error: 'onTaskError'
-    });
+    for (var i = 0; i < hostComponents.length; i++) {
+      App.ajax.send({
+        name: 'reassign.remove_component',
+        sender: this,
+        data: {
+          hostName: hostName,
+          componentName: hostComponents[i]
+        },
+        success: 'onComponentsTasksSuccess',
+        error: 'onTaskError'
+      });
+    }
   }
 })

+ 5 - 5
ambari-web/app/messages.js

@@ -1076,13 +1076,13 @@ Em.I18n.translations = {
   'services.reassign.step3.sourceHost':'Source Host:',
   'services.reassign.step3.component':'Component name:',
   'services.reassign.step4.header':'Install, Start and Test',
-  'services.reassign.step4.task0.title':'{1} stop',
+  'services.reassign.step4.task0.title':'Stop All Services',
   'services.reassign.step4.task1.title':'{0} create',
   'services.reassign.step4.task2.title':'{0} disable',
-  'services.reassign.step4.task3.title':'{1} reconfigure',
+  'services.reassign.step4.task3.title':'{0} reconfigure',
   'services.reassign.step4.task4.title':'{0} install',
-  'services.reassign.step4.task5.title':'{1} remove',
-  'services.reassign.step4.task6.title':'{0} start',
+  'services.reassign.step4.task5.title':'{0} remove',
+  'services.reassign.step4.task6.title':'Start All Services',
   'services.reassign.step4.status.success': 'Successfully reassigned {0}',
   'services.reassign.step4.status.success.withManualSteps': 'Proceed to the next step',
   'services.reassign.step4.status.failed': 'Failed to reassign {0}',
@@ -1112,7 +1112,7 @@ Em.I18n.translations = {
       '</ol>',
   'services.reassign.step6.header': 'Install, Start and Test',
   'services.reassign.step6.task0.title':'{0} remove',
-  'services.reassign.step6.task1.title':'{1} start',
+  'services.reassign.step6.task1.title':'Start All Services',
   'services.reassign.step6.status.success': 'Successfully reassigned {0}',
   'services.reassign.step6.status.failed': 'Failed to reassign {0}',
   'services.reassign.step6.status.info': 'Reassigning {0}. \nPlease wait while all tasks will be completed.',

+ 28 - 29
ambari-web/app/utils/ajax.js

@@ -78,18 +78,18 @@ var urls = {
       };
     }
   },
-  'reassign.stop_service': {
-    'mock': '/data/wizard/reassign/request_id.json',
-    'real': '/clusters/{clusterName}/services/{serviceName}',
-    'type': 'PUT',
-    'format': function (data) {
+  'reassign.stop_services': {
+    'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
+    'mock': '',
+    'format': function (data, opt) {
       return {
+        type: 'PUT',
         data: JSON.stringify({
-          RequestInfo: {
-            "context": "Stop service " + data.displayName
+          "RequestInfo": {
+            "context": "Stop all services"
           },
-          Body: {
-            ServiceInfo: {
+          "Body": {
+            "ServiceInfo": {
               "state": "INSTALLED"
             }
           }
@@ -97,7 +97,25 @@ var urls = {
       }
     }
   },
-
+  'reassign.start_services': {
+    'real': '/clusters/{clusterName}/services?ServiceInfo/state=INSTALLED&params/run_smoke_test=true',
+    'mock': '',
+    'format': function (data, opt) {
+      return {
+        type: 'PUT',
+        data: JSON.stringify({
+          "RequestInfo": {
+            "context": "Start all services"
+          },
+          "Body": {
+            "ServiceInfo": {
+              "state": "STARTED"
+            }
+          }
+        })
+      }
+    }
+  },
   'reassign.maintenance_mode': {
     'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
     'mock': '',
@@ -114,25 +132,6 @@ var urls = {
       }
     }
   },
-  'reassign.start_components': {
-    'mock': '/data/wizard/reassign/request_id.json',
-    'real': '/clusters/{clusterName}/services/{serviceName}',
-    'type': 'PUT',
-    'format': function (data) {
-      return {
-        data: JSON.stringify({
-          RequestInfo: {
-            "context": "Start service " + data.displayName
-          },
-          Body: {
-            ServiceInfo: {
-              "state": "STARTED"
-            }
-          }
-        })
-      }
-    }
-  },
   'reassign.remove_component': {
     'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
     'mock': '',