rollback_controller.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. commands: [
  23. 'stopAllServices',
  24. 'restoreHBaseConfigs',
  25. 'stopFailoverControllers',
  26. 'deleteFailoverControllers',
  27. 'stopStandbyNameNode',
  28. 'stopNamenode',
  29. 'restoreHDFSConfigs',
  30. 'enableSecondaryNameNode',
  31. 'stopJournalNodes',
  32. 'deleteJournalNodes',
  33. 'deleteAdditionalNameNode',
  34. 'startAllServices'
  35. ],
  36. getStartingPoint: function() {
  37. },
  38. clearStep: function () {
  39. this.set('isSubmitDisabled', true);
  40. this.set('tasks', []);
  41. this.set('logs', []);
  42. this.set('currentRequestIds', []);
  43. var commands = this.get('commands');
  44. for (var i = 0; i < commands.length; i++) {
  45. this.get('tasks').pushObject(Ember.Object.create({
  46. title: Em.I18n.t('admin.highAvailability.rollback.task' + i + '.title'),
  47. status: 'PENDING',
  48. id: i,
  49. command: commands[i],
  50. showRetry: false,
  51. name: Em.I18n.t('admin.highAvailability.rollback.task' + i + '.title'),
  52. displayName: Em.I18n.t('admin.highAvailability.rollback.task' + i + '.title'),
  53. progress: 0,
  54. isRunning: false,
  55. hosts: []
  56. }));
  57. }
  58. },
  59. onTaskStatusChange: function () {
  60. if (!this.get('tasks').someProperty('status', 'IN_PROGRESS') && !this.get('tasks').someProperty('status', 'QUEUED') && !this.get('tasks').someProperty('status', 'FAILED')) {
  61. var nextTask = this.get('tasks').findProperty('status', 'PENDING');
  62. if (nextTask) {
  63. this.set('status', 'IN_PROGRESS');
  64. this.setTaskStatus(nextTask.get('id'), 'QUEUED');
  65. this.set('currentTaskId', nextTask.get('id'));
  66. this.runTask(nextTask.get('id'));
  67. } else {
  68. this.set('status', 'COMPLETED');
  69. this.set('isSubmitDisabled', false);
  70. }
  71. } else if (this.get('tasks').someProperty('status', 'FAILED') || this.get('tasks').someProperty('status', 'TIMEDOUT') || this.get('tasks').someProperty('status', 'ABORTED')) {
  72. this.set('status', 'FAILED');
  73. this.get('tasks').findProperty('status', 'FAILED').set('showRetry', true);
  74. }
  75. var statuses = this.get('tasks').mapProperty('status');
  76. var requestIds = this.get('currentRequestIds');
  77. this.saveTasksStatuses(statuses);
  78. this.saveRequestIds(requestIds);
  79. App.clusterStatus.setClusterStatus({
  80. clusterName: this.get('content.cluster.name'),
  81. clusterState: 'HIGH_AVAILABILITY_ROLLBACK',
  82. wizardControllerName: this.get('content.controllerName'),
  83. localdb: App.db.data
  84. });
  85. },
  86. saveTasksStatuses: function(statuses){
  87. App.db.setHighAvailabilityWizardTasksStatuses(statuses);
  88. //this.set('content.tasksStatuses', statuses);
  89. },
  90. loadTasksStatuses: function(){
  91. var statuses = App.db.getHighAvailabilityWizardTasksStatuses();
  92. //this.set('content.tasksStatuses', statuses);
  93. },
  94. saveRequestIds: function(requestIds){
  95. App.db.setHighAvailabilityWizardRequestIds(requestIds);
  96. //this.set('content.requestIds', requestIds);
  97. },
  98. loadRequestIds: function(){
  99. var requestIds = App.db.getHighAvailabilityWizardRequestIds();
  100. //this.set('content.requestIds', requestIds);
  101. },
  102. done: function () {
  103. if (!this.get('isSubmitDisabled')) {
  104. this.removeObserver('tasks.@each.status', this, 'onTaskStatusChange');
  105. this.get('popup').hide();
  106. App.router.transitionTo('main.admin.adminHighAvailability');
  107. }
  108. },
  109. stopAllServices: function(){
  110. },
  111. restoreHBaseConfigs: function(){
  112. },
  113. stopFailoverControllers: function(){
  114. },
  115. deleteFailoverControllers: function(){
  116. },
  117. stopStandbyNameNode: function(){
  118. },
  119. stopNamenode: function(){
  120. },
  121. restoreHDFSConfigs: function(){
  122. },
  123. enableSecondaryNameNode: function(){
  124. },
  125. stopJournalNodes: function(){
  126. },
  127. deleteJournalNodes: function(){
  128. },
  129. deleteAdditionalNameNode: function(){
  130. },
  131. startAllServices: function(){
  132. }
  133. });