rollback_wizard_controller.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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.RollbackHighAvailabilityWizardController = App.WizardController.extend({
  20. name: 'rollbackHighAvailabilityWizardController',
  21. totalSteps: 3,
  22. /**
  23. * Used for hiding back button in wizard
  24. */
  25. hideBackButton: true,
  26. content: Em.Object.create({
  27. controllerName: 'RollbackHighAvailabilityWizardController',
  28. cluster: null,
  29. masterComponentHosts: null,
  30. serviceName: 'MISC',
  31. hdfsUser:"hdfs",
  32. nameServiceId: '',
  33. selectedAddNNHost : null,
  34. selectedSNNHost : null,
  35. activeNNHost: null
  36. }),
  37. setCurrentStep: function (currentStep, completed) {
  38. this._super(currentStep, completed);
  39. App.clusterStatus.setClusterStatus({
  40. clusterName: this.get('content.cluster.name'),
  41. clusterState: 'ROLLBACK_HIGH_AVAILABILITY',
  42. wizardControllerName: 'rollbackHighAvailabilityWizardController',
  43. localdb: App.db.data
  44. });
  45. },
  46. /**
  47. * return new object extended from clusterStatusTemplate
  48. * @return Object
  49. */
  50. getCluster: function(){
  51. return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.router.getClusterName()});
  52. },
  53. /**
  54. * save status of the cluster.
  55. * @param clusterStatus object with status,requestId fields.
  56. */
  57. saveClusterStatus: function (clusterStatus) {
  58. var oldStatus = this.toObject(this.get('content.cluster'));
  59. clusterStatus = jQuery.extend(oldStatus, clusterStatus);
  60. if (clusterStatus.requestId) {
  61. clusterStatus.requestId.forEach(function (requestId) {
  62. if (clusterStatus.oldRequestsId.indexOf(requestId) === -1) {
  63. clusterStatus.oldRequestsId.push(requestId)
  64. }
  65. }, this);
  66. }
  67. this.set('content.cluster', clusterStatus);
  68. this.save('cluster');
  69. },
  70. saveTasksStatuses: function(statuses){
  71. App.db.setRollbackHighAvailabilityWizardTasksStatuses(statuses);
  72. this.set('content.tasksStatuses', statuses);
  73. },
  74. saveRequestIds: function(requestIds){
  75. App.db.setRollbackHighAvailabilityWizardRequestIds(requestIds);
  76. this.set('content.requestIds', requestIds);
  77. },
  78. saveLogs: function(logs){
  79. App.db.setRollbackHighAvailabilityWizardLogs(logs);
  80. this.set('content.logs', logs);
  81. },
  82. saveSelectedSNN: function(addNN){
  83. App.db.setRollBackHighAvailabilityWizardSelectedSNN(addNN);
  84. this.set('content.selectedAddNN', addNN);
  85. },
  86. saveSelectedAddNN: function(sNN){
  87. App.db.setRollBackHighAvailabilityWizardSelectedAddNN(sNN);
  88. this.set('content.selectedSNN', sNN);
  89. },
  90. loadAddNNHost: function () {
  91. var addNNHost = App.db.getRollBackHighAvailabilityWizardAddNNHost();
  92. this.set('content.addNNHost', addNNHost);
  93. },
  94. loadSNNHost: function () {
  95. var sNNHost = App.db.getRollBackHighAvailabilityWizardSNNHost();
  96. this.set('content.sNNHost', sNNHost);
  97. },
  98. loadTasksStatuses: function(){
  99. var sNNHost = App.db.getRollbackHighAvailabilityWizardTasksStatuses();
  100. this.set('content.tasksStatuses', sNNHost);
  101. },
  102. loadRequestIds: function(){
  103. var requestIds = App.db.getRollbackHighAvailabilityWizardRequestIds();
  104. this.set('content.requestIds', requestIds);
  105. },
  106. loadLogs: function(){
  107. var logs = App.db.getRollbackHighAvailabilityWizardLogs();
  108. this.set('content.logs', logs);
  109. },
  110. /**
  111. * Load data for all steps until <code>current step</code>
  112. */
  113. loadAllPriorSteps: function () {
  114. var step = this.get('currentStep');
  115. switch (step) {
  116. case '3':
  117. case '2':
  118. case '1':
  119. this.loadSNNHost();
  120. this.loadAddNNHost();
  121. this.load('cluster');
  122. }
  123. },
  124. /**
  125. * Remove all loaded data.
  126. * Created as copy for App.router.clearAllSteps
  127. */
  128. clearAllSteps: function () {
  129. this.clearInstallOptions();
  130. // clear temporary information stored during the install
  131. this.set('content.cluster', this.getCluster());
  132. },
  133. clearTasksData: function () {
  134. this.saveTasksStatuses(undefined);
  135. this.saveRequestIds(undefined);
  136. this.saveLogs(undefined);
  137. },
  138. /**
  139. * Clear all temporary data
  140. */
  141. finish: function () {
  142. this.setCurrentStep('1');
  143. this.clearAllSteps();
  144. App.router.get('updateController').updateAll();
  145. }
  146. });