step5_controller.js 6.0 KB

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