rollback_controller.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. require('controllers/main/admin/highAvailability/progress_controller');
  20. App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageController.extend({
  21. name: "highAvailabilityRollbackController",
  22. failedTask: null,
  23. commands: [
  24. 'stopAllServices',
  25. 'restoreHBaseConfigs',
  26. 'stopFailoverControllers',
  27. 'deleteFailoverControllers',
  28. 'stopStandbyNameNode',
  29. 'stopNameNode',
  30. 'restoreHDFSConfigs',
  31. 'enableSecondaryNameNode',
  32. 'stopJournalNodes',
  33. 'deleteJournalNodes',
  34. 'deleteAdditionalNameNode',
  35. 'startAllServices'
  36. ],
  37. loadStep: function () {
  38. this.loadFailedTask();
  39. this.clearStep();
  40. this.loadTasks();
  41. this.addObserver('tasks.@each.status', this, 'onTaskStatusChange');
  42. this.onTaskStatusChange();
  43. },
  44. setCommandsAndTasks: function(tmpTasks) {
  45. var fTask = this.get('failedTask');
  46. var newCommands = [];
  47. var newTasks = [];
  48. var index = [
  49. 'deleteSNameNode',
  50. 'startAllServices',
  51. 'reconfigureHBase',
  52. 'startZKFC',
  53. 'installZKFC',
  54. 'startSecondNameNode',
  55. 'startNameNode',
  56. 'startZooKeeperServers',
  57. 'reconfigureHDFS',
  58. 'disableSNameNode',
  59. 'startJournalNodes',
  60. 'installJournalNodes',
  61. 'installNameNode',
  62. 'stopAllServices'
  63. ].indexOf(fTask.command);
  64. if(index > 6){
  65. --index;
  66. }
  67. newCommands = this.get('commands').splice(index);
  68. this.set('commands', newCommands);
  69. newTasks = tmpTasks.splice(index);
  70. this.set('tasks', newTasks);
  71. },
  72. clearStep: function () {
  73. this.set('isSubmitDisabled', true);
  74. this.set('tasks', []);
  75. this.set('logs', []);
  76. this.set('currentRequestIds', []);
  77. var commands = this.get('commands');
  78. var tmpTasks = [];
  79. for (var i = 0; i < commands.length; i++) {
  80. tmpTasks.pushObject(Ember.Object.create({
  81. title: Em.I18n.t('admin.highAvailability.rollback.task' + i + '.title'),
  82. status: 'PENDING',
  83. id: i,
  84. command: commands[i],
  85. showRetry: false,
  86. name: Em.I18n.t('admin.highAvailability.rollback.task' + i + '.title'),
  87. displayName: Em.I18n.t('admin.highAvailability.rollback.task' + i + '.title'),
  88. progress: 0,
  89. isRunning: false,
  90. hosts: []
  91. }));
  92. }
  93. this.setCommandsAndTasks(tmpTasks);
  94. },
  95. onTaskStatusChange: function () {
  96. if (!this.get('tasks').someProperty('status', 'IN_PROGRESS') && !this.get('tasks').someProperty('status', 'QUEUED') && !this.get('tasks').someProperty('status', 'FAILED')) {
  97. var nextTask = this.get('tasks').findProperty('status', 'PENDING');
  98. if (nextTask) {
  99. this.set('status', 'IN_PROGRESS');
  100. this.setTaskStatus(nextTask.get('id'), 'QUEUED');
  101. this.set('currentTaskId', nextTask.get('id'));
  102. this.runTask(nextTask.get('id'));
  103. } else {
  104. this.set('status', 'COMPLETED');
  105. this.set('isSubmitDisabled', false);
  106. }
  107. } else if (this.get('tasks').someProperty('status', 'FAILED') || this.get('tasks').someProperty('status', 'TIMEDOUT') || this.get('tasks').someProperty('status', 'ABORTED')) {
  108. this.set('status', 'FAILED');
  109. this.get('tasks').findProperty('status', 'FAILED').set('showRetry', true);
  110. }
  111. var statuses = this.get('tasks').mapProperty('status');
  112. var requestIds = this.get('currentRequestIds');
  113. this.saveTasksStatuses(statuses);
  114. this.saveRequestIds(requestIds);
  115. App.clusterStatus.setClusterStatus({
  116. clusterName: this.get('content.cluster.name'),
  117. clusterState: 'HIGH_AVAILABILITY_ROLLBACK',
  118. wizardControllerName: this.get('content.controllerName'),
  119. localdb: App.db.data
  120. });
  121. },
  122. saveTasksStatuses: function(statuses){
  123. App.db.setHighAvailabilityWizardTasksStatuses(statuses);
  124. //this.set('content.tasksStatuses', statuses);
  125. },
  126. loadTasksStatuses: function(){
  127. var statuses = App.db.getHighAvailabilityWizardTasksStatuses();
  128. //this.set('content.tasksStatuses', statuses);
  129. },
  130. loadFailedTask: function(){
  131. var failedTask = App.db.getHighAvailabilityWizardFailedTask();
  132. this.set('failedTask', failedTask);
  133. },
  134. saveRequestIds: function(requestIds){
  135. App.db.setHighAvailabilityWizardRequestIds(requestIds);
  136. //this.set('content.requestIds', requestIds);
  137. },
  138. loadRequestIds: function(){
  139. var requestIds = App.db.getHighAvailabilityWizardRequestIds();
  140. //this.set('content.requestIds', requestIds);
  141. },
  142. done: function () {
  143. if (!this.get('isSubmitDisabled')) {
  144. this.removeObserver('tasks.@each.status', this, 'onTaskStatusChange');
  145. this.get('popup').hide();
  146. App.router.transitionTo('main.admin.adminHighAvailability');
  147. }
  148. },
  149. stopAllServices: function(){
  150. },
  151. restoreHBaseConfigs: function(){
  152. },
  153. stopFailoverControllers: function(){
  154. },
  155. deleteFailoverControllers: function(){
  156. },
  157. stopStandbyNameNode: function(){
  158. },
  159. stopNameNode: function(){
  160. },
  161. restoreHDFSConfigs: function(){
  162. },
  163. enableSecondaryNameNode: function(){
  164. },
  165. stopJournalNodes: function(){
  166. },
  167. deleteJournalNodes: function(){
  168. },
  169. deleteAdditionalNameNode: function(){
  170. },
  171. startAllServices: function(){
  172. }
  173. });