step5_controller.js 6.2 KB

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