step5_controller.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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.HighAvailabilityWizardStep5Controller = App.HighAvailabilityProgressPageController.extend({
  20. name:"highAvailabilityWizardStep5Controller",
  21. isHA: true,
  22. commands: ['stopAllServices', 'installNameNode', 'installJournalNodes', 'startJournalNodes', 'disableSNameNode', 'reconfigureHDFS'],
  23. hdfsSiteTag : "",
  24. coreSiteTag : "",
  25. stopAllServices: function () {
  26. App.ajax.send({
  27. name: 'admin.high_availability.stop_all_services',
  28. sender: this,
  29. success: 'startPolling',
  30. error: 'onTaskError'
  31. });
  32. },
  33. installNameNode: function () {
  34. var hostName = this.get('content.masterComponentHosts').findProperty('isAddNameNode').hostName;
  35. this.createComponent('NAMENODE', hostName);
  36. },
  37. installJournalNodes: function () {
  38. App.ajax.send({
  39. name: 'admin.high_availability.create_journalnode',
  40. sender: this,
  41. success: 'onJournalNodeCreate',
  42. error: 'onJournalNodeCreate'
  43. });
  44. },
  45. onJournalNodeCreate: function () {
  46. var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
  47. this.createComponent('JOURNALNODE', hostNames);
  48. },
  49. startJournalNodes: function () {
  50. var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
  51. this.startComponent('JOURNALNODE', hostNames);
  52. },
  53. disableSNameNode: function () {
  54. var hostName = this.get('content.masterComponentHosts').findProperty('component', 'SECONDARY_NAMENODE').hostName;
  55. App.ajax.send({
  56. name: 'admin.high_availability.maintenance_mode',
  57. sender: this,
  58. data: {
  59. hostName: hostName,
  60. componentName: 'SECONDARY_NAMENODE'
  61. },
  62. success: 'onTaskCompleted',
  63. error: 'onTaskError'
  64. });
  65. },
  66. reconfigureHDFS: function () {
  67. this.loadConfigsTags();
  68. },
  69. loadConfigsTags: function () {
  70. App.ajax.send({
  71. name: 'config.tags',
  72. sender: this,
  73. success: 'onLoadConfigsTags',
  74. error: 'onTaskError'
  75. });
  76. },
  77. onLoadConfigsTags: function (data) {
  78. var hdfsSiteTag = data.Clusters.desired_configs['hdfs-site'].tag;
  79. var coreSiteTag = data.Clusters.desired_configs['core-site'].tag;
  80. this.set("hdfsSiteTag", {name : "hdfsSiteTag", value : hdfsSiteTag});
  81. this.set("coreSiteTag", {name : "coreSiteTag", value : coreSiteTag});
  82. App.ajax.send({
  83. name: 'admin.high_availability.load_configs',
  84. sender: this,
  85. data: {
  86. hdfsSiteTag: hdfsSiteTag,
  87. coreSiteTag: coreSiteTag
  88. },
  89. success: 'onLoadConfigs',
  90. error: 'onTaskError'
  91. });
  92. },
  93. onLoadConfigs: function (data) {
  94. var hdfsSiteProperties = data.items.findProperty('type', 'hdfs-site').properties;
  95. var coreSiteProperties = data.items.findProperty('type', 'core-site').properties;
  96. var currentNameNodeHost = this.get('content.masterComponentHosts').findProperty('isCurNameNode').hostName;
  97. var newNameNodeHost = this.get('content.masterComponentHosts').findProperty('isAddNameNode').hostName;
  98. var journalNodeHosts = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
  99. var zooKeeperHosts = this.get('content.masterComponentHosts').filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName');
  100. var nameServiceId = this.get('content.nameServiceId');
  101. //hdfs-site configs changes
  102. hdfsSiteProperties['dfs.nameservices'] = nameServiceId;
  103. hdfsSiteProperties['dfs.ha.namenodes.' + nameServiceId] = 'nn1,nn2';
  104. hdfsSiteProperties['dfs.namenode.rpc-address.' + nameServiceId + '.nn1'] = currentNameNodeHost + ':8020';
  105. hdfsSiteProperties['dfs.namenode.rpc-address.' + nameServiceId + '.nn2'] = newNameNodeHost + ':8020';
  106. hdfsSiteProperties['dfs.namenode.http-address.' + nameServiceId + '.nn1'] = currentNameNodeHost + ':50070';
  107. hdfsSiteProperties['dfs.namenode.http-address.' + nameServiceId + '.nn2'] = newNameNodeHost + ':50070';
  108. hdfsSiteProperties['dfs.namenode.shared.edits.dir'] = 'qjournal://' + journalNodeHosts[0] + ':8485;' + journalNodeHosts[1] + ':8485;' + journalNodeHosts[2] + ':8485/' + nameServiceId;
  109. hdfsSiteProperties['dfs.client.failover.proxy.provider.' + nameServiceId] = 'org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider';
  110. hdfsSiteProperties['dfs.ha.fencing.methods'] = 'shell(/bin/true)';
  111. hdfsSiteProperties['dfs.journalnode.edits.dir'] = '/grid/0/hdfs/journal';
  112. hdfsSiteProperties['dfs.ha.automatic-failover.enabled'] = 'true';
  113. //core-site configs changes
  114. coreSiteProperties['ha.zookeeper.quorum'] = zooKeeperHosts[0] + ':2181,' + zooKeeperHosts[1] + ':2181,' + zooKeeperHosts[2] + ':2181';
  115. coreSiteProperties['fs.defaultFS'] = 'hdfs://' + nameServiceId;
  116. this.set('configsSaved', false);
  117. App.ajax.send({
  118. name: 'admin.high_availability.save_configs',
  119. sender: this,
  120. data: {
  121. siteName: 'hdfs-site',
  122. properties: hdfsSiteProperties
  123. },
  124. success: 'installHDFSClients',
  125. error: 'onTaskError'
  126. });
  127. App.ajax.send({
  128. name: 'admin.high_availability.save_configs',
  129. sender: this,
  130. data: {
  131. siteName: 'core-site',
  132. properties: coreSiteProperties
  133. },
  134. success: 'installHDFSClients',
  135. error: 'onTaskError'
  136. });
  137. },
  138. configsSaved: false,
  139. installHDFSClients: function () {
  140. if (!this.get('configsSaved')) {
  141. this.set('configsSaved', true);
  142. return;
  143. }
  144. var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName');
  145. this.createComponent('HDFS_CLIENT', hostNames);
  146. App.router.get(this.get('content.controllerName')).saveConfigTag(this.get("hdfsSiteTag"));
  147. App.router.get(this.get('content.controllerName')).saveConfigTag(this.get("coreSiteTag"));
  148. App.router.get(this.get('content.controllerName')).saveHdfsClientHosts(hostNames);
  149. App.clusterStatus.setClusterStatus({
  150. clusterName: this.get('content.cluster.name'),
  151. clusterState: 'HIGH_AVAILABILITY_DEPLOY',
  152. wizardControllerName: this.get('content.controllerName'),
  153. localdb: App.db.data
  154. });
  155. }
  156. });