step3_controller.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. loadStep: function () {
  24. this.renderConfigs();
  25. },
  26. /**
  27. * Render configs to show them in <code>App.ServiceConfigView</code>
  28. */
  29. renderConfigs: function () {
  30. var configs = $.extend(true, {}, require('data/HDP2/rm_ha_properties').haConfig);
  31. var serviceConfig = App.ServiceConfig.create({
  32. serviceName: configs.serviceName,
  33. displayName: configs.displayName,
  34. configCategories: [],
  35. showConfig: true,
  36. configs: []
  37. });
  38. configs.configCategories.forEach(function (configCategory) {
  39. if (App.Service.find().someProperty('serviceName', configCategory.name)) {
  40. serviceConfig.configCategories.pushObject(configCategory);
  41. }
  42. }, this);
  43. this.renderConfigProperties(configs, serviceConfig);
  44. this.setDynamicConfigValues(serviceConfig);
  45. this.set('selectedService', serviceConfig);
  46. },
  47. /**
  48. * Set values dependent on host selection
  49. * @param configs
  50. */
  51. setDynamicConfigValues: function (configs) {
  52. var configProperties = configs.configs;
  53. var currentRMHost = this.get('content.rmHosts.currentRM');
  54. var additionalRMHost = this.get('content.rmHosts.additionalRM');
  55. var zooKeeperHosts = App.HostComponent.find().filterProperty('componentName', 'ZOOKEEPER_SERVER').mapProperty('host.hostName').join(',');
  56. configProperties.findProperty('name', 'yarn.resourcemanager.hostname.rm1').set('value', currentRMHost).set('defaultValue', currentRMHost);
  57. configProperties.findProperty('name', 'yarn.resourcemanager.hostname.rm2').set('value', additionalRMHost).set('defaultValue', additionalRMHost);
  58. configProperties.findProperty('name', 'yarn.resourcemanager.zk-address').set('value', zooKeeperHosts).set('defaultValue', zooKeeperHosts);
  59. },
  60. /**
  61. * Load child components to service config object
  62. * @param _componentConfig
  63. * @param componentConfig
  64. */
  65. renderConfigProperties: function (_componentConfig, componentConfig) {
  66. _componentConfig.configs.forEach(function (_serviceConfigProperty) {
  67. var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
  68. componentConfig.configs.pushObject(serviceConfigProperty);
  69. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  70. serviceConfigProperty.validate();
  71. }, this);
  72. }
  73. });