step3_controller.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. clearStep: function () {
  27. this.get('stepConfigs').clear();
  28. this.serverConfigData = {};
  29. },
  30. loadStep: function () {
  31. this.clearStep();
  32. this.loadConfigsTags();
  33. },
  34. loadConfigsTags: function () {
  35. App.ajax.send({
  36. name: 'config.tags',
  37. sender: this,
  38. success: 'onLoadConfigsTags',
  39. error: 'onTaskError'
  40. });
  41. },
  42. onLoadConfigsTags: function (data) {
  43. var urlParams = [];
  44. var hdfsSiteTag = data.Clusters.desired_configs['hdfs-site'].tag;
  45. var coreSiteTag = data.Clusters.desired_configs['core-site'].tag;
  46. urlParams.push('(type=hdfs-site&tag=' + hdfsSiteTag + ')');
  47. urlParams.push('(type=core-site&tag=' + coreSiteTag + ')');
  48. this.set("hdfsSiteTag", {name : "hdfsSiteTag", value : hdfsSiteTag});
  49. this.set("coreSiteTag", {name : "coreSiteTag", value : coreSiteTag});
  50. if (App.Service.find().someProperty('serviceName', 'HBASE')) {
  51. var hbaseSiteTag = data.Clusters.desired_configs['hbase-site'].tag;
  52. urlParams.push('(type=hbase-site&tag=' + hbaseSiteTag + ')');
  53. this.set("hbaseSiteTag", {name : "hbaseSiteTag", value : hbaseSiteTag});
  54. }
  55. App.ajax.send({
  56. name: 'admin.get.all_configurations',
  57. sender: this,
  58. data: {
  59. urlParams: urlParams.join('|')
  60. },
  61. success: 'onLoadConfigs',
  62. error: 'onTaskError'
  63. });
  64. },
  65. onLoadConfigs: function (data) {
  66. this.set('serverConfigData',data);
  67. this.tweakServiceConfigs(this.get('haConfig.configs'));
  68. this.renderServiceConfigs(this.get('haConfig'));
  69. },
  70. tweakServiceConfigs: function(configs) {
  71. var nameServiceId = this.get('content.nameServiceId');
  72. var nameServiceConfig = configs.findProperty('name','dfs.nameservices');
  73. this.setConfigInitialValue(nameServiceConfig,nameServiceId);
  74. var defaultFsConfig = configs.findProperty('name','fs.defaultFS');
  75. this.setConfigInitialValue(defaultFsConfig, "hdfs://" + nameServiceId);
  76. this.tweakServiceConfigNames(configs,nameServiceId);
  77. this.tweakServiceConfigValues(configs,nameServiceId);
  78. },
  79. tweakServiceConfigNames: function(configs,nameServiceId) {
  80. var regex = new RegExp("\\$\\{dfs.nameservices\\}","g");
  81. configs.forEach(function(config) {
  82. if (config.name.contains("${dfs.nameservices}")) {
  83. config.name = config.name.replace(regex,nameServiceId);
  84. config.displayName = config.displayName.replace(regex,nameServiceId);
  85. }
  86. }, this);
  87. },
  88. tweakServiceConfigValues: function(configs,nameServiceId) {
  89. var currentNameNodeHost = this.get('content.masterComponentHosts').findProperty('isCurNameNode').hostName;
  90. var newNameNodeHost = this.get('content.masterComponentHosts').findProperty('isAddNameNode').hostName;
  91. var journalNodeHosts = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
  92. var zooKeeperHosts = this.get('content.masterComponentHosts').filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName');
  93. var config = configs.findProperty('name','dfs.namenode.rpc-address.' + nameServiceId + '.nn1');
  94. this.setConfigInitialValue(config,currentNameNodeHost + ':8020');
  95. config = configs.findProperty('name','dfs.namenode.rpc-address.' + nameServiceId + '.nn2');
  96. this.setConfigInitialValue(config,newNameNodeHost + ':8020');
  97. config = configs.findProperty('name','dfs.namenode.http-address.' + nameServiceId + '.nn1');
  98. this.setConfigInitialValue(config,currentNameNodeHost + ':50070');
  99. config = configs.findProperty('name','dfs.namenode.http-address.' + nameServiceId + '.nn2');
  100. this.setConfigInitialValue(config,newNameNodeHost + ':50070');
  101. config = configs.findProperty('name','dfs.namenode.https-address.' + nameServiceId + '.nn1');
  102. this.setConfigInitialValue(config,currentNameNodeHost + ':50470');
  103. config = configs.findProperty('name','dfs.namenode.https-address.' + nameServiceId + '.nn2');
  104. this.setConfigInitialValue(config,newNameNodeHost + ':50470');
  105. config = configs.findProperty('name','dfs.namenode.shared.edits.dir');
  106. this.setConfigInitialValue(config,'qjournal://' + journalNodeHosts[0] + ':8485;' + journalNodeHosts[1] + ':8485;' + journalNodeHosts[2] + ':8485/' + nameServiceId);
  107. config = configs.findProperty('name','ha.zookeeper.quorum');
  108. this.setConfigInitialValue(config,zooKeeperHosts[0] + ':2181,' + zooKeeperHosts[1] + ':2181,' + zooKeeperHosts[2] + ':2181');
  109. config = configs.findProperty('name','hbase.rootdir');
  110. if (App.Service.find().someProperty('serviceName', 'HBASE')) {
  111. var value = this.get('serverConfigData.items').findProperty('type', 'hbase-site').properties['hbase.rootdir'].replace(/\/\/[^\/]*/, '//' + nameServiceId);
  112. this.setConfigInitialValue(config,value);
  113. }
  114. },
  115. setConfigInitialValue: function(config,value) {
  116. config.value = value;
  117. config.defaultValue = value;
  118. },
  119. renderServiceConfigs: function (_serviceConfig) {
  120. var serviceConfig = App.ServiceConfig.create({
  121. serviceName: _serviceConfig.serviceName,
  122. displayName: _serviceConfig.displayName,
  123. configCategories: [],
  124. showConfig: true,
  125. configs: []
  126. });
  127. _serviceConfig.configCategories.forEach(function (_configCategory) {
  128. if (App.Service.find().someProperty('serviceName', _configCategory.name)) {
  129. serviceConfig.configCategories.pushObject(_configCategory);
  130. }
  131. }, this);
  132. this.loadComponentConfigs(_serviceConfig, serviceConfig);
  133. this.get('stepConfigs').pushObject(serviceConfig);
  134. this.set('selectedService', this.get('stepConfigs').objectAt(0));
  135. this.once = true;
  136. },
  137. /**
  138. * Load child components to service config object
  139. * @param _componentConfig
  140. * @param componentConfig
  141. */
  142. loadComponentConfigs: function (_componentConfig, componentConfig) {
  143. _componentConfig.configs.forEach(function (_serviceConfigProperty) {
  144. var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
  145. componentConfig.configs.pushObject(serviceConfigProperty);
  146. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  147. serviceConfigProperty.validate();
  148. }, this);
  149. }
  150. });