step7_controller.js 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346
  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(App.ServerValidatorMixin, {
  29. name: 'wizardStep7Controller',
  30. /**
  31. * Contains all field properties that are viewed in this step
  32. * @type {object[]}
  33. */
  34. stepConfigs: [],
  35. selectedService: null,
  36. slaveHostToGroup: null,
  37. addMiscTabToPage: true,
  38. /**
  39. * Is Submit-click processing now
  40. * @type {bool}
  41. */
  42. submitButtonClicked: false,
  43. isRecommendedLoaded: false,
  44. /**
  45. * used in services_config.js view to mark a config with security icon
  46. */
  47. secureConfigs: require('data/HDP2/secure_mapping'),
  48. /**
  49. * config categories with secure properties
  50. * use only for add service wizard when security is enabled;
  51. */
  52. secureServices: function () {
  53. return $.extend(true, [], require('data/HDP2/secure_configs'));
  54. }.property(),
  55. /**
  56. * uses for add service - find out is security is enabled
  57. */
  58. securityEnabled: function () {
  59. return App.router.get('mainAdminSecurityController.securityEnabled');
  60. }.property('App.router.mainAdminSecurityController.securityEnabled'),
  61. /**
  62. * If miscConfigChange Modal is shown
  63. * @type {bool}
  64. */
  65. miscModalVisible: false,
  66. gangliaAvailableSpace: null,
  67. /**
  68. * @type {string}
  69. */
  70. gangliaMoutDir: '/',
  71. overrideToAdd: null,
  72. /**
  73. * Is installer controller used
  74. * @type {bool}
  75. */
  76. isInstaller: true,
  77. /**
  78. * List of config groups
  79. * @type {object[]}
  80. */
  81. configGroups: [],
  82. /**
  83. * List of config group to be deleted
  84. * @type {object[]}
  85. */
  86. groupsToDelete: [],
  87. preSelectedConfigGroup: null,
  88. /**
  89. * Currently selected config group
  90. * @type {object}
  91. */
  92. selectedConfigGroup: null,
  93. /**
  94. * Config tags of actually installed services
  95. * @type {array}
  96. */
  97. serviceConfigTags: [],
  98. /**
  99. * Are advanced configs loaded
  100. * @type {bool}
  101. */
  102. isAdvancedConfigLoaded: true,
  103. /**
  104. * Are applied to service configs loaded
  105. * @type {bool}
  106. */
  107. isAppliedConfigLoaded: true,
  108. isConfigsLoaded: function () {
  109. return (this.get('isAdvancedConfigLoaded') && this.get('isAppliedConfigLoaded'));
  110. }.property('isAdvancedConfigLoaded', 'isAppliedConfigLoaded'),
  111. /**
  112. * Should Next-button be disabled
  113. * @type {bool}
  114. */
  115. isSubmitDisabled: function () {
  116. if (!this.get('stepConfigs.length')) return true;
  117. if (this.get('submitButtonClicked')) return true;
  118. return (!this.get('stepConfigs').filterProperty('showConfig', true).everyProperty('errorCount', 0) || this.get("miscModalVisible"));
  119. }.property('stepConfigs.@each.errorCount', 'miscModalVisible', 'submitButtonClicked'),
  120. /**
  121. * List of selected to install service names
  122. * @type {string[]}
  123. */
  124. selectedServiceNames: function () {
  125. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).mapProperty('serviceName');
  126. }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
  127. /**
  128. * List of installed and selected to install service names
  129. * @type {string[]}
  130. */
  131. allSelectedServiceNames: function () {
  132. return this.get('content.services').filter(function (service) {
  133. return service.get('isInstalled') || service.get('isSelected');
  134. }).mapProperty('serviceName');
  135. }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
  136. /**
  137. * List of installed service names
  138. * @type {string[]}
  139. */
  140. installedServiceNames: function () {
  141. var serviceNames = this.get('content.services').filterProperty('isInstalled').mapProperty('serviceName');
  142. if (this.get('content.controllerName') !== 'installerController') {
  143. serviceNames = serviceNames.filter(function (_serviceName) {
  144. return !App.get('services.noConfigTypes').contains(_serviceName);
  145. });
  146. }
  147. return serviceNames;
  148. }.property('content.services').cacheable(),
  149. /**
  150. * List of master components
  151. * @type {Ember.Enumerable}
  152. */
  153. masterComponentHosts: function () {
  154. return this.get('content.masterComponentHosts');
  155. }.property('content.masterComponentHosts'),
  156. /**
  157. * List of slave components
  158. * @type {Ember.Enumerable}
  159. */
  160. slaveComponentHosts: function () {
  161. return this.get('content.slaveGroupProperties');
  162. }.property('content.slaveGroupProperties', 'content.slaveComponentHosts'),
  163. customData: [],
  164. /**
  165. * Filter text will be located here
  166. * @type {string}
  167. */
  168. filter: '',
  169. /**
  170. * List of filters for config properties to populate filter combobox
  171. */
  172. propertyFilters: [
  173. {
  174. attributeName: 'isOverridden',
  175. attributeValue: true,
  176. caption: 'common.combobox.dropdown.overridden'
  177. },
  178. {
  179. attributeName: 'isFinal',
  180. attributeValue: true,
  181. caption: 'common.combobox.dropdown.final'
  182. },
  183. {
  184. attributeName: 'isValid',
  185. attributeValue: false,
  186. caption: 'common.combobox.dropdown.issues'
  187. },
  188. {
  189. attributeName: 'warn',
  190. attributeValue: true,
  191. caption: 'common.combobox.dropdown.warnings'
  192. }
  193. ],
  194. /**
  195. * Dropdown menu items in filter combobox
  196. */
  197. filterColumns: function () {
  198. return this.get('propertyFilters').map(function (filter) {
  199. return Ember.Object.create({
  200. attributeName: filter.attributeName,
  201. attributeValue: filter.attributeValue,
  202. name: this.t(filter.caption),
  203. selected: false
  204. });
  205. }, this);
  206. }.property('propertyFilters'),
  207. /**
  208. * Clear controller's properties:
  209. * <ul>
  210. * <li>stepConfigs</li>
  211. * <li>filter</li>
  212. * </ul>
  213. * and desect all <code>filterColumns</code>
  214. * @method clearStep
  215. */
  216. clearStep: function () {
  217. this.set('configValidationGlobalMessage', []);
  218. this.set('submitButtonClicked', false);
  219. this.set('isSubmitDisabled', true);
  220. this.set('isRecommendedLoaded', false);
  221. this.get('stepConfigs').clear();
  222. this.set('filter', '');
  223. this.get('filterColumns').setEach('selected', false);
  224. },
  225. /**
  226. * Load config groups for installed services
  227. * One ajax-request for each service
  228. * @param {string[]} servicesNames
  229. * @method loadInstalledServicesConfigGroups
  230. */
  231. loadInstalledServicesConfigGroups: function (servicesNames) {
  232. servicesNames.forEach(function (serviceName) {
  233. App.ajax.send({
  234. name: 'config.tags_and_groups',
  235. sender: this,
  236. data: {
  237. serviceName: serviceName,
  238. serviceConfigsDef: App.config.get('preDefinedServiceConfigs').findProperty('serviceName', serviceName)
  239. },
  240. success: 'loadServiceTagsSuccess'
  241. });
  242. }, this);
  243. },
  244. /**
  245. * Create site to tag map. Format:
  246. * <code>
  247. * {
  248. * site1: tag1,
  249. * site1: tag2,
  250. * site2: tag3
  251. * ...
  252. * }
  253. * </code>
  254. * @param {object} desired_configs
  255. * @param {string[]} sites
  256. * @returns {object}
  257. * @private
  258. * @method _createSiteToTagMap
  259. */
  260. _createSiteToTagMap: function (desired_configs, sites) {
  261. var siteToTagMap = {};
  262. for (var site in desired_configs) {
  263. if (desired_configs.hasOwnProperty(site)) {
  264. if (!!sites[site]) {
  265. siteToTagMap[site] = desired_configs[site].tag;
  266. }
  267. }
  268. }
  269. return siteToTagMap;
  270. },
  271. /**
  272. * Load config groups success callback
  273. * @param {object} data
  274. * @param {object} opt
  275. * @param {object} params
  276. * @method loadServiceTagsSuccess
  277. */
  278. loadServiceTagsSuccess: function (data, opt, params) {
  279. var serviceName = params.serviceName,
  280. service = this.get('stepConfigs').findProperty('serviceName', serviceName),
  281. defaultConfigGroupHosts = this.get('wizardController.allHosts').mapProperty('hostName'),
  282. siteToTagMap = this._createSiteToTagMap(data.Clusters.desired_configs, params.serviceConfigsDef.get('configTypes')),
  283. selectedConfigGroup,
  284. manageCGController = App.router.get('manageConfigGroupsController');
  285. this.set('loadedClusterSiteToTagMap', siteToTagMap);
  286. //parse loaded config groups
  287. var configGroups = [];
  288. if (data.config_groups.length) {
  289. data.config_groups.forEach(function (item) {
  290. item = item.ConfigGroup;
  291. if (item.tag === serviceName) {
  292. var groupHosts = item.hosts.mapProperty('host_name');
  293. var newConfigGroup = App.ConfigGroup.create({
  294. id: item.id,
  295. name: item.group_name,
  296. description: item.description,
  297. isDefault: false,
  298. parentConfigGroup: null,
  299. service: App.Service.find().findProperty('serviceName', item.tag),
  300. hosts: groupHosts,
  301. publicHosts: manageCGController.hostsToPublic(groupHosts),
  302. configSiteTags: []
  303. });
  304. groupHosts.forEach(function (host) {
  305. defaultConfigGroupHosts = defaultConfigGroupHosts.without(host);
  306. }, this);
  307. item.desired_configs.forEach(function (config) {
  308. newConfigGroup.configSiteTags.push(App.ConfigSiteTag.create({
  309. site: config.type,
  310. tag: config.tag
  311. }));
  312. }, this);
  313. configGroups.push(newConfigGroup);
  314. }
  315. }, this);
  316. }
  317. var defaultConfigGroup = App.ConfigGroup.create({
  318. name: App.format.role(serviceName) + " Default",
  319. description: "Default cluster level " + serviceName + " configuration",
  320. isDefault: true,
  321. hosts: defaultConfigGroupHosts,
  322. publicHosts: manageCGController.hostsToPublic(defaultConfigGroupHosts),
  323. parentConfigGroup: null,
  324. service: Em.Object.create({
  325. id: serviceName
  326. }),
  327. serviceName: serviceName,
  328. configSiteTags: []
  329. });
  330. if (!selectedConfigGroup) {
  331. selectedConfigGroup = defaultConfigGroup;
  332. }
  333. configGroups = configGroups.sortProperty('name');
  334. configGroups.unshift(defaultConfigGroup);
  335. service.set('configGroups', configGroups);
  336. var loadedGroupToOverrideSiteToTagMap = {};
  337. var configGroupsWithOverrides = selectedConfigGroup.get('isDefault') ? service.get('configGroups') : [selectedConfigGroup];
  338. configGroupsWithOverrides.forEach(function (item) {
  339. var groupName = item.get('name');
  340. loadedGroupToOverrideSiteToTagMap[groupName] = {};
  341. item.get('configSiteTags').forEach(function (siteTag) {
  342. var site = siteTag.get('site');
  343. loadedGroupToOverrideSiteToTagMap[groupName][site] = siteTag.get('tag');
  344. }, this);
  345. }, this);
  346. this.set('preSelectedConfigGroup', selectedConfigGroup);
  347. App.config.loadServiceConfigGroupOverrides(service.get('configs'), loadedGroupToOverrideSiteToTagMap, service.get('configGroups'), this.onLoadOverrides, this);
  348. },
  349. onLoadOverrides: function (configs) {
  350. var serviceName = configs[0].serviceName,
  351. service = this.get('stepConfigs').findProperty('serviceName', serviceName);
  352. var serviceConfig = App.config.createServiceConfig(serviceName);
  353. if (serviceConfig.get('serviceName') === 'HDFS') {
  354. App.config.OnNnHAHideSnn(serviceConfig);
  355. }
  356. service.set('selectedConfigGroup', this.get('preSelectedConfigGroup'));
  357. this.loadComponentConfigs(service.get('configs'), serviceConfig, service);
  358. service.set('configs', serviceConfig.get('configs'));
  359. },
  360. /**
  361. * By default <code>value</code>-property is string "true|false".
  362. * Should update it to boolean type
  363. * Also affects <code>defaultValue</code>
  364. * @param {Ember.Object} serviceConfigProperty
  365. * @returns {Ember.Object} Updated config-object
  366. * @method _updateValueForCheckBoxConfig
  367. */
  368. _updateValueForCheckBoxConfig: function (serviceConfigProperty) {
  369. var v = serviceConfigProperty.get('value');
  370. switch (serviceConfigProperty.get('value')) {
  371. case 'true':
  372. v = true;
  373. break;
  374. case 'false':
  375. v = false;
  376. break;
  377. }
  378. serviceConfigProperty.setProperties({value: v, defaultValue: v});
  379. return serviceConfigProperty;
  380. },
  381. /**
  382. * Set <code>isEditable</code>-property to <code>serviceConfigProperty</code>
  383. * Based on user's permissions and selected config group
  384. * @param {Ember.Object} serviceConfigProperty
  385. * @param {bool} defaultGroupSelected
  386. * @returns {Ember.Object} Updated config-object
  387. * @method _updateIsEditableFlagForConfig
  388. */
  389. _updateIsEditableFlagForConfig: function (serviceConfigProperty, defaultGroupSelected) {
  390. if (App.isAccessible('ADMIN')) {
  391. if (defaultGroupSelected && !this.get('isHostsConfigsPage') && !Em.get(serviceConfigProperty, 'group')) {
  392. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  393. } else if (Em.get(serviceConfigProperty, 'group') && Em.get(serviceConfigProperty, 'group.name') == this.get('selectedConfigGroup.name')) {
  394. serviceConfigProperty.set('isEditable', true);
  395. } else {
  396. serviceConfigProperty.set('isEditable', false);
  397. }
  398. }
  399. else {
  400. serviceConfigProperty.set('isEditable', false);
  401. }
  402. return serviceConfigProperty;
  403. },
  404. /**
  405. * Set <code>overrides</code>-property to <code>serviceConfigProperty<code>
  406. * @param {Ember.Object} serviceConfigProperty
  407. * @param {Ember.Object} component
  408. * @return {Ember.Object} Updated config-object
  409. * @method _updateOverridesForConfig
  410. */
  411. _updateOverridesForConfig: function (serviceConfigProperty, component) {
  412. var overrides = serviceConfigProperty.get('overrides');
  413. if (Em.isNone(overrides)) {
  414. serviceConfigProperty.set('overrides', Em.A([]));
  415. return serviceConfigProperty;
  416. }
  417. serviceConfigProperty.set('overrides', null);
  418. var defaultGroupSelected = component.get('selectedConfigGroup.isDefault');
  419. // Wrap each override to App.ServiceConfigProperty
  420. overrides.forEach(function (override) {
  421. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  422. newSCP.set('value', override.value);
  423. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  424. newSCP.set('parentSCP', serviceConfigProperty);
  425. if (defaultGroupSelected) {
  426. var group = component.get('configGroups').findProperty('name', override.group.get('name'));
  427. // prevent cycle in proto object, clean link
  428. if (group.get('properties').length == 0) {
  429. group.set('properties', Em.A([]));
  430. }
  431. group.get('properties').push(newSCP);
  432. newSCP.set('group', override.group);
  433. newSCP.set('isEditable', false);
  434. }
  435. var parentOverridesArray = serviceConfigProperty.get('overrides');
  436. if (Em.isNone(parentOverridesArray)) {
  437. parentOverridesArray = Em.A([]);
  438. serviceConfigProperty.set('overrides', parentOverridesArray);
  439. }
  440. serviceConfigProperty.get('overrides').pushObject(newSCP);
  441. }, this);
  442. return serviceConfigProperty;
  443. },
  444. /**
  445. * Set configs with overrides, recommended defaults to component
  446. * @param {Ember.Object[]} configs
  447. * @param {Ember.Object} componentConfig
  448. * @param {Ember.Object} component
  449. * @method loadComponentConfigs
  450. */
  451. loadComponentConfigs: function (configs, componentConfig, component) {
  452. var defaultGroupSelected = component.get('selectedConfigGroup.isDefault');
  453. configs.forEach(function (serviceConfigProperty) {
  454. if (!serviceConfigProperty) return;
  455. if (Em.isNone(serviceConfigProperty.get('isOverridable'))) {
  456. serviceConfigProperty.set('isOverridable', true);
  457. }
  458. if (serviceConfigProperty.get('displayType') === 'checkbox') {
  459. this._updateValueForCheckBoxConfig(serviceConfigProperty);
  460. }
  461. this._updateOverridesForConfig(serviceConfigProperty, component);
  462. this._updateIsEditableFlagForConfig(serviceConfigProperty, defaultGroupSelected);
  463. componentConfig.get('configs').pushObject(serviceConfigProperty);
  464. serviceConfigProperty.validate();
  465. }, this);
  466. component.get('configGroups').filterProperty('isDefault', false).forEach(function (configGroup) {
  467. configGroup.set('hash', this.get('wizardController').getConfigGroupHash(configGroup));
  468. }, this);
  469. var overrideToAdd = this.get('overrideToAdd');
  470. if (overrideToAdd) {
  471. overrideToAdd = componentConfig.get('configs').findProperty('name', overrideToAdd.name);
  472. if (overrideToAdd) {
  473. this.addOverrideProperty(overrideToAdd);
  474. component.set('overrideToAdd', null);
  475. }
  476. }
  477. },
  478. /**
  479. * Resolve dependency between configs.
  480. * @param serviceName {String}
  481. * @param configs {Ember.Enumerable}
  482. */
  483. resolveServiceDependencyConfigs: function (serviceName, configs) {
  484. switch (serviceName) {
  485. case 'STORM':
  486. this.resolveStormConfigs(configs);
  487. break;
  488. case 'YARN':
  489. this.resolveYarnConfigs(configs);
  490. default:
  491. break;
  492. }
  493. },
  494. /**
  495. * Update some Storm configs
  496. * If Ganglia is selected to install or already installed, Ganglia host should be added to configs
  497. * @param {Ember.Enumerable} configs
  498. * @method resolveStormConfigs
  499. */
  500. resolveStormConfigs: function (configs) {
  501. var dependentConfigs, gangliaServerHost, gangliaHostId, hosts;
  502. dependentConfigs = ['nimbus.childopts', 'supervisor.childopts', 'worker.childopts'];
  503. // if Ganglia selected or installed, set ganglia host to configs
  504. if (this.get('installedServiceNames').contains('STORM') && this.get('installedServiceNames').contains('GANGLIA')) return;
  505. if (this.get('allSelectedServiceNames').contains('GANGLIA') || this.get('installedServiceNames').contains('GANGLIA')) {
  506. if (this.get('wizardController.name') === 'addServiceController') {
  507. gangliaServerHost = this.get('wizardController').getDBProperty('masterComponentHosts').findProperty('component', 'GANGLIA_SERVER').hostName;
  508. } else {
  509. hosts = this.get('wizardController').getDBProperty('hosts');
  510. gangliaHostId = this.get('wizardController').getDBProperty('masterComponentHosts').findProperty('component', 'GANGLIA_SERVER').host_id;
  511. for (var hostName in hosts) {
  512. if (hosts[hostName].id == gangliaHostId) gangliaServerHost = hosts[hostName].name;
  513. }
  514. }
  515. dependentConfigs.forEach(function (configName) {
  516. var config = configs.findProperty('name', configName);
  517. if (!Em.isNone(config.value)) {
  518. var replaceStr = config.value.match(/.jar=host[^,]+/)[0];
  519. var replaceWith = replaceStr.slice(0, replaceStr.lastIndexOf('=') - replaceStr.length + 1) + gangliaServerHost;
  520. config.value = config.defaultValue = config.value.replace(replaceStr, replaceWith);
  521. }
  522. config.forceUpdate = true;
  523. }, this);
  524. }
  525. },
  526. /**
  527. * Update some Storm configs
  528. * If SLIDER is selected to install or already installed,
  529. * some Yarn properties must be changed
  530. * @param {Ember.Enumerable} configs
  531. * @method resolveYarnConfigs
  532. */
  533. resolveYarnConfigs: function (configs) {
  534. var cfgToChange = configs.findProperty('name', 'hadoop.registry.rm.enabled');
  535. if (cfgToChange) {
  536. var res = this.get('allSelectedServiceNames').contains('SLIDER');
  537. if (Em.get(cfgToChange, 'value') !== res) {
  538. Em.set(cfgToChange, 'defaultValue', res);
  539. Em.set(cfgToChange, 'value', res);
  540. Em.set(cfgToChange, 'forceUpdate', true);
  541. }
  542. }
  543. },
  544. /**
  545. * On load function
  546. * @method loadStep
  547. */
  548. loadStep: function () {
  549. console.log("TRACE: Loading step7: Configure Services");
  550. if (!this.get('isConfigsLoaded')) {
  551. return;
  552. }
  553. this.clearStep();
  554. var self = this;
  555. //STEP 1: Load advanced configs
  556. var advancedConfigs = this.get('content.advancedServiceConfig');
  557. //STEP 2: Load on-site configs by service from local DB
  558. var storedConfigs = this.get('content.serviceConfigProperties');
  559. //STEP 3: Merge pre-defined configs with loaded on-site configs
  560. var configs = App.config.mergePreDefinedWithStored(
  561. storedConfigs,
  562. advancedConfigs,
  563. this.get('selectedServiceNames').concat(this.get('installedServiceNames'))
  564. );
  565. App.config.setPreDefinedServiceConfigs(this.get('addMiscTabToPage'));
  566. //STEP 4: Add advanced configs
  567. App.config.addAdvancedConfigs(configs, advancedConfigs);
  568. //STEP 5: Add custom configs
  569. App.config.addCustomConfigs(configs);
  570. this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
  571. if (this.get('wizardController.name') === 'addServiceController') {
  572. App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags')).done(function (loadedConfigs) {
  573. self.setInstalledServiceConfigs(self.get('serviceConfigTags'), configs, loadedConfigs, self.get('installedServiceNames'));
  574. self.applyServicesConfigs(configs, storedConfigs);
  575. });
  576. } else {
  577. this.applyServicesConfigs(configs, storedConfigs);
  578. }
  579. },
  580. applyServicesConfigs: function (configs, storedConfigs) {
  581. if (this.get('allSelectedServiceNames').contains('YARN')) {
  582. configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml');
  583. }
  584. var dependendServices = ["STORM", "YARN"];
  585. dependendServices.forEach(function (serviceName) {
  586. if (this.get('allSelectedServiceNames').contains(serviceName)) {
  587. this.resolveServiceDependencyConfigs(serviceName, configs);
  588. }
  589. }, this);
  590. //STEP 6: Distribute configs by service and wrap each one in App.ServiceConfigProperty (configs -> serviceConfigs)
  591. var self = this;
  592. this.loadServerSideConfigsRecommendations().always(function () {
  593. self.set('isRecommendedLoaded', true);
  594. self.setStepConfigs(configs, storedConfigs);
  595. self.checkHostOverrideInstaller();
  596. self.activateSpecialConfigs();
  597. self.selectProperService();
  598. if (self.get('content.skipConfigStep')) {
  599. App.router.send('next');
  600. }
  601. });
  602. },
  603. /**
  604. * Load config groups
  605. * and (if some services are already installed) load config groups for installed services
  606. * @method checkHostOverrideInstaller
  607. */
  608. checkHostOverrideInstaller: function () {
  609. if (this.get('wizardController.name') !== 'kerberosWizardController') {
  610. this.loadConfigGroups(this.get('content.configGroups'));
  611. }
  612. if (this.get('installedServiceNames').length > 0) {
  613. this.loadInstalledServicesConfigGroups(this.get('installedServiceNames'));
  614. }
  615. },
  616. /**
  617. * Set init <code>stepConfigs</code> value
  618. * Set <code>selected</code> for addable services if addServiceController is used
  619. * Remove SNameNode if HA is enabled (and if addServiceController is used)
  620. * @param {Ember.Object[]} configs
  621. * @param {Ember.Object[]} storedConfigs
  622. * @method setStepConfigs
  623. */
  624. setStepConfigs: function (configs, storedConfigs) {
  625. var localDB = {
  626. hosts: this.get('wizardController.content.hosts'),
  627. masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
  628. slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts')
  629. };
  630. var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allSelectedServiceNames'), this.get('installedServiceNames'), localDB, this.get('recommendationsConfigs'));
  631. if (this.get('wizardController.name') === 'addServiceController') {
  632. serviceConfigs.setEach('showConfig', true);
  633. serviceConfigs.setEach('selected', false);
  634. this.get('selectedServiceNames').forEach(function (serviceName) {
  635. if (!serviceConfigs.findProperty('serviceName', serviceName)) return;
  636. var selectedService = serviceConfigs.findProperty('serviceName', serviceName).set('selected', true);
  637. // add secure configs when security is enabled
  638. if (this.get('securityEnabled')) {
  639. this.addSecureConfigs(selectedService, serviceName);
  640. }
  641. }, this);
  642. this.get('installedServiceNames').forEach(function (serviceName) {
  643. var serviceConfigObj = serviceConfigs.findProperty('serviceName', serviceName);
  644. var isInstallableService = App.StackService.find(serviceName).get('isInstallable');
  645. if (!isInstallableService) serviceConfigObj.set('showConfig', false);
  646. if (this.get('securityEnabled')) {
  647. this.setSecureConfigs(serviceConfigObj, serviceName);
  648. }
  649. }, this);
  650. // Remove SNameNode if HA is enabled
  651. if (App.get('isHaEnabled')) {
  652. var c = serviceConfigs.findProperty('serviceName', 'HDFS').configs;
  653. var removedConfigs = c.filterProperty('category', 'SECONDARY_NAMENODE');
  654. removedConfigs.map(function (config) {
  655. c = c.without(config);
  656. });
  657. serviceConfigs.findProperty('serviceName', 'HDFS').configs = c;
  658. }
  659. }
  660. // Remove Notifications from MISC if it isn't Installer Controller
  661. if (this.get('wizardController.name') !== 'installerController') {
  662. var miscService = serviceConfigs.findProperty('serviceName', 'MISC');
  663. if (miscService) {
  664. c = miscService.configs;
  665. removedConfigs = c.filterProperty('category', 'Notifications');
  666. removedConfigs.map(function (config) {
  667. c = c.without(config);
  668. });
  669. miscService.configs = c;
  670. }
  671. }
  672. if (!App.get('isHadoopWindowsStack')) {
  673. var hdfsService = serviceConfigs.findProperty('serviceName', 'HDFS');
  674. if (hdfsService) {
  675. c = hdfsService.configs;
  676. c.filterProperty('category', 'MetricsSink').map(function (config) {
  677. c = c.without(config);
  678. });
  679. serviceConfigs.findProperty('serviceName', 'HDFS').configs = c;
  680. }
  681. }
  682. this.set('stepConfigs', serviceConfigs);
  683. },
  684. /**
  685. * Set secure properties for installed services. Mark secure properties and
  686. * properties with default empty value as non required to pass validation.
  687. *
  688. * @param {Em.Object} serviceConfigObj
  689. * @param {String} serviceName
  690. */
  691. setSecureConfigs: function (serviceConfigObj, serviceName) {
  692. var configProperties = serviceConfigObj.get('configs');
  693. if (!configProperties) return;
  694. var secureConfigs = this.get('secureConfigs').filterProperty('serviceName', serviceName);
  695. secureConfigs.forEach(function (secureConfig) {
  696. var property = configProperties.findProperty('name', secureConfig.name);
  697. if (property) {
  698. property.set('isRequired', secureConfig.value != "");
  699. if (!property.get('isRequired')) property.set('errorMessage', '');
  700. }
  701. });
  702. },
  703. /**
  704. *
  705. * @param selectedService
  706. * @param serviceName
  707. */
  708. addSecureConfigs: function (selectedService, serviceName) {
  709. var secureService = this.get('secureServices').findProperty('serviceName', serviceName);
  710. if (!secureService) {
  711. return;
  712. }
  713. secureService.configCategories.forEach(function (category) {
  714. selectedService.get('configCategories').push(category);
  715. });
  716. secureService.configs.forEach(function (conf) {
  717. conf.isVisible = !conf.displayType.contains('masterHost') && !conf.displayType.contains('slaveHost');
  718. var config = App.ServiceConfigProperty.create(conf);
  719. selectedService.get('configs').push(config);
  720. }, this);
  721. },
  722. /**
  723. * Select first addable service for <code>addServiceWizard</code>
  724. * Select first service at all in other cases
  725. * @method selectProperService
  726. */
  727. selectProperService: function () {
  728. if (this.get('wizardController.name') === 'addServiceController') {
  729. this.set('selectedService', this.get('stepConfigs').filterProperty('selected', true).get('firstObject'));
  730. } else {
  731. this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
  732. }
  733. },
  734. /**
  735. * Load config tags
  736. * @return {$.ajax|null}
  737. * @method getConfigTags
  738. */
  739. getConfigTags: function () {
  740. this.set('isAppliedConfigLoaded', false);
  741. return App.ajax.send({
  742. name: 'config.tags',
  743. sender: this,
  744. success: 'getConfigTagsSuccess'
  745. });
  746. },
  747. /**
  748. * Success callback for config tags request
  749. * Updates <code>serviceConfigTags</code> with tags received from server
  750. * @param {object} data
  751. * @method getConfigTagsSuccess
  752. */
  753. getConfigTagsSuccess: function (data) {
  754. var installedServiceSites = [];
  755. App.StackService.find().filterProperty('isInstalled').forEach(function (service) {
  756. if (!service.get('configTypes')) return;
  757. var configTypes = Object.keys(service.get('configTypes'));
  758. installedServiceSites = installedServiceSites.concat(configTypes);
  759. }, this);
  760. installedServiceSites = installedServiceSites.uniq();
  761. var serviceConfigTags = [];
  762. for (var site in data.Clusters.desired_configs) {
  763. if (data.Clusters.desired_configs.hasOwnProperty(site)) {
  764. if (installedServiceSites.contains(site)) {
  765. serviceConfigTags.push({
  766. siteName: site,
  767. tagName: data.Clusters.desired_configs[site].tag,
  768. newTagName: null
  769. });
  770. }
  771. }
  772. }
  773. this.set('serviceConfigTags', serviceConfigTags);
  774. this.set('isAppliedConfigLoaded', true);
  775. },
  776. /**
  777. * set configs actual values from server
  778. * @param serviceConfigTags
  779. * @param configs
  780. * @param configsByTags
  781. * @param installedServiceNames
  782. * @method setInstalledServiceConfigs
  783. */
  784. setInstalledServiceConfigs: function (serviceConfigTags, configs, configsByTags, installedServiceNames) {
  785. var configsMap = {};
  786. var configTypeMap = {};
  787. var configMixin = App.get('config');
  788. var self = this;
  789. configsByTags.forEach(function (configSite) {
  790. configsMap[configSite.type] = configSite.properties;
  791. });
  792. configs.forEach(function (_config) {
  793. var nonServiceTab = require('data/service_configs');
  794. var type = _config.filename ? App.config.getConfigTagFromFileName(_config.filename) : null;
  795. var mappedConfigValue = type && configsMap[type] ? configsMap[type][_config.name] : null;
  796. if (!Em.isNone(mappedConfigValue) && ((installedServiceNames && installedServiceNames.contains(_config.serviceName) || nonServiceTab.someProperty('serviceName', _config.serviceName)))) {
  797. // prevent overriding already edited properties
  798. if (_config.defaultValue != mappedConfigValue) {
  799. _config.value = mappedConfigValue;
  800. }
  801. _config.defaultValue = mappedConfigValue;
  802. _config.hasInitialValue = true;
  803. App.config.handleSpecialProperties(_config);
  804. delete configsMap[type][_config.name];
  805. }
  806. });
  807. self.setServiceDatabaseConfigs(configs);
  808. //add user properties
  809. Em.keys(configsMap).forEach(function (filename) {
  810. Em.keys(configsMap[filename]).forEach(function (propertyName) {
  811. configs.push(configMixin.addUserProperty({
  812. id: 'site property',
  813. name: propertyName,
  814. serviceName: configMixin.getServiceNameByConfigType(filename),
  815. value: configsMap[filename][propertyName],
  816. defaultValue: configsMap[filename][propertyName],
  817. filename: configMixin.get('filenameExceptions').contains(filename) ? filename : filename + '.xml',
  818. category: 'Advanced',
  819. hasInitialValue: true,
  820. isUserProperty: true,
  821. isOverridable: true,
  822. overrides: [],
  823. isRequired: true,
  824. isVisible: true,
  825. showLabel: true
  826. }, false, []));
  827. });
  828. });
  829. },
  830. /**
  831. * Check if Oozie, Hive or MetricsSink use existing database then need
  832. * to restore missed properties
  833. *
  834. * @param {Object[]} configs
  835. **/
  836. setServiceDatabaseConfigs: function (configs) {
  837. var serviceNames = this.get('installedServiceNames').filter(function (serviceName) {
  838. return ['OOZIE', 'HIVE', 'HDFS'].contains(serviceName);
  839. });
  840. serviceNames.forEach(function (serviceName) {
  841. var propertyPrefix = serviceName.toLowerCase();
  842. if (/HDFS/gi.test(serviceName)) propertyPrefix = 'sink';
  843. var dbTypeConfig = configs.findProperty('name', propertyPrefix + '_database');
  844. if (!/existing/gi.test(dbTypeConfig.value)) return;
  845. var dbHostName = propertyPrefix + '_hostname';
  846. var database = dbTypeConfig.value.match(/MySQL|PostgreSQL|Oracle|Derby|MSSQL/gi)[0];
  847. var dbPrefix = database.toLowerCase();
  848. if (database.toLowerCase() == 'mssql') {
  849. dbHostName = 'sink.dbservername';
  850. if (/integrated/gi.test(dbTypeConfig.value)) {
  851. dbPrefix = 'mssql_server';
  852. } else {
  853. dbPrefix = 'mssql_server_2';
  854. }
  855. }
  856. var propertyName = propertyPrefix + '_existing_' + dbPrefix + '_host';
  857. var existingDBConfig = configs.findProperty('name', propertyName);
  858. if (!existingDBConfig.value)
  859. existingDBConfig.value = existingDBConfig.defaultValue = configs.findProperty('name', dbHostName).value;
  860. }, this);
  861. },
  862. /**
  863. * Add group ids to <code>groupsToDelete</code>
  864. * Also save <code>groupsToDelete</code> to local storage
  865. * @param {Ember.Object[]} groups
  866. * @method setGroupsToDelete
  867. */
  868. setGroupsToDelete: function (groups) {
  869. var groupsToDelete = this.get('groupsToDelete');
  870. groups.forEach(function (group) {
  871. if (group.get('id'))
  872. groupsToDelete.push({
  873. id: group.get('id')
  874. });
  875. });
  876. this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
  877. },
  878. /**
  879. * Update <code>configGroups</code> with selected service configGroups
  880. * Also set default group to first position
  881. * Update <code>selectedConfigGroup</code> with new default group
  882. * @method selectedServiceObserver
  883. */
  884. selectedServiceObserver: function () {
  885. if (this.get('selectedService') && (this.get('selectedService.serviceName') !== 'MISC')) {
  886. var serviceGroups = this.get('selectedService.configGroups');
  887. serviceGroups.forEach(function (item, index, array) {
  888. if (item.isDefault) {
  889. array.unshift(item);
  890. array.splice(index + 1, 1);
  891. }
  892. });
  893. this.set('configGroups', serviceGroups);
  894. this.set('selectedConfigGroup', serviceGroups.findProperty('isDefault'));
  895. }
  896. }.observes('selectedService.configGroups.@each'),
  897. /**
  898. * load default groups for each service in case of initial load
  899. * @param serviceConfigGroups
  900. * @method loadConfigGroups
  901. */
  902. loadConfigGroups: function (serviceConfigGroups) {
  903. var services = this.get('stepConfigs');
  904. var hosts = this.get('wizardController.allHosts').mapProperty('hostName');
  905. var manageCGController = App.router.get('manageConfigGroupsController');
  906. this.setupManageConfigGroupsController();
  907. services.forEach(function (service) {
  908. if (service.get('serviceName') === 'MISC') return;
  909. var serviceRawGroups = serviceConfigGroups.filterProperty('service.id', service.serviceName);
  910. if (!serviceRawGroups.length) {
  911. service.set('configGroups', [
  912. App.ConfigGroup.create({
  913. name: service.displayName + " Default",
  914. description: "Default cluster level " + service.serviceName + " configuration",
  915. isDefault: true,
  916. hosts: Em.copy(hosts),
  917. publicHosts: Em.copy(manageCGController.hostsToPublic(hosts)),
  918. service: Em.Object.create({
  919. id: service.serviceName
  920. }),
  921. serviceName: service.serviceName
  922. })
  923. ]);
  924. }
  925. else {
  926. var defaultGroup = App.ConfigGroup.create(serviceRawGroups.findProperty('isDefault'));
  927. var serviceGroups = service.get('configGroups');
  928. serviceRawGroups.filterProperty('isDefault', false).forEach(function (configGroup) {
  929. var readyGroup = App.ConfigGroup.create(configGroup);
  930. var wrappedProperties = [];
  931. readyGroup.get('properties').forEach(function (propertyData) {
  932. var parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name', propertyData.name);
  933. var overriddenSCP = App.ServiceConfigProperty.create(parentSCP);
  934. overriddenSCP.set('isOriginalSCP', false);
  935. overriddenSCP.set('parentSCP', parentSCP);
  936. overriddenSCP.set('group', readyGroup);
  937. overriddenSCP.setProperties(propertyData);
  938. wrappedProperties.pushObject(App.ServiceConfigProperty.create(overriddenSCP));
  939. });
  940. wrappedProperties.setEach('group', readyGroup);
  941. readyGroup.set('properties', wrappedProperties);
  942. readyGroup.set('parentConfigGroup', defaultGroup);
  943. serviceGroups.pushObject(readyGroup);
  944. });
  945. defaultGroup.set('childConfigGroups', serviceGroups);
  946. serviceGroups.pushObject(defaultGroup);
  947. }
  948. });
  949. },
  950. setupManageConfigGroupsController: function () {
  951. var manageCGController = App.router.get('manageConfigGroupsController');
  952. manageCGController.set('isInstaller', true);
  953. manageCGController.set('isAddService', this.get('wizardController.name') === 'addServiceController');
  954. },
  955. /**
  956. * Click-handler on config-group to make it selected
  957. * @param {object} event
  958. * @method selectConfigGroup
  959. */
  960. selectConfigGroup: function (event) {
  961. this.set('selectedConfigGroup', event.context);
  962. },
  963. /**
  964. * Rebuild list of configs switch of config group:
  965. * on default - display all configs from default group and configs from non-default groups as disabled
  966. * on non-default - display all from default group as disabled and configs from selected non-default group
  967. * @method switchConfigGroupConfigs
  968. */
  969. switchConfigGroupConfigs: function () {
  970. var serviceConfigs = this.get('selectedService.configs'),
  971. selectedGroup = this.get('selectedConfigGroup'),
  972. overrideToAdd = this.get('overrideToAdd'),
  973. overrides = [];
  974. if (!selectedGroup) return;
  975. var displayedConfigGroups = this._getDisplayedConfigGroups();
  976. displayedConfigGroups.forEach(function (group) {
  977. overrides.pushObjects(group.get('properties'));
  978. });
  979. serviceConfigs.forEach(function (config) {
  980. this._setEditableValue(config);
  981. this._setOverrides(config, overrides);
  982. }, this);
  983. }.observes('selectedConfigGroup'),
  984. /**
  985. * Get list of config groups to display
  986. * Returns empty array if no <code>selectedConfigGroup</code>
  987. * @return {Array}
  988. * @method _getDisplayedConfigGroups
  989. */
  990. _getDisplayedConfigGroups: function () {
  991. var selectedGroup = this.get('selectedConfigGroup');
  992. if (!selectedGroup) return [];
  993. return (selectedGroup.get('isDefault')) ?
  994. this.get('selectedService.configGroups').filterProperty('isDefault', false) :
  995. [this.get('selectedConfigGroup')];
  996. },
  997. /**
  998. * Set <code>isEditable</code> property to <code>config</code>
  999. * @param {Ember.Object} config
  1000. * @return {Ember.Object} updated config-object
  1001. * @method _setEditableValue
  1002. */
  1003. _setEditableValue: function (config) {
  1004. var selectedGroup = this.get('selectedConfigGroup');
  1005. if (!selectedGroup) return config;
  1006. var isEditable = config.get('isEditable'),
  1007. isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName'));
  1008. if (isServiceInstalled) {
  1009. isEditable = (!isEditable && !config.get('isReconfigurable')) ? false : selectedGroup.get('isDefault');
  1010. }
  1011. else {
  1012. isEditable = selectedGroup.get('isDefault');
  1013. }
  1014. if (config.get('group')) {
  1015. isEditable = config.get('group.name') == this.get('selectedConfigGroup.name');
  1016. }
  1017. config.set('isEditable', isEditable);
  1018. return config;
  1019. },
  1020. /**
  1021. * Set <code>overrides</code> property to <code>config</code>
  1022. * @param {Ember.Object} config
  1023. * @param {Ember.Enumerable} overrides
  1024. * @returns {Ember.Object}
  1025. * @method _setOverrides
  1026. */
  1027. _setOverrides: function (config, overrides) {
  1028. var selectedGroup = this.get('selectedConfigGroup'),
  1029. overrideToAdd = this.get('overrideToAdd'),
  1030. configOverrides = overrides.filterProperty('name', config.get('name'));
  1031. if (!selectedGroup) return config;
  1032. if (overrideToAdd && overrideToAdd.get('name') === config.get('name')) {
  1033. configOverrides.push(this.addOverrideProperty(config));
  1034. this.set('overrideToAdd', null);
  1035. }
  1036. configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
  1037. configOverrides.setEach('parentSCP', config);
  1038. config.set('overrides', configOverrides);
  1039. return config;
  1040. },
  1041. /**
  1042. * create overriden property and push it into Config group
  1043. * @param {App.ServiceConfigProperty} serviceConfigProperty
  1044. * @return {App.ServiceConfigProperty}
  1045. * @method addOverrideProperty
  1046. */
  1047. addOverrideProperty: function (serviceConfigProperty) {
  1048. var overrides = serviceConfigProperty.get('overrides') || [];
  1049. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  1050. var group = this.get('selectedService.configGroups').findProperty('name', this.get('selectedConfigGroup.name'));
  1051. newSCP.set('group', group);
  1052. newSCP.set('value', '');
  1053. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  1054. newSCP.set('parentSCP', serviceConfigProperty);
  1055. newSCP.set('isEditable', true);
  1056. group.get('properties').pushObject(newSCP);
  1057. overrides.pushObject(newSCP);
  1058. return newSCP;
  1059. },
  1060. /**
  1061. * @method manageConfigurationGroup
  1062. */
  1063. manageConfigurationGroup: function () {
  1064. App.router.get('mainServiceInfoConfigsController').manageConfigurationGroups(this);
  1065. },
  1066. /**
  1067. * Make some configs visible depending on active services
  1068. * @method activateSpecialConfigs
  1069. */
  1070. activateSpecialConfigs: function () {
  1071. if (this.get('addMiscTabToPage')) {
  1072. var miscConfigs = this.get('stepConfigs').findProperty('serviceName', 'MISC').configs;
  1073. if (this.get('wizardController.name') == "addServiceController") {
  1074. miscConfigs.findProperty('name', 'smokeuser').set('value', this.get('content.smokeuser')).set('isEditable', false);
  1075. miscConfigs.findProperty('name', 'user_group').set('value', this.get('content.group')).set('isEditable', false);
  1076. }
  1077. App.config.miscConfigVisibleProperty(miscConfigs, this.get('selectedServiceNames'));
  1078. }
  1079. var wizardController = this.get('wizardController');
  1080. if (wizardController.get('name') === "kerberosWizardController") {
  1081. var kerberosConfigs = this.get('stepConfigs').findProperty('serviceName', 'KERBEROS').configs;
  1082. kerberosConfigs.findProperty('name', 'kdc_type').set('value', wizardController.get('content.kerberosOption'));
  1083. }
  1084. },
  1085. /**
  1086. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1087. * @return {$.ajax|null}
  1088. * @method checkMySQLHost
  1089. */
  1090. checkMySQLHost: function () {
  1091. // get ambari database type and hostname
  1092. return App.ajax.send({
  1093. name: 'config.ambari.database.info',
  1094. sender: this,
  1095. success: 'getAmbariDatabaseSuccess'
  1096. });
  1097. },
  1098. /**
  1099. * Success callback for ambari database, get Ambari DB type and DB server hostname, then
  1100. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1101. * @param {object} data
  1102. * @method getAmbariDatabaseSuccess
  1103. */
  1104. getAmbariDatabaseSuccess: function (data) {
  1105. var hiveDBHostname = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_ambari_host').value;
  1106. var ambariServiceHostComponents = data.hostComponents;
  1107. if (!!ambariServiceHostComponents.length) {
  1108. var ambariDBInfo = JSON.stringify(ambariServiceHostComponents[0].RootServiceHostComponents.properties);
  1109. this.set('mySQLServerConflict', ambariDBInfo.indexOf('mysql') > 0 && ambariDBInfo.indexOf(hiveDBHostname) > 0);
  1110. } else {
  1111. this.set('mySQLServerConflict', false);
  1112. }
  1113. },
  1114. /**
  1115. * Check if new MySql database was chosen for Hive service
  1116. * and it is not located on the same host as Ambari server
  1117. * that using MySql database too.
  1118. *
  1119. * @method resolveHiveMysqlDatabase
  1120. **/
  1121. resolveHiveMysqlDatabase: function () {
  1122. var hiveService = this.get('content.services').findProperty('serviceName', 'HIVE');
  1123. if (!hiveService || !hiveService.get('isSelected') || hiveService.get('isInstalled')) {
  1124. this.moveNext();
  1125. return;
  1126. }
  1127. var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_database').value;
  1128. if (hiveDBType == 'New MySQL Database') {
  1129. var self = this;
  1130. this.checkMySQLHost().done(function () {
  1131. if (self.get('mySQLServerConflict')) {
  1132. // error popup before you can proceed
  1133. return App.ModalPopup.show({
  1134. header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
  1135. bodyClass: Ember.View.extend({
  1136. template: Ember.Handlebars.compile(Em.I18n.t('installer.step7.popup.mySQLWarning.body'))
  1137. }),
  1138. secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
  1139. primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
  1140. onSecondary: function () {
  1141. var parent = this;
  1142. return App.ModalPopup.show({
  1143. header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
  1144. bodyClass: Ember.View.extend({
  1145. template: Ember.Handlebars.compile(Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'))
  1146. }),
  1147. onPrimary: function () {
  1148. this.hide();
  1149. parent.hide();
  1150. // go back to step 5: assign masters and disable default navigation warning
  1151. App.router.get('installerController').gotoStep(5, true);
  1152. }
  1153. });
  1154. }
  1155. });
  1156. } else {
  1157. self.moveNext();
  1158. }
  1159. });
  1160. } else {
  1161. this.moveNext();
  1162. }
  1163. },
  1164. checkDatabaseConnectionTest: function () {
  1165. var deferred = $.Deferred();
  1166. var configMap = [
  1167. {
  1168. serviceName: 'OOZIE',
  1169. ignored: [Em.I18n.t('installer.step7.oozie.database.new')]
  1170. },
  1171. {
  1172. serviceName: 'HIVE',
  1173. ignored: [Em.I18n.t('installer.step7.hive.database.new.mysql'), Em.I18n.t('installer.step7.hive.database.new.postgres')]
  1174. }
  1175. ];
  1176. configMap.forEach(function (config) {
  1177. var isConnectionNotTested = false;
  1178. var service = this.get('content.services').findProperty('serviceName', config.serviceName);
  1179. if (service && service.get('isSelected') && !service.get('isInstalled')) {
  1180. var serviceConfigs = this.get('stepConfigs').findProperty('serviceName', config.serviceName).configs;
  1181. var serviceDatabase = serviceConfigs.findProperty('name', config.serviceName.toLowerCase() + '_database').get('value');
  1182. if (!config.ignored.contains(serviceDatabase)) {
  1183. var filledProperties = App.db.get('tmp', config.serviceName + '_connection');
  1184. if (!filledProperties || App.isEmptyObject(filledProperties)) {
  1185. isConnectionNotTested = true;
  1186. } else {
  1187. for (var key in filledProperties) {
  1188. if (serviceConfigs.findProperty('name', key).get('value') !== filledProperties[key])
  1189. isConnectionNotTested = true;
  1190. }
  1191. }
  1192. }
  1193. }
  1194. config.isCheckIgnored = isConnectionNotTested;
  1195. }, this);
  1196. var ignoredServices = configMap.filterProperty('isCheckIgnored', true);
  1197. if (ignoredServices.length) {
  1198. var displayedServiceNames = ignoredServices.mapProperty('serviceName').map(function (serviceName) {
  1199. return this.get('content.services').findProperty('serviceName', serviceName).get('displayName');
  1200. }, this);
  1201. this.showDatabaseConnectionWarningPopup(displayedServiceNames, deferred);
  1202. }
  1203. else {
  1204. deferred.resolve();
  1205. }
  1206. return deferred;
  1207. },
  1208. showDatabaseConnectionWarningPopup: function (serviceNames, deferred) {
  1209. return App.ModalPopup.show({
  1210. header: Em.I18n.t('installer.step7.popup.database.connection.header'),
  1211. body: Em.I18n.t('installer.step7.popup.database.connection.body').format(serviceNames.join(', ')),
  1212. secondary: Em.I18n.t('common.cancel'),
  1213. primary: Em.I18n.t('common.proceedAnyway'),
  1214. onPrimary: function () {
  1215. deferred.resolve();
  1216. this._super();
  1217. },
  1218. onSecondary: function () {
  1219. deferred.reject();
  1220. this._super();
  1221. }
  1222. })
  1223. },
  1224. /**
  1225. * Proceed to the next step
  1226. **/
  1227. moveNext: function () {
  1228. App.router.send('next');
  1229. },
  1230. /**
  1231. * Click-handler on Next button
  1232. * Disable "Submit"-button while server-side processes are running
  1233. * @method submit
  1234. */
  1235. submit: function () {
  1236. if (this.get('isSubmitDisabled')) {
  1237. return;
  1238. }
  1239. var self = this;
  1240. this.set('submitButtonClicked', true);
  1241. this.serverSideValidation().done(function () {
  1242. self.checkDatabaseConnectionTest().done(function () {
  1243. self.resolveHiveMysqlDatabase();
  1244. self.set('submitButtonClicked', false);
  1245. });
  1246. }).fail(function (value) {
  1247. if ("invalid_configs" == value) {
  1248. self.set('submitButtonClicked', false);
  1249. } else {
  1250. // Failed due to validation mechanism failure.
  1251. // Should proceed with other checks
  1252. self.checkDatabaseConnectionTest().done(function () {
  1253. self.resolveHiveMysqlDatabase();
  1254. self.set('submitButtonClicked', false);
  1255. });
  1256. }
  1257. });
  1258. }
  1259. });