step7_controller.js 8.8 KB

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