step13_controller.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. App.WizardStep13Controller = App.HighAvailabilityProgressPageController.extend({
  20. commands: ['stopServices', 'createHostComponents', 'putHostComponentsInMaintenanceMode', 'installHostComponents', 'reconfigure', 'startServices', 'deleteHostComponents'],
  21. clusterDeployStep: 'REASSIGN_MASTER_INSTALLING',
  22. componentsWithManualSteps: ['NAMENODE, SECONDARY_NAMENODE', 'JOBTRACKER'],
  23. multiTaskCounter: 0,
  24. hostComponents: [],
  25. serviceNames: [],
  26. loadStep: function () {
  27. if (['HIVE_METASTORE', 'WEBHCAT_SERVER'].contains(this.get('content.reassign.component_name'))) { //todo
  28. this.set('hostComponents', ['HIVE_METASTORE', 'WEBHCAT']);
  29. this.set('serviceNames', ['HIVE', 'WEBHCAT']);
  30. } else {
  31. this.set('hostComponents', [this.get('content.reassign.component_name')]);
  32. this.set('serviceNames', [this.get('content.reassign.service_id')]);
  33. }
  34. this._super();
  35. },
  36. initializeTasks: function () {
  37. var commands = this.get('commands');
  38. var currentStep = App.router.get('reassignMasterController.currentStep');
  39. var hostComponentsNames = '';
  40. var serviceNames = '';
  41. this.get('hostComponents').forEach(function (comp, index) {
  42. hostComponentsNames += index ? ', ' : '';
  43. hostComponentsNames += App.format.role(comp);
  44. }, this);
  45. this.get('serviceNames').forEach(function (service, index) {
  46. serviceNames += index ? ', ' : '';
  47. serviceNames += App.Service.find().findProperty('serviceName', service).get('displayName');
  48. }, this);
  49. for (var i = 0; i < commands.length; i++) {
  50. var title = Em.I18n.t('installer.step13.task' + i + '.title').format(hostComponentsNames, serviceNames);
  51. this.get('tasks').pushObject(Ember.Object.create({
  52. title: title,
  53. status: 'PENDING',
  54. id: i,
  55. command: commands[i],
  56. showRetry: false,
  57. showRollback: false,
  58. name: title,
  59. displayName: title,
  60. progress: 0,
  61. isRunning: false,
  62. hosts: []
  63. }));
  64. }
  65. //todo
  66. /*if (this.get('componentsWithManualSteps').contains(this.get('content.reassign.component_name'))) {
  67. this.get('tasks').splice(4, 3);
  68. }*/
  69. },
  70. hideRollbackButton: function () {
  71. var failedTask = this.get('tasks').findProperty('showRollback');
  72. if (failedTask) {
  73. failedTask.set('showRollback', false)
  74. }
  75. }.observes('tasks.@each.showRollback'),
  76. onComponentsTasksSuccess: function () {
  77. this.set('multiTaskCounter', this.get('multiTaskCounter') + 1);
  78. if (this.get('multiTaskCounter') >= this.get('hostComponents').length) {
  79. this.onTaskCompleted();
  80. }
  81. },
  82. stopServices: function () {
  83. this.set('multiTaskCounter', 0);
  84. var serviceNames = this.get('serviceNames');
  85. for (var i = 0; i < serviceNames.length; i++) {
  86. App.ajax.send({
  87. name: 'reassign.stop_service',
  88. sender: this,
  89. data: {
  90. serviceName: serviceNames[i],
  91. displayName: App.Service.find().findProperty('serviceName', serviceNames[i]).get('displayName'),
  92. taskNum: serviceNames.length
  93. },
  94. success: 'startPolling',
  95. error: 'onTaskError'
  96. });
  97. }
  98. },
  99. createHostComponents: function () {
  100. this.set('multiTaskCounter', 0);
  101. var hostComponents = this.get('hostComponents');
  102. var hostName = this.get('content.masterComponentHosts').findProperty('component', this.get('content.reassign.component_name')).hostName;
  103. for (var i = 0; i < hostComponents.length; i++) {
  104. this.createComponent(hostComponents[i], hostName);
  105. }
  106. },
  107. onCreateComponent: function () {
  108. this.onComponentsTasksSuccess();
  109. },
  110. putHostComponentsInMaintenanceMode: function () {
  111. this.set('multiTaskCounter', 0);
  112. var hostComponents = this.get('hostComponents');
  113. var hostName = this.get('content.reassign.host_id');
  114. for (var i = 0; i < hostComponents.length; i++) {
  115. App.ajax.send({
  116. name: 'reassign.maintenance_mode',
  117. sender: this,
  118. data: {
  119. hostName: hostName,
  120. componentName: hostComponents[i]
  121. },
  122. success: 'onComponentsTasksSuccess',
  123. error: 'onTaskError'
  124. });
  125. }
  126. },
  127. installHostComponents: function () {
  128. this.set('multiTaskCounter', 0);
  129. var hostComponents = this.get('hostComponents');
  130. var hostName = this.get('content.masterComponentHosts').findProperty('component', this.get('content.reassign.component_name')).hostName;
  131. for (var i = 0; i < hostComponents.length; i++) {
  132. this.installComponent(hostComponents[i], hostName, hostComponents.length);
  133. }
  134. },
  135. reconfigure: function () {
  136. //todo
  137. this.onTaskCompleted();
  138. },
  139. startServices: function () {
  140. this.set('multiTaskCounter', 0);
  141. var serviceNames = this.get('serviceNames');
  142. for (var i = 0; i < serviceNames.length; i++) {
  143. App.ajax.send({
  144. name: 'reassign.start_components',
  145. sender: this,
  146. data: {
  147. serviceName: serviceNames[i],
  148. displayName: App.Service.find().findProperty('serviceName', serviceNames[i]).get('displayName'),
  149. taskNum: serviceNames.length
  150. },
  151. success: 'startPolling',
  152. error: 'onTaskError'
  153. });
  154. }
  155. },
  156. deleteHostComponents: function () {
  157. this.set('multiTaskCounter', 0);
  158. var hostComponents = this.get('hostComponents');
  159. var hostName = this.get('content.reassign.host_id');
  160. for (var i = 0; i < hostComponents.length; i++) {
  161. App.ajax.send({
  162. name: 'reassign.remove_component',
  163. sender: this,
  164. data: {
  165. hostName: hostName,
  166. componentName: hostComponents[i]
  167. },
  168. success: 'onComponentsTasksSuccess',
  169. error: 'onTaskError'
  170. });
  171. }
  172. }
  173. })