step3_controller.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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} hawqHaConfigDependencies
  20. */
  21. var App = require('app');
  22. require('utils/configs/hawq_ha_config_initializer');
  23. App.AddHawqStandbyWizardStep3Controller = Em.Controller.extend({
  24. name: "addHawqStandbyWizardStep3Controller",
  25. // Used in service_config.hbs
  26. // selectedService
  27. // hideDependenciesInfoBar
  28. // versionLoaded
  29. selectedService: null,
  30. hawqProps: null,
  31. hideDependenciesInfoBar: true,
  32. versionLoaded: true,
  33. // Used in step3.hbs
  34. // isLoaded
  35. // isSubmitDisabled
  36. // hawqMasterDirectoryCleanUpMessage
  37. isLoaded: false,
  38. isSubmitDisabled: Em.computed.not('isLoaded'),
  39. loadStep: function () {
  40. this.renderConfigs();
  41. },
  42. content: Em.Object.create({
  43. controllerName: 'addHawqStandbyWizardStep3Controller'
  44. }),
  45. /**
  46. * Render configs to show them in <code>App.ServiceConfigView</code>
  47. */
  48. renderConfigs: function () {
  49. var configs = require('data/HDP2.3/hawq_ha_properties').haConfig;
  50. var serviceConfig = App.ServiceConfig.create({
  51. serviceName: configs.serviceName,
  52. displayName: configs.displayName,
  53. configCategories: [],
  54. showConfig: true,
  55. configs: []
  56. });
  57. configs.configCategories.forEach(function (configCategory) {
  58. if (App.Service.find().someProperty('serviceName', configCategory.name)) {
  59. serviceConfig.configCategories.pushObject(configCategory);
  60. }
  61. }, this);
  62. this.renderConfigProperties(configs, serviceConfig);
  63. App.ajax.send({
  64. name: 'config.tags',
  65. sender: this,
  66. success: 'loadConfigTagsSuccessCallback',
  67. error: '',
  68. data: {
  69. serviceConfig: serviceConfig
  70. }
  71. });
  72. },
  73. loadConfigTagsSuccessCallback: function (data, opt, params) {
  74. var urlParams = '(type=hawq-site&tag=' + data.Clusters.desired_configs['hawq-site'].tag + ')';
  75. App.ajax.send({
  76. name: 'reassign.load_configs',
  77. sender: this,
  78. data: {
  79. urlParams: urlParams,
  80. serviceConfig: params.serviceConfig
  81. },
  82. success: 'loadConfigsSuccessCallback',
  83. error: 'loadConfigsSuccessCallback'
  84. });
  85. },
  86. loadConfigsSuccessCallback: function (data, opt, params) {
  87. params = params.serviceConfig ? params.serviceConfig : {};
  88. this.setDynamicConfigValues(params, data);
  89. this.setProperties({
  90. selectedService: params,
  91. isLoaded: true,
  92. hawqProps: data
  93. });
  94. },
  95. setDynamicConfigValues: function (configs, data) {
  96. var topologyLocalDB = this.get('content').getProperties(['masterComponentHosts']);
  97. configs.configs.forEach(function (config) {
  98. App.HawqHaConfigInitializer.initialValue(config, topologyLocalDB);
  99. });
  100. App.HawqHaConfigInitializer.cleanup();
  101. return configs;
  102. },
  103. /**
  104. * Load child components to service config object
  105. * @param _componentConfig
  106. * @param componentConfig
  107. */
  108. renderConfigProperties: function (_componentConfig, componentConfig) {
  109. _componentConfig.configs.forEach(function (_serviceConfigProperty) {
  110. var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
  111. componentConfig.configs.pushObject(serviceConfigProperty);
  112. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  113. }, this);
  114. },
  115. submit: function () {
  116. if (!this.get('isSubmitDisabled')) {
  117. dataDir = this.get('hawqProps').items[0].properties['hawq_master_directory'];
  118. hawqStandby = this.get('content.hawqHosts.newHawqStandby');
  119. App.showConfirmationPopup(
  120. function() {
  121. App.get('router.mainAdminKerberosController').getKDCSessionState(function() {
  122. App.router.send("next");
  123. });
  124. },
  125. Em.I18n.t('admin.addHawqStandby.wizard.step3.confirm.dataDir.body').format(dataDir, hawqStandby),
  126. null,
  127. Em.I18n.t('admin.addHawqStandby.wizard.step3.confirm.dataDir.title'),
  128. "Confirm",
  129. false
  130. );
  131. }
  132. },
  133. });