step9_controller.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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.HighAvailabilityWizardStep9Controller = App.HighAvailabilityProgressPageController.extend(App.WizardEnableDone, {
  20. name:"highAvailabilityWizardStep9Controller",
  21. commands: ['startSecondNameNode', 'installZKFC', 'startZKFC', 'installPXF', 'reconfigureHBase', 'reconfigureAccumulo', 'reconfigureHawq', 'deleteSNameNode', 'startAllServices'],
  22. hbaseSiteTag: "",
  23. accumuloSiteTag: "",
  24. hawqSiteTag: "",
  25. secondNameNodeHost: "",
  26. initializeTasks: function () {
  27. this._super();
  28. var numSpliced = 0;
  29. // find hostname where second namenode will be installed
  30. this.set('secondNameNodeHost', this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').findProperty('isInstalled', false).hostName);
  31. if (!App.Service.find().someProperty('serviceName', 'PXF') || this.isPxfComponentInstalled()) {
  32. this.get('tasks').splice(this.get('tasks').findProperty('command', 'installPXF').get('id'), 1);
  33. numSpliced = 1;
  34. }
  35. if (!App.Service.find().someProperty('serviceName', 'HBASE')) {
  36. this.get('tasks').splice(this.get('tasks').findProperty('command', 'reconfigureHBase').get('id') - numSpliced, 1);
  37. numSpliced++;
  38. }
  39. if (!App.Service.find().someProperty('serviceName', 'ACCUMULO')) {
  40. this.get('tasks').splice(this.get('tasks').findProperty('command', 'reconfigureAccumulo').get('id') - numSpliced, 1);
  41. numSpliced++ ;
  42. }
  43. if (!App.Service.find().someProperty('serviceName', 'HAWQ')) {
  44. this.get('tasks').splice(this.get('tasks').findProperty('command', 'reconfigureHawq').get('id') - numSpliced, 1);
  45. }
  46. },
  47. startSecondNameNode: function () {
  48. var hostName = this.get('secondNameNodeHost');
  49. this.updateComponent('NAMENODE', hostName, "HDFS", "Start");
  50. },
  51. installZKFC: function () {
  52. var hostName = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName');
  53. this.createComponent('ZKFC', hostName, "HDFS");
  54. },
  55. startZKFC: function () {
  56. var hostName = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName');
  57. this.updateComponent('ZKFC', hostName, "HDFS", "Start");
  58. },
  59. isPxfComponentInstalled: function () {
  60. var pxfComponent = this.getSlaveComponentHosts().findProperty('componentName', 'PXF');
  61. if (pxfComponent !== undefined) {
  62. var host;
  63. // check if PXF is already installed on the host assigned for additional NameNode
  64. for (var i = 0; i < pxfComponent.hosts.length; i++) {
  65. host = pxfComponent.hosts[i];
  66. if (host.hostName === this.get('secondNameNodeHost'))
  67. return true;
  68. }
  69. }
  70. return false;
  71. },
  72. installPXF: function () {
  73. this.createComponent('PXF', this.get('secondNameNodeHost'), "PXF");
  74. },
  75. reconfigureHBase: function () {
  76. var data = this.get('content.serviceConfigProperties');
  77. var configData = this.reconfigureSites(['hbase-site'], data, Em.I18n.t('admin.highAvailability.step4.save.configuration.note').format(App.format.role('NAMENODE')));
  78. App.ajax.send({
  79. name: 'common.service.configurations',
  80. sender: this,
  81. data: {
  82. desired_config: configData
  83. },
  84. success: 'saveConfigTag',
  85. error: 'onTaskError'
  86. });
  87. },
  88. reconfigureAccumulo: function () {
  89. var data = this.get('content.serviceConfigProperties');
  90. var configData = this.reconfigureSites(['accumulo-site'], data, Em.I18n.t('admin.highAvailability.step4.save.configuration.note').format(App.format.role('NAMENODE')));
  91. App.ajax.send({
  92. name: 'common.service.configurations',
  93. sender: this,
  94. data: {
  95. desired_config: configData
  96. },
  97. success: 'saveConfigTag',
  98. error: 'onTaskError'
  99. });
  100. },
  101. reconfigureHawq: function () {
  102. var data = this.get('content.serviceConfigProperties');
  103. var reconfigureFiles = ['hawq-site', 'hdfs-client'];
  104. reconfigureFiles.forEach(function (fileName) {
  105. var configData = this.reconfigureSites([fileName], data, Em.I18n.t('admin.highAvailability.step4.save.configuration.note').format(App.format.role('NAMENODE')));
  106. App.ajax.send({
  107. name: 'common.service.configurations',
  108. sender: this,
  109. data: {
  110. desired_config: configData
  111. },
  112. success: 'saveConfigTag',
  113. error: 'onTaskError'
  114. });
  115. }, this);
  116. },
  117. saveConfigTag: function () {
  118. App.clusterStatus.setClusterStatus({
  119. clusterName: this.get('content.cluster.name'),
  120. clusterState: 'HIGH_AVAILABILITY_DEPLOY',
  121. wizardControllerName: this.get('content.controllerName'),
  122. localdb: App.db.data
  123. });
  124. this.onTaskCompleted();
  125. },
  126. startAllServices: function () {
  127. this.startServices(false);
  128. },
  129. deleteSNameNode: function () {
  130. var hostName = this.get('content.masterComponentHosts').findProperty('component', 'SECONDARY_NAMENODE').hostName;
  131. App.ajax.send({
  132. name: 'common.delete.host_component',
  133. sender: this,
  134. data: {
  135. componentName: 'SECONDARY_NAMENODE',
  136. hostName: hostName
  137. },
  138. success: 'onTaskCompleted',
  139. error: 'onTaskError'
  140. });
  141. }
  142. });