step3_controller.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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.RMHighAvailabilityWizardStep3Controller = Em.Controller.extend({
  20. name: "rMHighAvailabilityWizardStep3Controller",
  21. selectedService: null,
  22. versionLoaded: true,
  23. hideDependenciesInfoBar: true,
  24. isLoaded: false,
  25. isSubmitDisabled: function () {
  26. return !this.get('isLoaded');
  27. }.property('isLoaded'),
  28. loadStep: function () {
  29. this.renderConfigs();
  30. },
  31. /**
  32. * Render configs to show them in <code>App.ServiceConfigView</code>
  33. */
  34. renderConfigs: function () {
  35. var configs = $.extend(true, {}, require('data/HDP2/rm_ha_properties').haConfig);
  36. var serviceConfig = App.ServiceConfig.create({
  37. serviceName: configs.serviceName,
  38. displayName: configs.displayName,
  39. configCategories: [],
  40. showConfig: true,
  41. configs: []
  42. });
  43. configs.configCategories.forEach(function (configCategory) {
  44. if (App.Service.find().someProperty('serviceName', configCategory.name)) {
  45. serviceConfig.configCategories.pushObject(configCategory);
  46. }
  47. }, this);
  48. this.renderConfigProperties(configs, serviceConfig);
  49. App.ajax.send({
  50. name: 'config.tags',
  51. sender: this,
  52. success: 'loadConfigTagsSuccessCallback',
  53. error: 'loadConfigsErrorCallback',
  54. data: {
  55. serviceConfig: serviceConfig
  56. }
  57. });
  58. },
  59. loadConfigTagsSuccessCallback: function (data, opt, params) {
  60. var urlParams = '(type=zoo.cfg&tag=' + data.Clusters.desired_configs['zoo.cfg'].tag + ')|' +
  61. '(type=yarn-site&tag=' + data.Clusters.desired_configs['yarn-site'].tag + ')';
  62. App.ajax.send({
  63. name: 'reassign.load_configs',
  64. sender: this,
  65. data: {
  66. urlParams: urlParams,
  67. serviceConfig: params.serviceConfig
  68. },
  69. success: 'loadConfigsSuccessCallback',
  70. error: 'loadConfigsSuccessCallback'
  71. });
  72. },
  73. loadConfigsSuccessCallback: function (data, opt, params) {
  74. var
  75. zooCfg = data && data.items ? data.items.findProperty('type', 'zoo.cfg') : null,
  76. yarnSite = data && data.items ? data.items.findProperty('type', 'yarn-site') : null,
  77. portValue = zooCfg && Em.get(zooCfg, 'properties.clientPort'),
  78. zkPort = portValue ? portValue : '2181',
  79. webAddressPort = yarnSite && yarnSite.properties ? yarnSite.properties['yarn.resourcemanager.webapp.address'] : null,
  80. httpsWebAddressPort = yarnSite && yarnSite.properties ? yarnSite. properties['yarn.resourcemanager.webapp.https.address'] : null;
  81. webAddressPort = webAddressPort && webAddressPort.match(/:[0-9]*/g) ? webAddressPort.match(/:[0-9]*/g)[0] : ":8088";
  82. httpsWebAddressPort = httpsWebAddressPort && httpsWebAddressPort.match(/:[0-9]*/g) ? httpsWebAddressPort.match(/:[0-9]*/g)[0] : ":8090";
  83. params = params.serviceConfig ? params.serviceConfig : arguments[4].serviceConfig;
  84. this.setDynamicConfigValues(params, zkPort, webAddressPort, httpsWebAddressPort);
  85. this.setProperties({
  86. selectedService: params,
  87. isLoaded: true
  88. });
  89. },
  90. /**
  91. * Set values dependent on host selection
  92. * @param configs
  93. * @param zkPort
  94. * @param webAddressPort
  95. * @param httpsWebAddressPort
  96. */
  97. setDynamicConfigValues: function (configs, zkPort, webAddressPort, httpsWebAddressPort) {
  98. var
  99. configProperties = configs.configs,
  100. currentRMHost = this.get('content.rmHosts.currentRM'),
  101. additionalRMHost = this.get('content.rmHosts.additionalRM'),
  102. zooKeeperHostsWithPort = App.HostComponent.find().filterProperty('componentName', 'ZOOKEEPER_SERVER').map(function (item) {
  103. return item.get('hostName') + ':' + zkPort;
  104. }).join(',');
  105. configProperties.findProperty('name', 'yarn.resourcemanager.hostname.rm1').set('value', currentRMHost).set('recommendedValue', currentRMHost);
  106. configProperties.findProperty('name', 'yarn.resourcemanager.hostname.rm2').set('value', additionalRMHost).set('recommendedValue', additionalRMHost);
  107. configProperties.findProperty('name', 'yarn.resourcemanager.zk-address').set('value', zooKeeperHostsWithPort).set('recommendedValue', zooKeeperHostsWithPort);
  108. configProperties.findProperty('name', 'yarn.resourcemanager.webapp.address.rm1')
  109. .set('value', currentRMHost + webAddressPort)
  110. .set('recommendedValue', currentRMHost + webAddressPort);
  111. configProperties.findProperty('name', 'yarn.resourcemanager.webapp.address.rm2')
  112. .set('value', additionalRMHost + webAddressPort)
  113. .set('recommendedValue', additionalRMHost + webAddressPort);
  114. configProperties.findProperty('name', 'yarn.resourcemanager.webapp.https.address.rm1')
  115. .set('value', currentRMHost + httpsWebAddressPort)
  116. .set('recommendedValue', currentRMHost + httpsWebAddressPort);
  117. configProperties.findProperty('name', 'yarn.resourcemanager.webapp.https.address.rm2')
  118. .set('value', additionalRMHost + httpsWebAddressPort)
  119. .set('recommendedValue', additionalRMHost + httpsWebAddressPort);
  120. },
  121. /**
  122. * Load child components to service config object
  123. * @param _componentConfig
  124. * @param componentConfig
  125. */
  126. renderConfigProperties: function (_componentConfig, componentConfig) {
  127. _componentConfig.configs.forEach(function (_serviceConfigProperty) {
  128. var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
  129. componentConfig.configs.pushObject(serviceConfigProperty);
  130. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  131. serviceConfigProperty.validate();
  132. }, this);
  133. },
  134. submit: function () {
  135. if (!this.get('isSubmitDisabled')) {
  136. App.get('router.mainAdminKerberosController').getKDCSessionState(function() {
  137. App.router.send("next");
  138. });
  139. }
  140. }
  141. });