step5_controller.js 6.8 KB

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