step6_controller.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.ReassignMasterWizardStep6Controller = App.HighAvailabilityProgressPageController.extend({
  20. isReassign: true,
  21. commands: ['deleteHostComponents', 'startServices'],
  22. clusterDeployState: 'REASSIGN_MASTER_INSTALLING',
  23. multiTaskCounter: 0,
  24. hostComponents: [],
  25. loadStep: function () {
  26. if (this.get('content.reassign.component_name') === 'NAMENODE' && App.get('isHaEnabled')) {
  27. this.set('hostComponents', ['NAMENODE', 'ZKFC']);
  28. } else {
  29. this.set('hostComponents', [this.get('content.reassign.component_name')]);
  30. }
  31. this._super();
  32. },
  33. initializeTasks: function () {
  34. var commands = this.get('commands');
  35. var hostComponentsNames = '';
  36. this.get('hostComponents').forEach(function (comp, index) {
  37. hostComponentsNames += index ? '+' : '';
  38. hostComponentsNames += comp === 'ZKFC' ? comp : App.format.role(comp);
  39. }, this);
  40. var currentStep = App.router.get('reassignMasterController.currentStep');
  41. for (var i = 0; i < commands.length; i++) {
  42. var title = Em.I18n.t('services.reassign.step6.task' + i + '.title').format(hostComponentsNames);
  43. this.get('tasks').pushObject(Ember.Object.create({
  44. title: title,
  45. status: 'PENDING',
  46. id: i,
  47. command: commands[i],
  48. showRetry: false,
  49. showRollback: false,
  50. name: title,
  51. displayName: title,
  52. progress: 0,
  53. isRunning: false,
  54. hosts: []
  55. }));
  56. }
  57. },
  58. hideRollbackButton: function () {
  59. var failedTask = this.get('tasks').findProperty('showRollback');
  60. if (failedTask) {
  61. failedTask.set('showRollback', false)
  62. }
  63. }.observes('tasks.@each.showRollback'),
  64. onComponentsTasksSuccess: function () {
  65. this.set('multiTaskCounter', this.get('multiTaskCounter') + 1);
  66. if (this.get('multiTaskCounter') >= this.get('hostComponents').length) {
  67. this.onTaskCompleted();
  68. }
  69. },
  70. startServices: function () {
  71. App.ajax.send({
  72. name: 'common.services.update',
  73. sender: this,
  74. data: {
  75. "context": "Start all services",
  76. "ServiceInfo": {
  77. "state": "STARTED"
  78. },
  79. urlParams: "params/run_smoke_test=true"
  80. },
  81. success: 'startPolling',
  82. error: 'onTaskError'
  83. });
  84. },
  85. deleteHostComponents: function () {
  86. this.set('multiTaskCounter', 0);
  87. var hostComponents = this.get('hostComponents');
  88. var hostName = this.get('content.reassignHosts.source');
  89. for (var i = 0; i < hostComponents.length; i++) {
  90. App.ajax.send({
  91. name: 'common.delete.host_component',
  92. sender: this,
  93. data: {
  94. hostName: hostName,
  95. componentName: hostComponents[i]
  96. },
  97. success: 'onComponentsTasksSuccess',
  98. error: 'onDeleteHostComponentsError'
  99. });
  100. }
  101. },
  102. onDeleteHostComponentsError: function (error) {
  103. if (error.responseText.indexOf('org.apache.ambari.server.controller.spi.NoSuchResourceException') !== -1) {
  104. this.onComponentsTasksSuccess();
  105. } else {
  106. this.onTaskError();
  107. }
  108. }
  109. });