step7_controller.js 50 KB

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