rollback_wizard_controller.js 4.9 KB

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