step3_controller.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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.HighAvailabilityWizardStep3Controller = Em.Controller.extend({
  20. name: "highAvailabilityWizardStep3Controller",
  21. selectedService: null,
  22. stepConfigs: [],
  23. serverConfigData: {},
  24. haConfig: $.extend(true, {}, require('data/HDP2/ha_properties').haConfig),
  25. once: false,
  26. isLoaded: false,
  27. versionLoaded: true,
  28. hideDependenciesInfoBar: true,
  29. /**
  30. * Map of sites and properties to delete
  31. * @type Object
  32. */
  33. configsToRemove: {
  34. 'hdfs-site': ['dfs.namenode.secondary.http-address']
  35. },
  36. clearStep: function () {
  37. this.get('stepConfigs').clear();
  38. this.serverConfigData = {};
  39. },
  40. loadStep: function () {
  41. this.clearStep();
  42. this.loadConfigsTags();
  43. },
  44. loadConfigsTags: function () {
  45. App.ajax.send({
  46. name: 'config.tags',
  47. sender: this,
  48. success: 'onLoadConfigsTags',
  49. error: 'onTaskError'
  50. });
  51. },
  52. onLoadConfigsTags: function (data) {
  53. var urlParams = [];
  54. var hdfsSiteTag = data.Clusters.desired_configs['hdfs-site'].tag;
  55. var coreSiteTag = data.Clusters.desired_configs['core-site'].tag;
  56. urlParams.push('(type=hdfs-site&tag=' + hdfsSiteTag + ')');
  57. urlParams.push('(type=core-site&tag=' + coreSiteTag + ')');
  58. this.set("hdfsSiteTag", {name : "hdfsSiteTag", value : hdfsSiteTag});
  59. this.set("coreSiteTag", {name : "coreSiteTag", value : coreSiteTag});
  60. if (App.Service.find().someProperty('serviceName', 'HBASE')) {
  61. var hbaseSiteTag = data.Clusters.desired_configs['hbase-site'].tag;
  62. urlParams.push('(type=hbase-site&tag=' + hbaseSiteTag + ')');
  63. this.set("hbaseSiteTag", {name : "hbaseSiteTag", value : hbaseSiteTag});
  64. }
  65. if (App.Service.find().someProperty('serviceName', 'ACCUMULO')) {
  66. var accumuloSiteTag = data.Clusters.desired_configs['accumulo-site'].tag;
  67. urlParams.push('(type=accumulo-site&tag=' + accumuloSiteTag + ')');
  68. this.set("accumuloSiteTag", {name : "accumuloSiteTag", value : accumuloSiteTag});
  69. }
  70. App.ajax.send({
  71. name: 'admin.get.all_configurations',
  72. sender: this,
  73. data: {
  74. urlParams: urlParams.join('|')
  75. },
  76. success: 'onLoadConfigs',
  77. error: 'onTaskError'
  78. });
  79. },
  80. onLoadConfigs: function (data) {
  81. this.set('serverConfigData',data);
  82. this.removeConfigs(this.get('configsToRemove'), this.get('serverConfigData'));
  83. this.tweakServiceConfigs(this.get('haConfig.configs'));
  84. this.renderServiceConfigs(this.get('haConfig'));
  85. this.set('isLoaded', true);
  86. },
  87. tweakServiceConfigs: function(configs) {
  88. var nameServiceId = this.get('content.nameServiceId');
  89. var nameServiceConfig = configs.findProperty('name','dfs.nameservices');
  90. this.setConfigInitialValue(nameServiceConfig,nameServiceId);
  91. var defaultFsConfig = configs.findProperty('name','fs.defaultFS');
  92. this.setConfigInitialValue(defaultFsConfig, "hdfs://" + nameServiceId);
  93. this.tweakServiceConfigNames(configs,nameServiceId);
  94. this.tweakServiceConfigValues(configs,nameServiceId);
  95. },
  96. tweakServiceConfigNames: function(configs,nameServiceId) {
  97. var regex = new RegExp("\\$\\{dfs.nameservices\\}","g");
  98. configs.forEach(function(config) {
  99. if (config.name.contains("${dfs.nameservices}")) {
  100. config.name = config.name.replace(regex,nameServiceId);
  101. config.displayName = config.displayName.replace(regex,nameServiceId);
  102. }
  103. }, this);
  104. },
  105. tweakServiceConfigValues: function(configs,nameServiceId) {
  106. var currentNameNodeHost = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').findProperty('isInstalled', true).hostName;
  107. var newNameNodeHost = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').findProperty('isInstalled', false).hostName;
  108. var journalNodeHosts = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
  109. var zooKeeperHosts = this.get('content.masterComponentHosts').filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName');
  110. var config = configs.findProperty('name','dfs.namenode.rpc-address.' + nameServiceId + '.nn1');
  111. this.setConfigInitialValue(config,currentNameNodeHost + ':8020');
  112. config = configs.findProperty('name','dfs.namenode.rpc-address.' + nameServiceId + '.nn2');
  113. this.setConfigInitialValue(config,newNameNodeHost + ':8020');
  114. config = configs.findProperty('name','dfs.namenode.http-address.' + nameServiceId + '.nn1');
  115. this.setConfigInitialValue(config,currentNameNodeHost + ':50070');
  116. config = configs.findProperty('name','dfs.namenode.http-address.' + nameServiceId + '.nn2');
  117. this.setConfigInitialValue(config,newNameNodeHost + ':50070');
  118. config = configs.findProperty('name','dfs.namenode.https-address.' + nameServiceId + '.nn1');
  119. this.setConfigInitialValue(config,currentNameNodeHost + ':50470');
  120. config = configs.findProperty('name','dfs.namenode.https-address.' + nameServiceId + '.nn2');
  121. this.setConfigInitialValue(config,newNameNodeHost + ':50470');
  122. config = configs.findProperty('name','dfs.namenode.shared.edits.dir');
  123. this.setConfigInitialValue(config,'qjournal://' + journalNodeHosts[0] + ':8485;' + journalNodeHosts[1] + ':8485;' + journalNodeHosts[2] + ':8485/' + nameServiceId);
  124. config = configs.findProperty('name','ha.zookeeper.quorum');
  125. this.setConfigInitialValue(config,zooKeeperHosts[0] + ':2181,' + zooKeeperHosts[1] + ':2181,' + zooKeeperHosts[2] + ':2181');
  126. config = configs.findProperty('name','hbase.rootdir');
  127. if (App.Service.find().someProperty('serviceName', 'HBASE')) {
  128. var value = this.get('serverConfigData.items').findProperty('type', 'hbase-site').properties['hbase.rootdir'].replace(/\/\/[^\/]*/, '//' + nameServiceId);
  129. this.setConfigInitialValue(config,value);
  130. }
  131. config = configs.findProperty('name','instance.volumes');
  132. var config2 = configs.findProperty('name','instance.volumes.replacements');
  133. if (App.Service.find().someProperty('serviceName', 'ACCUMULO')) {
  134. var oldValue = this.get('serverConfigData.items').findProperty('type', 'accumulo-site').properties['instance.volumes'];
  135. var value = oldValue.replace(/\/\/[^\/]*/, '//' + nameServiceId);
  136. var replacements = oldValue + " " + value;
  137. this.setConfigInitialValue(config,value);
  138. this.setConfigInitialValue(config2,replacements)
  139. }
  140. config = configs.findProperty('name','dfs.journalnode.edits.dir');
  141. if (App.get('isHadoopWindowsStack') && App.Service.find().someProperty('serviceName', 'HDFS')) {
  142. var value = this.get('serverConfigData.items').findProperty('type', 'hdfs-site').properties['dfs.journalnode.edits.dir'];
  143. this.setConfigInitialValue(config, value);
  144. }
  145. },
  146. /**
  147. * Find and remove config properties in <code>serverConfigData</code>
  148. * @param configsToRemove - map of config sites and properties to remove
  149. * @param configs - configuration object
  150. * @returns {Object}
  151. */
  152. removeConfigs:function (configsToRemove, configs) {
  153. Em.keys(configsToRemove).forEach(function(site){
  154. var siteConfigs = configs.items.findProperty('type', site);
  155. if (siteConfigs) {
  156. configsToRemove[site].forEach(function (property) {
  157. delete siteConfigs.properties[property];
  158. });
  159. }
  160. });
  161. return configs;
  162. },
  163. setConfigInitialValue: function(config,value) {
  164. config.value = value;
  165. config.recommendedValue = value;
  166. },
  167. renderServiceConfigs: function (_serviceConfig) {
  168. var serviceConfig = App.ServiceConfig.create({
  169. serviceName: _serviceConfig.serviceName,
  170. displayName: _serviceConfig.displayName,
  171. configCategories: [],
  172. showConfig: true,
  173. configs: []
  174. });
  175. _serviceConfig.configCategories.forEach(function (_configCategory) {
  176. if (App.Service.find().someProperty('serviceName', _configCategory.name)) {
  177. serviceConfig.configCategories.pushObject(_configCategory);
  178. }
  179. }, this);
  180. this.loadComponentConfigs(_serviceConfig, serviceConfig);
  181. this.get('stepConfigs').pushObject(serviceConfig);
  182. this.set('selectedService', this.get('stepConfigs').objectAt(0));
  183. this.once = true;
  184. },
  185. /**
  186. * Load child components to service config object
  187. * @param _componentConfig
  188. * @param componentConfig
  189. */
  190. loadComponentConfigs: function (_componentConfig, componentConfig) {
  191. _componentConfig.configs.forEach(function (_serviceConfigProperty) {
  192. var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
  193. componentConfig.configs.pushObject(serviceConfigProperty);
  194. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  195. serviceConfigProperty.validate();
  196. }, this);
  197. },
  198. isNextDisabled: function () {
  199. return !this.get('isLoaded');
  200. }.property('isLoaded')
  201. });