step3_controller.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. /**
  19. * @typedef {object} rmHaConfigDependencies
  20. * @property {string|number} webAddressPort
  21. * @property {string|number} httpsWebAddressPort
  22. * @property {string|number} zkClientPort
  23. */
  24. var App = require('app');
  25. require('utils/configs/rm_ha_config_initializer');
  26. App.RMHighAvailabilityWizardStep3Controller = Em.Controller.extend({
  27. name: "rMHighAvailabilityWizardStep3Controller",
  28. selectedService: null,
  29. versionLoaded: true,
  30. hideDependenciesInfoBar: true,
  31. isLoaded: false,
  32. isSubmitDisabled: Em.computed.not('isLoaded'),
  33. loadStep: function () {
  34. this.renderConfigs();
  35. },
  36. /**
  37. * Render configs to show them in <code>App.ServiceConfigView</code>
  38. */
  39. renderConfigs: function () {
  40. var configs = $.extend(true, {}, require('data/HDP2/rm_ha_properties').haConfig);
  41. var serviceConfig = App.ServiceConfig.create({
  42. serviceName: configs.serviceName,
  43. displayName: configs.displayName,
  44. configCategories: [],
  45. showConfig: true,
  46. configs: []
  47. });
  48. configs.configCategories.forEach(function (configCategory) {
  49. if (App.Service.find().someProperty('serviceName', configCategory.name)) {
  50. serviceConfig.configCategories.pushObject(configCategory);
  51. }
  52. }, this);
  53. this.renderConfigProperties(configs, serviceConfig);
  54. App.ajax.send({
  55. name: 'config.tags',
  56. sender: this,
  57. success: 'loadConfigTagsSuccessCallback',
  58. error: 'loadConfigsErrorCallback',
  59. data: {
  60. serviceConfig: serviceConfig
  61. }
  62. });
  63. },
  64. loadConfigTagsSuccessCallback: function (data, opt, params) {
  65. var urlParams = '(type=zoo.cfg&tag=' + data.Clusters.desired_configs['zoo.cfg'].tag + ')|' +
  66. '(type=yarn-site&tag=' + data.Clusters.desired_configs['yarn-site'].tag + ')|' +
  67. '(type=yarn-env&tag=' + data.Clusters.desired_configs['yarn-env'].tag + ')';
  68. App.ajax.send({
  69. name: 'reassign.load_configs',
  70. sender: this,
  71. data: {
  72. urlParams: urlParams,
  73. serviceConfig: params.serviceConfig
  74. },
  75. success: 'loadConfigsSuccessCallback',
  76. error: 'loadConfigsSuccessCallback'
  77. });
  78. },
  79. loadConfigsSuccessCallback: function (data, opt, params) {
  80. params = params.serviceConfig ? params.serviceConfig : arguments[4].serviceConfig;
  81. this.setDynamicConfigValues(params, data);
  82. this.setProperties({
  83. selectedService: params,
  84. isLoaded: true
  85. });
  86. },
  87. /**
  88. * Get dependencies for new configs
  89. *
  90. * @param {{items: object[]}} data
  91. * @returns {rmHaConfigDependencies}
  92. * @private
  93. * @method _prepareDependencies
  94. */
  95. _prepareDependencies: function (data) {
  96. var ret = {};
  97. var zooCfg = data && data.items ? data.items.findProperty('type', 'zoo.cfg') : null;
  98. var yarnSite = data && data.items ? data.items.findProperty('type', 'yarn-site') : null;
  99. var portValue = zooCfg && Em.get(zooCfg, 'properties.clientPort');
  100. var webAddressPort = yarnSite && yarnSite.properties ? yarnSite.properties['yarn.resourcemanager.webapp.address'] : '';
  101. var httpsWebAddressPort = yarnSite && yarnSite.properties ? yarnSite. properties['yarn.resourcemanager.webapp.https.address'] : '';
  102. ret.webAddressPort = webAddressPort && webAddressPort.contains(':') ? webAddressPort.split(':')[1] : '8088';
  103. ret.httpsWebAddressPort = httpsWebAddressPort && httpsWebAddressPort.contains(':') ? httpsWebAddressPort.split(':')[1] : '8090';
  104. ret.zkClientPort = portValue ? portValue : '2181';
  105. return ret;
  106. },
  107. /**
  108. * Set values to the new configs
  109. *
  110. * @param {object} configs
  111. * @param {object} data
  112. * @returns {object}
  113. * @method setDynamicConfigValues
  114. */
  115. setDynamicConfigValues: function (configs, data) {
  116. var topologyLocalDB = this.get('content').getProperties(['masterComponentHosts', 'slaveComponentHosts', 'hosts']);
  117. var yarnUser = data.items.findProperty('type', 'yarn-env').properties.yarn_user;
  118. App.RmHaConfigInitializer.setup({
  119. yarnUser: yarnUser
  120. });
  121. var dependencies = this._prepareDependencies(data);
  122. /** add dynamic property 'hadoop.proxyuser.' + yarnUser + '.hosts' **/
  123. var proxyUserConfig = App.ServiceConfigProperty.create(App.config.createDefaultConfig('hadoop.proxyuser.' + yarnUser + '.hosts',
  124. 'core-site', false, {category : "HDFS", isUserProperty: false, isEditable: false, isOverridable: false, serviceName: 'MISC'}));
  125. configs.configs.pushObject(proxyUserConfig);
  126. configs.configs.forEach(function (config) {
  127. App.RmHaConfigInitializer.initialValue(config, topologyLocalDB, dependencies);
  128. });
  129. App.RmHaConfigInitializer.cleanup();
  130. return configs;
  131. },
  132. /**
  133. * Load child components to service config object
  134. * @param _componentConfig
  135. * @param componentConfig
  136. */
  137. renderConfigProperties: function (_componentConfig, componentConfig) {
  138. _componentConfig.configs.forEach(function (_serviceConfigProperty) {
  139. var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
  140. componentConfig.configs.pushObject(serviceConfigProperty);
  141. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  142. serviceConfigProperty.validate();
  143. }, this);
  144. },
  145. submit: function () {
  146. if (!this.get('isSubmitDisabled')) {
  147. App.get('router.mainAdminKerberosController').getKDCSessionState(function() {
  148. App.router.send("next");
  149. });
  150. }
  151. }
  152. });