step7_controller.js 45 KB

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