rollback_wizard_controller.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. saveSelectedSNN: function(addNN){
  79. App.db.setRollBackHighAvailabilityWizardSelectedSNN(addNN);
  80. this.set('content.selectedAddNN', addNN);
  81. },
  82. saveSelectedAddNN: function(sNN){
  83. App.db.setRollBackHighAvailabilityWizardSelectedAddNN(sNN);
  84. this.set('content.selectedSNN', sNN);
  85. },
  86. loadAddNNHost: function () {
  87. var addNNHost = App.db.getRollBackHighAvailabilityWizardAddNNHost();
  88. this.set('content.addNNHost', addNNHost);
  89. },
  90. loadSNNHost: function () {
  91. var sNNHost = App.db.getRollBackHighAvailabilityWizardSNNHost();
  92. this.set('content.sNNHost', sNNHost);
  93. },
  94. loadTasksStatuses: function(){
  95. var sNNHost = App.db.getRollbackHighAvailabilityWizardTasksStatuses();
  96. this.set('content.tasksStatuses', sNNHost);
  97. },
  98. loadRequestIds: function(){
  99. var requestIds = App.db.getRollbackHighAvailabilityWizardRequestIds();
  100. this.set('content.requestIds', requestIds);
  101. },
  102. /**
  103. * Load data for all steps until <code>current step</code>
  104. */
  105. loadAllPriorSteps: function () {
  106. var step = this.get('currentStep');
  107. switch (step) {
  108. case '3':
  109. case '2':
  110. case '1':
  111. this.loadSNNHost();
  112. this.loadAddNNHost();
  113. this.load('cluster');
  114. }
  115. },
  116. /**
  117. * Remove all loaded data.
  118. * Created as copy for App.router.clearAllSteps
  119. */
  120. clearAllSteps: function () {
  121. this.clearInstallOptions();
  122. // clear temporary information stored during the install
  123. this.set('content.cluster', this.getCluster());
  124. },
  125. clearTasksData: function () {
  126. this.saveTasksStatuses(undefined);
  127. this.saveRequestIds(undefined);
  128. },
  129. /**
  130. * Clear all temporary data
  131. */
  132. finish: function () {
  133. this.setCurrentStep('1');
  134. this.clearAllSteps();
  135. App.router.get('updateController').updateAll();
  136. }
  137. });