step7_controller.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. /**
  20. * By Step 7, we have the following information stored in App.db and set on this
  21. * controller by the router.
  22. *
  23. * selectedServices: App.db.selectedServices (the services that the user selected in Step 4)
  24. * masterComponentHosts: App.db.masterComponentHosts (master-components-to-hosts mapping the user selected in Step 5)
  25. * slaveComponentHosts: App.db.slaveComponentHosts (slave-components-to-hosts mapping the user selected in Step 6)
  26. *
  27. */
  28. App.WizardStep7Controller = Em.Controller.extend({
  29. name: 'wizardStep7Controller',
  30. stepConfigs: [], //contains all field properties that are viewed in this step
  31. selectedService: null,
  32. slaveHostToGroup: null,
  33. isSubmitDisabled: function () {
  34. return !this.stepConfigs.everyProperty('errorCount', 0);
  35. }.property('stepConfigs.@each.errorCount'),
  36. selectedServiceNames: function () {
  37. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).mapProperty('serviceName');
  38. }.property('content.services').cacheable(),
  39. masterComponentHosts: function () {
  40. return this.get('content.masterComponentHosts');
  41. }.property('content.masterComponentHosts'),
  42. slaveComponentHosts: function () {
  43. return this.get('content.slaveGroupProperties');
  44. }.property('content.slaveGroupProperties', 'content.slaveComponentHosts'),
  45. serviceConfigs: require('data/service_configs'),
  46. configMapping: require('data/config_mapping'),
  47. customConfigs: require('data/custom_configs'),
  48. customData: [],
  49. clearStep: function () {
  50. this.get('stepConfigs').clear();
  51. },
  52. /**
  53. * On load function
  54. */
  55. loadStep: function () {
  56. console.log("TRACE: Loading step7: Configure Services");
  57. this.clearStep();
  58. var serviceConfigs = this.get('serviceConfigs');
  59. var advancedConfig = this.get('content.advancedServiceConfig') || [];
  60. this.loadAdvancedConfig(serviceConfigs,advancedConfig);
  61. this.loadHostConfigs();
  62. this.loadCustomConfig();
  63. this.renderServiceConfigs(serviceConfigs);
  64. var storedServices = this.get('content.serviceConfigProperties');
  65. if (storedServices) {
  66. var configs = new Ember.Set();
  67. // for all services`
  68. this.get('stepConfigs').forEach(function (_content) {
  69. //for all components
  70. _content.get('configs').forEach(function (_config) {
  71. var componentVal = storedServices.findProperty('name', _config.get('name'));
  72. //if we have config for specified component
  73. if (componentVal) {
  74. //set it
  75. _config.set('value', componentVal.value)
  76. }
  77. }, this);
  78. }, this);
  79. }
  80. },
  81. /*
  82. Loads the advanced configs fetched from the server metadata libarary
  83. */
  84. loadAdvancedConfig: function (serviceConfigs,advancedConfig) {
  85. advancedConfig.forEach(function (_config) {
  86. if (_config) {
  87. var service = serviceConfigs.findProperty('serviceName', _config.serviceName);
  88. if (service) {
  89. if (this.get('configMapping').someProperty('name', _config.name)) {
  90. } else if (!(service.configs.someProperty('name', _config.name))) {
  91. _config.id = "site property";
  92. _config.category = 'Advanced';
  93. _config.displayName = _config.name;
  94. _config.defaultValue = _config.value;
  95. // make all advanced configs optional and populated by default
  96. /*
  97. if (/\${.*}/.test(_config.value) || (service.serviceName !== 'OOZIE' && service.serviceName !== 'HBASE')) {
  98. _config.isRequired = false;
  99. _config.value = '';
  100. } else if (/^\s+$/.test(_config.value)) {
  101. _config.isRequired = false;
  102. }
  103. */
  104. _config.isRequired = false;
  105. _config.isVisible = true;
  106. _config.displayType = 'advanced';
  107. service.configs.pushObject(_config);
  108. }
  109. }
  110. }
  111. }, this);
  112. },
  113. /*
  114. loads host related configs obtained from server.
  115. */
  116. loadHostConfigs: function() {
  117. },
  118. /**
  119. * Render a custom conf-site box for entering properties that will be written in *-site.xml files of the services
  120. */
  121. loadCustomConfig: function () {
  122. var serviceConfigs = this.get('serviceConfigs');
  123. this.get('customConfigs').forEach(function (_config) {
  124. var service = serviceConfigs.findProperty('serviceName', _config.serviceName);
  125. if (service) {
  126. if (!(service.configs.someProperty('name', _config.name))) {
  127. service.configs.pushObject(_config);
  128. }
  129. }
  130. }, this);
  131. },
  132. /**
  133. * Render configs for active services
  134. * @param serviceConfigs
  135. */
  136. renderServiceConfigs: function (serviceConfigs) {
  137. serviceConfigs.forEach(function (_serviceConfig) {
  138. var serviceConfig = App.ServiceConfig.create({
  139. filename: _serviceConfig.filename,
  140. serviceName: _serviceConfig.serviceName,
  141. displayName: _serviceConfig.displayName,
  142. configCategories: _serviceConfig.configCategories,
  143. configs: []
  144. });
  145. if (this.get('selectedServiceNames').contains(serviceConfig.serviceName) || serviceConfig.serviceName === 'MISC') {
  146. this.loadComponentConfigs(_serviceConfig, serviceConfig);
  147. console.log('pushing ' + serviceConfig.serviceName);
  148. this.get('stepConfigs').pushObject(serviceConfig);
  149. } else {
  150. console.log('skipping ' + serviceConfig.serviceName);
  151. }
  152. }, this);
  153. var miscConfigs = this.get('stepConfigs').findProperty('serviceName', 'MISC').configs;
  154. var showProxyGroup = this.get('selectedServiceNames').contains('HIVE') ||
  155. this.get('selectedServiceNames').contains('HCATALOG') ||
  156. this.get('selectedServiceNames').contains('OOZIE');
  157. miscConfigs.findProperty('name', 'proxyuser_group').set('isVisible', showProxyGroup);
  158. miscConfigs.findProperty('name', 'hbase_user').set('isVisible', this.get('selectedServiceNames').contains('HBASE'));
  159. miscConfigs.findProperty('name', 'mapred_user').set('isVisible', this.get('selectedServiceNames').contains('MAPREDUCE'));
  160. miscConfigs.findProperty('name', 'hive_user').set('isVisible', this.get('selectedServiceNames').contains('HIVE'));
  161. miscConfigs.findProperty('name', 'hcat_user').set('isVisible', this.get('selectedServiceNames').contains('HCATALOG'));
  162. miscConfigs.findProperty('name', 'templeton_user').set('isVisible', this.get('selectedServiceNames').contains('HCATALOG'));
  163. miscConfigs.findProperty('name', 'oozie_user').set('isVisible', this.get('selectedServiceNames').contains('OOZIE'));
  164. miscConfigs.findProperty('name', 'pig_user').set('isVisible', this.get('selectedServiceNames').contains('PIG'));
  165. miscConfigs.findProperty('name', 'sqoop_user').set('isVisible', this.get('selectedServiceNames').contains('SQOOP'));
  166. miscConfigs.findProperty('name', 'zk_user').set('isVisible', this.get('selectedServiceNames').contains('ZOOKEEPER'));
  167. this.set('selectedService', this.get('stepConfigs').objectAt(0));
  168. },
  169. /**
  170. * Load child components to service config object
  171. * @param _componentConfig
  172. * @param componentConfig
  173. */
  174. loadComponentConfigs: function (_componentConfig, componentConfig) {
  175. _componentConfig.configs.forEach(function (_serviceConfigProperty) {
  176. var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
  177. serviceConfigProperty.serviceConfig = componentConfig;
  178. serviceConfigProperty.initialValue();
  179. componentConfig.configs.pushObject(serviceConfigProperty);
  180. serviceConfigProperty.validate();
  181. }, this);
  182. },
  183. submit: function () {
  184. if (!this.get('isSubmitDisabled')) {
  185. App.router.send('next');
  186. }
  187. }
  188. });