step7_controller.js 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753
  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. /**
  29. * @typedef {object} masterComponentHost
  30. * @property {string} component
  31. * @property {string} hostName
  32. * @property {boolean} isInstalled is component already installed on the this host or just going to be installed
  33. */
  34. /**
  35. * @typedef {object} topologyLocalDB
  36. * @property {object[]} hosts list of hosts with information of their disks usage and dirs
  37. * @property {masterComponentHost[]} masterComponentHosts
  38. * @property {?object[]} slaveComponentHosts
  39. */
  40. App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.EnhancedConfigsMixin, App.ToggleIsRequiredMixin, {
  41. name: 'wizardStep7Controller',
  42. /**
  43. * Contains all field properties that are viewed in this step
  44. * @type {object[]}
  45. */
  46. stepConfigs: [],
  47. hash: null,
  48. selectedService: null,
  49. slaveHostToGroup: null,
  50. addMiscTabToPage: true,
  51. /**
  52. * Is Submit-click processing now
  53. * @type {bool}
  54. */
  55. submitButtonClicked: false,
  56. isRecommendedLoaded: false,
  57. /**
  58. * used in services_config.js view to mark a config with security icon
  59. */
  60. secureConfigs: require('data/HDP2/secure_mapping'),
  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 applied to service configs loaded
  95. * @type {bool}
  96. */
  97. isAppliedConfigLoaded: true,
  98. isConfigsLoaded: Em.computed.and('wizardController.stackConfigsLoaded', 'isAppliedConfigLoaded'),
  99. /**
  100. * PreInstall Checks allowed only for Install
  101. * @type {boolean}
  102. */
  103. supportsPreInstallChecks: function () {
  104. return App.get('supports.preInstallChecks') && 'installerController' === this.get('content.controllerName');
  105. }.property('App.supports.preInstallChecks', 'wizardController.name'),
  106. /**
  107. * Number of errors in the configs in the selected service
  108. * @type {number}
  109. */
  110. errorsCount: function() {
  111. return this.get('selectedService.configsWithErrors').filter(function(c) {
  112. return Em.isNone(c.get('widget'));
  113. }).length;
  114. }.property('selectedService.configsWithErrors.length'),
  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. installedServices: function () {
  154. return App.StackService.find().toArray().toMapByCallback('serviceName', function (item) {
  155. return Em.get(item, 'isInstalled');
  156. });
  157. }.property(),
  158. /**
  159. * List of master components
  160. * @type {Ember.Enumerable}
  161. */
  162. masterComponentHosts: Em.computed.alias('content.masterComponentHosts'),
  163. /**
  164. * List of slave components
  165. * @type {Ember.Enumerable}
  166. */
  167. slaveComponentHosts: Em.computed.alias('content.slaveGroupProperties'),
  168. customData: [],
  169. /**
  170. * Filter text will be located here
  171. * @type {string}
  172. */
  173. filter: '',
  174. /**
  175. * list of dependencies that are user to set init value of config
  176. *
  177. * @type {Object}
  178. */
  179. configDependencies: function() {
  180. var dependencies = {
  181. 'sliderSelected': this.get('allSelectedServiceNames').contains('SLIDER')
  182. };
  183. var hiveMetastore = App.configsCollection.getConfigByName('hive.metastore.uris', 'hive-site.xml');
  184. var clientPort = App.configsCollection.getConfigByName('clientPort', 'zoo.cfg.xml');
  185. if (hiveMetastore) dependencies['hive.metastore.uris'] = hiveMetastore.recommendedValue;
  186. if (clientPort) dependencies['clientPort'] = clientPort.recommendedValue;
  187. return dependencies
  188. }.property('allSelectedServiceNames'),
  189. /**
  190. * List of filters for config properties to populate filter combobox
  191. */
  192. propertyFilters: [
  193. {
  194. attributeName: 'isOverridden',
  195. attributeValue: true,
  196. caption: 'common.combobox.dropdown.overridden'
  197. },
  198. {
  199. attributeName: 'isFinal',
  200. attributeValue: true,
  201. caption: 'common.combobox.dropdown.final'
  202. },
  203. {
  204. attributeName: 'hasIssues',
  205. attributeValue: true,
  206. caption: 'common.combobox.dropdown.issues'
  207. }
  208. ],
  209. issuesFilterText: function () {
  210. return (this.get('isSubmitDisabled') && !this.get('submitButtonClicked') &&
  211. this.get('filterColumns').findProperty('attributeName', 'hasIssues').get('selected')) ?
  212. Em.I18n.t('installer.step7.showingPropertiesWithIssues') : '';
  213. }.property('isSubmitDisabled', 'submitButtonClicked', 'filterColumns.@each.selected'),
  214. issuesFilterLinkText: function () {
  215. if (this.get('filterColumns').findProperty('attributeName', 'hasIssues').get('selected')) {
  216. return Em.I18n.t('installer.step7.showAllProperties');
  217. }
  218. return (this.get('isSubmitDisabled') && !this.get('submitButtonClicked')) ?
  219. (
  220. this.get('filterColumns').findProperty('attributeName', 'hasIssues').get('selected') ?
  221. Em.I18n.t('installer.step7.showAllProperties') : Em.I18n.t('installer.step7.showPropertiesWithIssues')
  222. ) : '';
  223. }.property('isSubmitDisabled', 'submitButtonClicked', 'filterColumns.@each.selected'),
  224. /**
  225. * Dropdown menu items in filter combobox
  226. */
  227. filterColumns: function () {
  228. return this.get('propertyFilters').map(function (filter) {
  229. return Ember.Object.create({
  230. attributeName: filter.attributeName,
  231. attributeValue: filter.attributeValue,
  232. name: this.t(filter.caption),
  233. selected: false
  234. });
  235. }, this);
  236. }.property('propertyFilters'),
  237. /**
  238. * Clear controller's properties:
  239. * <ul>
  240. * <li>stepConfigs</li>
  241. * <li>filter</li>
  242. * </ul>
  243. * and desect all <code>filterColumns</code>
  244. * @method clearStep
  245. */
  246. clearStep: function () {
  247. this.setProperties({
  248. configValidationGlobalMessage: [],
  249. submitButtonClicked: false,
  250. isSubmitDisabled: true,
  251. isRecommendedLoaded: false
  252. });
  253. this.get('stepConfigs').clear();
  254. this.set('filter', '');
  255. this.get('filterColumns').setEach('selected', false);
  256. },
  257. /**
  258. * Generate "finger-print" for current <code>stepConfigs[0]</code>
  259. * Used to determine, if user has some unsaved changes (comparing with <code>hash</code>)
  260. * @returns {string|null}
  261. * @method getHash
  262. */
  263. getHash: function () {
  264. if (!this.get('stepConfigs')[0]) {
  265. return null;
  266. }
  267. var hash = {};
  268. this.get('stepConfigs').forEach(function(stepConfig){
  269. stepConfig.configs.forEach(function (config) {
  270. hash[config.get('name')] = {value: config.get('value'), overrides: [], isFinal: config.get('isFinal')};
  271. if (!config.get('overrides')) return;
  272. if (!config.get('overrides.length')) return;
  273. config.get('overrides').forEach(function (override) {
  274. hash[config.get('name')].overrides.push(override.get('value'));
  275. });
  276. });
  277. });
  278. return JSON.stringify(hash);
  279. },
  280. /**
  281. * Are some changes available
  282. */
  283. hasChanges: function () {
  284. return this.get('hash') != this.getHash();
  285. },
  286. /**
  287. * Load config groups for installed services
  288. * One ajax-request for each service
  289. * @param {string[]} servicesNames
  290. * @method loadInstalledServicesConfigGroups
  291. */
  292. loadInstalledServicesConfigGroups: function (servicesNames) {
  293. servicesNames.forEach(function (serviceName) {
  294. App.ajax.send({
  295. name: 'config.tags_and_groups',
  296. sender: this,
  297. data: {
  298. serviceName: serviceName,
  299. serviceConfigsDef: App.config.get('preDefinedServiceConfigs').findProperty('serviceName', serviceName)
  300. },
  301. success: 'loadServiceTagsSuccess'
  302. });
  303. }, this);
  304. },
  305. /**
  306. * Create site to tag map. Format:
  307. * <code>
  308. * {
  309. * site1: tag1,
  310. * site1: tag2,
  311. * site2: tag3
  312. * ...
  313. * }
  314. * </code>
  315. * @param {object} desired_configs
  316. * @param {string[]} sites
  317. * @returns {object}
  318. * @private
  319. * @method _createSiteToTagMap
  320. */
  321. _createSiteToTagMap: function (desired_configs, sites) {
  322. var siteToTagMap = {};
  323. for (var site in desired_configs) {
  324. if (desired_configs.hasOwnProperty(site)) {
  325. if (!!sites[site]) {
  326. siteToTagMap[site] = desired_configs[site].tag;
  327. }
  328. }
  329. }
  330. return siteToTagMap;
  331. },
  332. /**
  333. * Load config groups success callback
  334. * @param {object} data
  335. * @param {object} opt
  336. * @param {object} params
  337. * @method loadServiceTagsSuccess
  338. */
  339. loadServiceTagsSuccess: function (data, opt, params) {
  340. var serviceName = params.serviceName,
  341. service = this.get('stepConfigs').findProperty('serviceName', serviceName),
  342. defaultConfigGroupHosts = this.get('wizardController.allHosts').mapProperty('hostName'),
  343. siteToTagMap = this._createSiteToTagMap(data.Clusters.desired_configs, params.serviceConfigsDef.get('configTypes'));
  344. this.set('loadedClusterSiteToTagMap', siteToTagMap);
  345. //parse loaded config groups
  346. var configGroups = [];
  347. if (data.config_groups.length) {
  348. data.config_groups.forEach(function (item) {
  349. item = item.ConfigGroup;
  350. if (item.tag === serviceName) {
  351. var groupHosts = item.hosts.mapProperty('host_name');
  352. configGroups.push({
  353. id: serviceName + item.id,
  354. config_group_id: item.id,
  355. name: item.group_name,
  356. description: item.description,
  357. is_default: false,
  358. parent_config_group_id: App.ServiceConfigGroup.getParentConfigGroupId(serviceName),
  359. service_id: serviceName,
  360. service_name: serviceName,
  361. hosts: groupHosts,
  362. desired_configs: item.desired_configs
  363. });
  364. groupHosts.forEach(function (host) {
  365. defaultConfigGroupHosts = defaultConfigGroupHosts.without(host);
  366. }, this);
  367. }
  368. }, this);
  369. }
  370. var defaultConfigGroup = App.configGroupsMapper.generateDefaultGroup(serviceName, defaultConfigGroupHosts);
  371. configGroups = configGroups.sortProperty('name');
  372. configGroups.unshift(defaultConfigGroup);
  373. App.store.loadMany(App.ServiceConfigGroup, configGroups);
  374. App.store.commit();
  375. service.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName', serviceName));
  376. var loadedGroupToOverrideSiteToTagMap = {};
  377. configGroups.forEach(function (item) {
  378. var groupName = item.name;
  379. loadedGroupToOverrideSiteToTagMap[groupName] = {};
  380. item.desired_configs.forEach(function (site) {
  381. loadedGroupToOverrideSiteToTagMap[groupName][site.type] = site.tag;
  382. }, this);
  383. }, this);
  384. this.set('preSelectedConfigGroup', App.ServiceConfigGroup.find(App.ServiceConfigGroup.getParentConfigGroupId(serviceName)));
  385. this.loadServiceConfigGroupOverrides(service.get('configs'), loadedGroupToOverrideSiteToTagMap, service.get('configGroups'));
  386. },
  387. /**
  388. * Get properties from server by type and tag with properties, that belong to group
  389. * push them to common {serviceConfigs} and call callback function
  390. */
  391. loadServiceConfigGroupOverrides: function (serviceConfigs, loadedGroupToOverrideSiteToTagMap, configGroups) {
  392. var configKeyToConfigMap = {};
  393. serviceConfigs.forEach(function (item) {
  394. if (!configKeyToConfigMap[item.filename]) {
  395. configKeyToConfigMap[item.filename] = {};
  396. }
  397. configKeyToConfigMap[item.filename][item.name] = item;
  398. });
  399. var typeTagToGroupMap = {};
  400. var urlParams = [];
  401. for (var group in loadedGroupToOverrideSiteToTagMap) {
  402. var overrideTypeTags = loadedGroupToOverrideSiteToTagMap[group];
  403. for (var type in overrideTypeTags) {
  404. var tag = overrideTypeTags[type];
  405. typeTagToGroupMap[type + "///" + tag] = configGroups.findProperty('name', group);
  406. urlParams.push('(type=' + type + '&tag=' + tag + ')');
  407. }
  408. }
  409. var params = urlParams.join('|');
  410. if (urlParams.length) {
  411. App.ajax.send({
  412. name: 'config.host_overrides',
  413. sender: this,
  414. data: {
  415. params: params,
  416. configKeyToConfigMap: configKeyToConfigMap,
  417. typeTagToGroupMap: typeTagToGroupMap,
  418. serviceConfigs: serviceConfigs
  419. },
  420. success: 'loadServiceConfigGroupOverridesSuccess'
  421. });
  422. } else {
  423. this.onLoadOverrides(serviceConfigs);
  424. }
  425. },
  426. loadServiceConfigGroupOverridesSuccess: function (data, opt, params) {
  427. data.items.forEach(function (config) {
  428. var group = params.typeTagToGroupMap[config.type + "///" + config.tag];
  429. var properties = config.properties;
  430. for (var prop in properties) {
  431. var fileName = App.config.getOriginalFileName(config.type);
  432. var serviceConfig = !!params.configKeyToConfigMap[fileName] ? params.configKeyToConfigMap[fileName][prop] : false;
  433. var hostOverrideValue = App.config.formatPropertyValue(serviceConfig, properties[prop]);
  434. var hostOverrideIsFinal = !!(config.properties_attributes && config.properties_attributes.final && config.properties_attributes.final[prop]);
  435. if (serviceConfig) {
  436. // Value of this property is different for this host.
  437. if (!Em.get(serviceConfig, 'overrides')) Em.set(serviceConfig, 'overrides', []);
  438. serviceConfig.overrides.pushObject({value: hostOverrideValue, group: group, isFinal: hostOverrideIsFinal});
  439. } else {
  440. params.serviceConfigs.push(App.config.createCustomGroupConfig(prop, fileName, config.properties[prop], group));
  441. }
  442. }
  443. });
  444. this.onLoadOverrides(params.serviceConfigs);
  445. },
  446. onLoadOverrides: function (configs) {
  447. var serviceName = configs[0].serviceName,
  448. service = this.get('stepConfigs').findProperty('serviceName', serviceName);
  449. var serviceConfig = App.config.createServiceConfig(serviceName);
  450. service.set('selectedConfigGroup', this.get('preSelectedConfigGroup'));
  451. this.loadComponentConfigs(service.get('configs'), serviceConfig, service);
  452. // override if a property isRequired or not
  453. this.overrideConfigIsRequired(service);
  454. service.set('configs', serviceConfig.get('configs'));
  455. },
  456. /**
  457. * Set <code>isEditable</code>-property to <code>serviceConfigProperty</code>
  458. * Based on user's permissions and selected config group
  459. * @param {Ember.Object} serviceConfigProperty
  460. * @param {bool} defaultGroupSelected
  461. * @returns {Ember.Object} Updated config-object
  462. * @method _updateIsEditableFlagForConfig
  463. */
  464. _updateIsEditableFlagForConfig: function (serviceConfigProperty, defaultGroupSelected) {
  465. if (App.isAuthorized('AMBARI.ADD_DELETE_CLUSTERS')) {
  466. if (defaultGroupSelected && !this.get('isHostsConfigsPage') && !Em.get(serviceConfigProperty, 'group')) {
  467. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  468. } else if (Em.get(serviceConfigProperty, 'group') && Em.get(serviceConfigProperty, 'group.name') == this.get('selectedConfigGroup.name')) {
  469. serviceConfigProperty.set('isEditable', true);
  470. } else {
  471. serviceConfigProperty.set('isEditable', false);
  472. }
  473. }
  474. else {
  475. serviceConfigProperty.set('isEditable', false);
  476. }
  477. return serviceConfigProperty;
  478. },
  479. /**
  480. * Set <code>overrides</code>-property to <code>serviceConfigProperty<code>
  481. * @param {Ember.Object} serviceConfigProperty
  482. * @param {Ember.Object} component
  483. * @return {Ember.Object} Updated config-object
  484. * @method _updateOverridesForConfig
  485. */
  486. _updateOverridesForConfig: function (serviceConfigProperty, component) {
  487. var overrides = serviceConfigProperty.get('overrides');
  488. if (Em.isNone(overrides)) {
  489. serviceConfigProperty.set('overrides', Em.A([]));
  490. return serviceConfigProperty;
  491. }
  492. serviceConfigProperty.set('overrides', null);
  493. var defaultGroupSelected = component.get('selectedConfigGroup.isDefault');
  494. // Wrap each override to App.ServiceConfigProperty
  495. overrides.forEach(function (override) {
  496. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  497. newSCP.set('value', override.value);
  498. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  499. newSCP.set('parentSCP', serviceConfigProperty);
  500. if (defaultGroupSelected) {
  501. var group = component.get('configGroups').findProperty('name', override.group.get('name'));
  502. // prevent cycle in proto object, clean link
  503. if (group.get('properties').length == 0) {
  504. group.set('properties', Em.A([]));
  505. }
  506. group.get('properties').push(newSCP);
  507. newSCP.set('group', override.group);
  508. newSCP.set('isEditable', false);
  509. }
  510. var parentOverridesArray = serviceConfigProperty.get('overrides');
  511. if (Em.isNone(parentOverridesArray)) {
  512. parentOverridesArray = Em.A([]);
  513. serviceConfigProperty.set('overrides', parentOverridesArray);
  514. }
  515. serviceConfigProperty.get('overrides').pushObject(newSCP);
  516. newSCP.validate();
  517. }, this);
  518. return serviceConfigProperty;
  519. },
  520. /**
  521. * Set configs with overrides, recommended defaults to component
  522. * @param {Ember.Object[]} configs
  523. * @param {Ember.Object} componentConfig
  524. * @param {Ember.Object} component
  525. * @method loadComponentConfigs
  526. */
  527. loadComponentConfigs: function (configs, componentConfig, component) {
  528. var defaultGroupSelected = component.get('selectedConfigGroup.isDefault');
  529. configs.forEach(function (serviceConfigProperty) {
  530. if (!serviceConfigProperty) return;
  531. if (Em.isNone(serviceConfigProperty.get('isOverridable'))) {
  532. serviceConfigProperty.set('isOverridable', true);
  533. }
  534. this._updateOverridesForConfig(serviceConfigProperty, component);
  535. this._updateIsEditableFlagForConfig(serviceConfigProperty, defaultGroupSelected);
  536. componentConfig.get('configs').pushObject(serviceConfigProperty);
  537. serviceConfigProperty.validate();
  538. }, this);
  539. component.get('configGroups').filterProperty('isDefault', false).forEach(function (configGroup) {
  540. configGroup.set('hash', this.get('wizardController').getConfigGroupHash(configGroup));
  541. }, this);
  542. var overrideToAdd = this.get('overrideToAdd');
  543. if (overrideToAdd) {
  544. overrideToAdd = componentConfig.get('configs').findProperty('name', overrideToAdd.name);
  545. if (overrideToAdd) {
  546. var group = this.get('selectedService.configGroups').findProperty('name', this.get('selectedConfigGroup.name'));
  547. var newSCP = App.config.createOverride(overrideToAdd, {isEditable: true}, group);
  548. group.get('properties').pushObject(newSCP);
  549. component.set('overrideToAdd', null);
  550. }
  551. }
  552. },
  553. /**
  554. * On load function
  555. * @method loadStep
  556. */
  557. loadStep: function () {
  558. if (!this.get('isConfigsLoaded')) {
  559. return;
  560. }
  561. console.time('wizard loadStep: ');
  562. this.clearStep();
  563. var self = this;
  564. App.config.setPreDefinedServiceConfigs(this.get('addMiscTabToPage'));
  565. var storedConfigs = this.get('content.serviceConfigProperties');
  566. var configs = (storedConfigs && storedConfigs.length) ? storedConfigs : App.configsCollection.getAll();
  567. this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
  568. if (this.get('wizardController.name') === 'addServiceController' && !this.get('content.serviceConfigProperties.length')) {
  569. App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags')).done(function (loadedConfigs) {
  570. configs = self.setInstalledServiceConfigs(configs, loadedConfigs, self.get('installedServiceNames'));
  571. self.applyServicesConfigs(configs);
  572. });
  573. } else {
  574. this.applyServicesConfigs(configs);
  575. }
  576. },
  577. /**
  578. * Resolve config theme conditions
  579. * in order to correctly calculate config errors number of service
  580. * @param {Array} configs
  581. */
  582. resolveConfigThemeConditions: function (configs) {
  583. App.ThemeCondition.find().forEach(function (configCondition) {
  584. var _configs = Em.A(configCondition.get('configs'));
  585. if (configCondition.get("resource") === 'config' && _configs.length > 0) {
  586. var isConditionTrue = App.config.calculateConfigCondition(configCondition.get("if"), configs);
  587. var action = isConditionTrue ? configCondition.get("then") : configCondition.get("else");
  588. if (configCondition.get('id')) {
  589. var valueAttributes = action.property_value_attributes;
  590. if (valueAttributes && !Em.none(valueAttributes['visible'])) {
  591. var themeResource;
  592. if (configCondition.get('type') === 'subsection') {
  593. themeResource = App.SubSection.find().findProperty('name', configCondition.get('name'));
  594. } else if (configCondition.get('type') === 'subsectionTab') {
  595. themeResource = App.SubSectionTab.find().findProperty('name', configCondition.get('name'));
  596. } else if (configCondition.get('type') === 'config') {
  597. //simulate section wrapper for condition type "config"
  598. themeResource = Em.Object.create({
  599. configProperties: [App.config.configId(configCondition.get('configName'), configCondition.get('fileName'))]
  600. });
  601. }
  602. if (themeResource) {
  603. themeResource.get('configProperties').forEach(function (_configId) {
  604. configs.forEach(function (item) {
  605. if (App.config.configId(item.name, item.filename) === _configId) {
  606. // if config has already been hidden by condition with "subsection" or "subsectionTab" type
  607. // then ignore condition of "config" type
  608. if (configCondition.get('type') === 'config' && item.hiddenBySection) return false;
  609. item.hiddenBySection = !valueAttributes['visible'];
  610. }
  611. });
  612. }, this);
  613. }
  614. }
  615. }
  616. }
  617. });
  618. },
  619. /**
  620. * Update hawq configuration depending on the state of the cluster
  621. * @param {Array} configs
  622. */
  623. updateHawqConfigs: function (configs) {
  624. if (this.get('wizardController.name') == 'addServiceController') {
  625. if (App.get('isHaEnabled')) this.addHawqConfigsOnNnHa(configs);
  626. if (App.get('isRMHaEnabled')) this.addHawqConfigsOnRMHa(configs);
  627. if (App.get('isKerberosEnabled')) this.addHawqConfigsOnKerberizedCluster(configs);
  628. }
  629. if (App.get('isSingleNode')) this.removeHawqStandbyHostAddressConfig(configs);
  630. return configs
  631. },
  632. /**
  633. * Remove hawq_standby_address_host config from HAWQ configs
  634. * @param {Array} configs
  635. */
  636. removeHawqStandbyHostAddressConfig: function(configs) {
  637. var hawqStandbyAddressHostIndex = configs.indexOf(configs.findProperty('name', 'hawq_standby_address_host'));
  638. if (hawqStandbyAddressHostIndex > -1) configs.removeAt(hawqStandbyAddressHostIndex) ;
  639. return configs
  640. },
  641. applyServicesConfigs: function (configs) {
  642. if (this.get('allSelectedServiceNames').contains('YARN')) {
  643. configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml', []);
  644. }
  645. if (!this.get('installedServiceNames').contains('HAWQ') && this.get('allSelectedServiceNames').contains('HAWQ')) {
  646. this.updateHawqConfigs(configs);
  647. }
  648. if (App.get('isKerberosEnabled') && this.get('wizardController.name') == 'addServiceController') {
  649. this.addKerberosDescriptorConfigs(configs, this.get('wizardController.kerberosDescriptorConfigs') || []);
  650. }
  651. this.resolveConfigThemeConditions(configs);
  652. var stepConfigs = this.createStepConfigs();
  653. var serviceConfigs = this.renderConfigs(stepConfigs, configs);
  654. // if HA is enabled -> Make some reconfigurations
  655. if (this.get('wizardController.name') === 'addServiceController' && App.get('isHaEnabled')) {
  656. serviceConfigs = this._reconfigureServicesOnNnHa(serviceConfigs);
  657. }
  658. this.set('stepConfigs', serviceConfigs);
  659. this.checkHostOverrideInstaller();
  660. this.selectProperService();
  661. var self = this;
  662. var rangerService = App.StackService.find().findProperty('serviceName', 'RANGER');
  663. if (rangerService && !rangerService.get('isInstalled') && !rangerService.get('isSelected')) {
  664. App.config.removeRangerConfigs(self.get('stepConfigs'));
  665. }
  666. this.loadConfigRecommendations(null, this.completeConfigLoading.bind(this));
  667. },
  668. completeConfigLoading: function() {
  669. this.clearRecommendationsByServiceName(App.StackService.find().filterProperty('isSelected').mapProperty('serviceName'));
  670. console.timeEnd('wizard loadStep: ');
  671. this.set('isRecommendedLoaded', true);
  672. if (this.get('content.skipConfigStep')) {
  673. App.router.send('next');
  674. }
  675. this.set('hash', this.getHash());
  676. },
  677. /**
  678. * Update initialValues only while loading recommendations first time
  679. *
  680. * @param serviceName
  681. * @returns {boolean}
  682. * @override
  683. */
  684. updateInitialOnRecommendations: function(serviceName) {
  685. return this._super(serviceName) && !this.get('isRecommendedLoaded');
  686. },
  687. /**
  688. * Mark descriptor properties in configuration object.
  689. *
  690. * @param {Object[]} configs - config properties to change
  691. * @param {App.ServiceConfigProperty[]} descriptor - parsed kerberos descriptor
  692. * @method addKerberosDescriptorConfigs
  693. */
  694. addKerberosDescriptorConfigs: function (configs, descriptor) {
  695. descriptor.forEach(function (item) {
  696. var property = configs.findProperty('name', item.get('name'));
  697. if (property) {
  698. Em.setProperties(property, {
  699. isSecureConfig: true,
  700. displayName: Em.get(item, 'name'),
  701. isUserProperty: false,
  702. isOverridable: false,
  703. category: 'Advanced ' + Em.get(item, 'filename')
  704. });
  705. }
  706. });
  707. },
  708. /**
  709. * Load config groups
  710. * and (if some services are already installed) load config groups for installed services
  711. * @method checkHostOverrideInstaller
  712. */
  713. checkHostOverrideInstaller: function () {
  714. if (this.get('wizardController.name') !== 'kerberosWizardController') {
  715. this.loadConfigGroups(this.get('content.configGroups'));
  716. }
  717. if (this.get('installedServiceNames').length > 0 && !this.get('wizardController.areInstalledConfigGroupsLoaded')) {
  718. this.loadInstalledServicesConfigGroups(this.get('installedServiceNames'));
  719. }
  720. },
  721. /**
  722. * Create stepConfigs array with all info except configs list
  723. *
  724. * @return {Object[]}
  725. * @method createStepConfigs
  726. */
  727. createStepConfigs: function() {
  728. var stepConfigs = [];
  729. App.config.get('preDefinedServiceConfigs').forEach(function (service) {
  730. var serviceName = service.get('serviceName');
  731. if (['MISC'].concat(this.get('allSelectedServiceNames')).contains(serviceName)) {
  732. var serviceConfig = App.config.createServiceConfig(serviceName);
  733. serviceConfig.set('showConfig', App.StackService.find(serviceName).get('isInstallable'));
  734. if (this.get('wizardController.name') == 'addServiceController') {
  735. serviceConfig.set('selected', !this.get('installedServiceNames').concat('MISC').contains(serviceName));
  736. if (serviceName === 'MISC') {
  737. serviceConfig.set('configCategories', serviceConfig.get('configCategories').rejectProperty('name', 'Notifications'));
  738. }
  739. } else if (this.get('wizardController.name') == 'kerberosWizardController') {
  740. serviceConfig.set('showConfig', true);
  741. }
  742. stepConfigs.pushObject(serviceConfig);
  743. }
  744. }, this);
  745. return stepConfigs;
  746. },
  747. /**
  748. * For Namenode HA, HAWQ service requires additional config parameters in hdfs-client.xml
  749. * This method ensures that these additional parameters are added to hdfs-client.xml
  750. * @param configs existing configs on cluster
  751. * @returns {Object[]} existing configs + additional config parameters in hdfs-client.xml
  752. */
  753. addHawqConfigsOnNnHa: function(configs) {
  754. var nameService = configs.findProperty('id', 'dfs.nameservices__hdfs-site').value;
  755. var propertyNames = [
  756. 'dfs.nameservices',
  757. 'dfs.ha.namenodes.' + nameService,
  758. 'dfs.namenode.rpc-address.'+ nameService +'.nn1',
  759. 'dfs.namenode.rpc-address.'+ nameService +'.nn2',
  760. 'dfs.namenode.http-address.'+ nameService +'.nn1',
  761. 'dfs.namenode.http-address.'+ nameService +'.nn2'
  762. ];
  763. propertyNames.forEach(function(propertyName, propertyIndex) {
  764. var propertyFromHdfs = configs.findProperty('id', propertyName + '__hdfs-site');
  765. var newProperty = App.config.createDefaultConfig(propertyName, 'HAWQ', 'hdfs-client.xml', true);
  766. Em.setProperties(newProperty, {
  767. description: propertyFromHdfs.description,
  768. displayName: propertyFromHdfs.displayName,
  769. displayType: 'string',
  770. index: propertyIndex,
  771. isOverridable: false,
  772. isReconfigurable: false,
  773. name: propertyFromHdfs.name,
  774. value: propertyFromHdfs.value,
  775. recommendedValue: propertyFromHdfs.recommendedValue
  776. });
  777. configs.push(App.ServiceConfigProperty.create(newProperty));
  778. });
  779. return configs;
  780. },
  781. /**
  782. * For ResourceManager HA, HAWQ service requires additional config parameters in yarn-client.xml
  783. * This method ensures that these additional parameters are added to yarn-client.xml
  784. * @param configs existing configs on cluster
  785. * @returns {Object[]} existing configs + additional config parameters in yarn-client.xml
  786. */
  787. addHawqConfigsOnRMHa: function(configs) {
  788. rmHost1 = configs.findProperty('id', 'yarn.resourcemanager.hostname.rm1__yarn-site').value ;
  789. rmHost2 = configs.findProperty('id', 'yarn.resourcemanager.hostname.rm2__yarn-site').value ;
  790. var yarnConfigToBeAdded = [
  791. {
  792. name: 'yarn.resourcemanager.ha',
  793. displayName: 'yarn.resourcemanager.ha',
  794. description: 'Comma separated yarn resourcemanager host addresses with port',
  795. port: '8032'
  796. },
  797. {
  798. name: 'yarn.resourcemanager.scheduler.ha',
  799. displayName: 'yarn.resourcemanager.scheduler.ha',
  800. description: 'Comma separated yarn resourcemanager scheduler addresses with port',
  801. port: '8030'
  802. }
  803. ];
  804. yarnConfigToBeAdded.forEach(function(propertyDetails) {
  805. var newProperty = App.config.createDefaultConfig(propertyDetails.name, 'HAWQ', 'yarn-client.xml', true);
  806. var value = rmHost1 + ':' + propertyDetails.port + ',' + rmHost2 + ':' + propertyDetails.port;
  807. Em.setProperties(newProperty, {
  808. name: propertyDetails.name,
  809. description: propertyDetails.description,
  810. displayName: propertyDetails.displayName,
  811. isOverridable: false,
  812. isReconfigurable: false,
  813. value: value,
  814. recommendedValue: value
  815. });
  816. configs.push(App.ServiceConfigProperty.create(newProperty));
  817. });
  818. return configs;
  819. },
  820. /**
  821. * For Kerberos Enabled cluster, HAWQ service requires additional config parameters in hdfs-client.xml and hawq-site.xml
  822. * This method ensures that these additional parameters are added to hdfs-client.xml and hawq-site.xml
  823. * @param configs existing configs on cluster
  824. * @returns {Object[]} existing configs + additional config parameters in hdfs-client.xml and hawq-site.xml
  825. */
  826. addHawqConfigsOnKerberizedCluster: function(configs) {
  827. Em.A([
  828. {
  829. name: 'hadoop.security.authentication',
  830. value: 'kerberos',
  831. filename: 'hdfs-client.xml',
  832. isOverridable: false,
  833. isReconfigurable: false
  834. }, {
  835. name: 'enable_secure_filesystem',
  836. value: 'ON',
  837. filename: 'hawq-site.xml',
  838. isOverridable: false,
  839. isReconfigurable: false
  840. }, {
  841. name: 'krb_server_keyfile',
  842. value: '/etc/security/keytabs/hawq.service.keytab',
  843. filename: 'hawq-site.xml',
  844. isOverridable: true,
  845. isReconfigurable: true
  846. }
  847. ]).forEach(function (property) {
  848. var newProperty = App.config.createDefaultConfig(property.name, 'HAWQ', property.filename, true);
  849. Em.setProperties(newProperty, {
  850. displayName: property.name,
  851. displayType: 'string',
  852. name: property.name,
  853. value: property.value,
  854. recommendedValue: property.value,
  855. isOverridable: property.isOverridable,
  856. isReconfigurable: property.isReconfigurable,
  857. isSecureConfig: true
  858. });
  859. configs.push(App.ServiceConfigProperty.create(newProperty));
  860. });
  861. },
  862. /**
  863. * render configs, distribute them by service
  864. * and wrap each in ServiceConfigProperty object
  865. * @param stepConfigs
  866. * @param configs
  867. * @return {App.ServiceConfig[]}
  868. */
  869. renderConfigs: function (stepConfigs, configs) {
  870. var localDB = {
  871. hosts: this.get('wizardController.content.hosts'),
  872. masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
  873. slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts')
  874. };
  875. var configsByService = {}, dependencies = this.get('configDependencies');
  876. configs.forEach(function (_config) {
  877. if (!configsByService[_config.serviceName]) {
  878. configsByService[_config.serviceName] = [];
  879. }
  880. var serviceConfigProperty = App.ServiceConfigProperty.create(_config);
  881. this.updateHostOverrides(serviceConfigProperty, _config);
  882. if (this.get('wizardController.name') === 'addServiceController') {
  883. this._updateIsEditableFlagForConfig(serviceConfigProperty, true);
  884. }
  885. if (!this.get('content.serviceConfigProperties.length') && !serviceConfigProperty.get('hasInitialValue')) {
  886. App.ConfigInitializer.initialValue(serviceConfigProperty, localDB, dependencies);
  887. }
  888. serviceConfigProperty.validate();
  889. configsByService[_config.serviceName].pushObject(serviceConfigProperty);
  890. }, this);
  891. stepConfigs.forEach(function (service) {
  892. service.set('configs', configsByService[service.get('serviceName')]);
  893. if (['addServiceController', 'installerController'].contains(this.get('wizardController.name'))) {
  894. this.addHostNamesToConfigs(service, localDB.masterComponentHosts, localDB.slaveComponentHosts);
  895. }
  896. }, this);
  897. return stepConfigs;
  898. },
  899. /**
  900. * Add host name properties to appropriate categories (for installer and add service)
  901. *
  902. * @param {Object} serviceConfig
  903. * @param {Object[]} masterComponents - info from localStorage
  904. * @param {Object[]} slaveComponents - info from localStorage
  905. */
  906. addHostNamesToConfigs: function(serviceConfig, masterComponents, slaveComponents) {
  907. serviceConfig.get('configCategories').forEach(function(c) {
  908. if (c.showHost) {
  909. var value = [];
  910. var componentName = c.name;
  911. var masters = masterComponents && masterComponents.filterProperty('component', componentName);
  912. if (masters.length) {
  913. value = masters.mapProperty('hostName');
  914. } else {
  915. var slaves = slaveComponents && slaveComponents.findProperty('componentName', componentName);
  916. if (slaves) {
  917. value = slaves.hosts.mapProperty('hostName');
  918. }
  919. }
  920. var stackComponent = App.StackServiceComponent.find(componentName);
  921. var hProperty = App.config.createHostNameProperty(serviceConfig.get('serviceName'), componentName, value, stackComponent);
  922. var newConfigName = Em.get(hProperty, 'name');
  923. if (!serviceConfig.get('configs').someProperty('name', newConfigName)) {
  924. serviceConfig.get('configs').push(App.ServiceConfigProperty.create(hProperty));
  925. }
  926. }
  927. }, this);
  928. },
  929. /**
  930. * create new child configs from overrides, attach them to parent config
  931. * override - value of config, related to particular host(s)
  932. * @param configProperty
  933. * @param storedConfigProperty
  934. */
  935. updateHostOverrides: function (configProperty, storedConfigProperty) {
  936. if (storedConfigProperty.overrides != null && storedConfigProperty.overrides.length > 0) {
  937. var overrides = [];
  938. storedConfigProperty.overrides.forEach(function (overrideEntry) {
  939. // create new override with new value
  940. var newSCP = App.ServiceConfigProperty.create(configProperty);
  941. newSCP.set('value', overrideEntry.value);
  942. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  943. newSCP.set('parentSCP', configProperty);
  944. overrides.pushObject(newSCP);
  945. });
  946. configProperty.set('overrides', overrides);
  947. }
  948. },
  949. /**
  950. * When NameNode HA is enabled some configs based on <code>dfs.nameservices</code> should be changed
  951. * This happens only if service is added AFTER NN HA is enabled
  952. *
  953. * @param {App.ServiceConfig[]} serviceConfigs
  954. * @method _reconfigureServiceOnNnHa
  955. * @private
  956. * @returns {App.ServiceConfig[]}
  957. */
  958. _reconfigureServicesOnNnHa: function (serviceConfigs) {
  959. var selectedServiceNames = this.get('selectedServiceNames');
  960. var nameServiceId = serviceConfigs.findProperty('serviceName', 'HDFS').configs.findProperty('name', 'dfs.nameservices');
  961. Em.A([
  962. {
  963. serviceName: 'HBASE',
  964. configToUpdate: 'hbase.rootdir'
  965. },
  966. {
  967. serviceName: 'ACCUMULO',
  968. configToUpdate: 'instance.volumes'
  969. },
  970. {
  971. serviceName: 'HAWQ',
  972. configToUpdate: 'hawq_dfs_url',
  973. regexPattern: /(^.*:[0-9]+)(?=\/)/,
  974. replacementValue: nameServiceId.get('value')
  975. }
  976. ]).forEach(function (c) {
  977. if (selectedServiceNames.contains(c.serviceName) && nameServiceId) {
  978. var cfg = serviceConfigs.findProperty('serviceName', c.serviceName).configs.findProperty('name', c.configToUpdate);
  979. var regexPattern = /\/\/.*:[0-9]+/i;
  980. var replacementValue = '//' + nameServiceId.get('value');
  981. if (typeof(c.regexPattern) !== "undefined" && typeof(c.replacementValue) !== "undefined") {
  982. regexPattern = c.regexPattern;
  983. replacementValue = c.replacementValue;
  984. }
  985. var newValue = cfg.get('value').replace(regexPattern, replacementValue);
  986. cfg.setProperties({
  987. value: newValue,
  988. recommendedValue: newValue
  989. });
  990. }
  991. });
  992. return serviceConfigs;
  993. },
  994. /**
  995. * Select first addable service for <code>addServiceWizard</code>
  996. * Select first service at all in other cases
  997. * @method selectProperService
  998. */
  999. selectProperService: function () {
  1000. if (this.get('wizardController.name') === 'addServiceController') {
  1001. this.set('selectedService', this.get('stepConfigs').filterProperty('selected', true).get('firstObject'));
  1002. } else {
  1003. this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
  1004. }
  1005. },
  1006. /**
  1007. * Load config tags
  1008. * @return {$.ajax|null}
  1009. * @method getConfigTags
  1010. */
  1011. getConfigTags: function () {
  1012. this.set('isAppliedConfigLoaded', false);
  1013. return App.ajax.send({
  1014. name: 'config.tags',
  1015. sender: this,
  1016. success: 'getConfigTagsSuccess'
  1017. });
  1018. },
  1019. /**
  1020. * Success callback for config tags request
  1021. * Updates <code>serviceConfigTags</code> with tags received from server
  1022. * @param {object} data
  1023. * @method getConfigTagsSuccess
  1024. */
  1025. getConfigTagsSuccess: function (data) {
  1026. var installedServiceSites = [];
  1027. App.StackService.find().filterProperty('isInstalled').forEach(function (service) {
  1028. if (!service.get('configTypes')) return;
  1029. var configTypes = Object.keys(service.get('configTypes'));
  1030. installedServiceSites = installedServiceSites.concat(configTypes);
  1031. }, this);
  1032. installedServiceSites = installedServiceSites.uniq();
  1033. var serviceConfigTags = [];
  1034. for (var site in data.Clusters.desired_configs) {
  1035. if (data.Clusters.desired_configs.hasOwnProperty(site)) {
  1036. if (installedServiceSites.contains(site) || site == 'cluster-env') {
  1037. serviceConfigTags.push({
  1038. siteName: site,
  1039. tagName: data.Clusters.desired_configs[site].tag,
  1040. newTagName: null
  1041. });
  1042. }
  1043. }
  1044. }
  1045. this.set('serviceConfigTags', serviceConfigTags);
  1046. this.set('isAppliedConfigLoaded', true);
  1047. },
  1048. /**
  1049. * set configs actual values from server
  1050. * @param configs
  1051. * @param configsByTags
  1052. * @param installedServiceNames
  1053. * @method setInstalledServiceConfigs
  1054. */
  1055. setInstalledServiceConfigs: function (configs, configsByTags, installedServiceNames) {
  1056. var configsMap = {};
  1057. configsByTags.forEach(function (configSite) {
  1058. configsMap[configSite.type] = configSite.properties || {};
  1059. });
  1060. var allConfigs = configs.filter(function (_config) {
  1061. // filter out alert_notification configs on add service //TODO find better place for this!
  1062. if (_config.filename === 'alert_notification') return false;
  1063. if ((['MISC'].concat(installedServiceNames).contains(_config.serviceName))) {
  1064. var type = _config.filename ? App.config.getConfigTagFromFileName(_config.filename) : null;
  1065. var mappedConfigValue = type && configsMap[type] ? configsMap[type][_config.name] : null;
  1066. if (Em.isNone(mappedConfigValue)) {
  1067. //for now ranger plugin properties are not sending by recommendations if they are missed - it should be added
  1068. return _config.serviceName == 'MISC' || /^ranger-/.test(_config.filename);
  1069. } else {
  1070. if (_config.savedValue != mappedConfigValue) {
  1071. _config.savedValue = App.config.formatPropertyValue(_config, mappedConfigValue);
  1072. }
  1073. _config.value = App.config.formatPropertyValue(_config, mappedConfigValue);
  1074. _config.hasInitialValue = true;
  1075. this.updateDependencies(_config);
  1076. delete configsMap[type][_config.name];
  1077. return true;
  1078. }
  1079. } else {
  1080. return true;
  1081. }
  1082. }, this);
  1083. //add user properties
  1084. Em.keys(configsMap).forEach(function (filename) {
  1085. Em.keys(configsMap[filename]).forEach(function (propertyName) {
  1086. allConfigs.push(App.config.createDefaultConfig(propertyName,
  1087. App.config.getServiceByConfigType(filename) ? App.config.getServiceByConfigType(filename).get('serviceName') : 'MISC',
  1088. App.config.getOriginalFileName(filename),
  1089. false, {
  1090. value: configsMap[filename][propertyName],
  1091. savedValue: configsMap[filename][propertyName],
  1092. hasInitialValue: true
  1093. }));
  1094. });
  1095. });
  1096. return allConfigs;
  1097. },
  1098. /**
  1099. * update dependencies according to current config value
  1100. *
  1101. * @param config
  1102. */
  1103. updateDependencies: function(config) {
  1104. if (config.name === 'hive.metastore.uris' && config.filename === 'hive-site.xml') {
  1105. this.get('configDependencies')['hive.metastore.uris'] = config.savedValue;
  1106. } else if (config.name === 'clientPort' && config.filename === 'hive-site.xml') {
  1107. this.get('configDependencies')['clientPort'] = config.savedValue;
  1108. }
  1109. },
  1110. /**
  1111. * Add group ids to <code>groupsToDelete</code>
  1112. * Also save <code>groupsToDelete</code> to local storage
  1113. * @param {Ember.Object[]} groups
  1114. * @method setGroupsToDelete
  1115. */
  1116. setGroupsToDelete: function (groups) {
  1117. var groupsToDelete = this.get('groupsToDelete');
  1118. groups.forEach(function (group) {
  1119. if (group.get('id'))
  1120. groupsToDelete.push({
  1121. id: group.get('id')
  1122. });
  1123. });
  1124. this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
  1125. },
  1126. /**
  1127. * Update <code>configGroups</code> with selected service configGroups
  1128. * Also set default group to first position
  1129. * Update <code>selectedConfigGroup</code> with new default group
  1130. * @method selectedServiceObserver
  1131. */
  1132. selectedServiceObserver: function () {
  1133. if (this.get('selectedService') && (this.get('selectedService.serviceName') !== 'MISC')) {
  1134. var serviceGroups = this.get('selectedService.configGroups');
  1135. serviceGroups.forEach(function (item, index, array) {
  1136. if (item.isDefault) {
  1137. array.unshift(item);
  1138. array.splice(index + 1, 1);
  1139. }
  1140. });
  1141. this.set('configGroups', serviceGroups);
  1142. this.set('selectedConfigGroup', serviceGroups.findProperty('isDefault'));
  1143. }
  1144. }.observes('selectedService.configGroups.@each'),
  1145. /**
  1146. * load default groups for each service in case of initial load
  1147. * @param serviceConfigGroups
  1148. * @method loadConfigGroups
  1149. */
  1150. loadConfigGroups: function (serviceConfigGroups) {
  1151. var services = this.get('stepConfigs');
  1152. var hosts = this.get('wizardController.allHosts').mapProperty('hostName');
  1153. services.forEach(function (service) {
  1154. if (service.get('serviceName') === 'MISC') return;
  1155. var serviceRawGroups = serviceConfigGroups.filterProperty('service_name', service.serviceName);
  1156. var id = App.ServiceConfigGroup.getParentConfigGroupId(service.get('serviceName'));
  1157. if (!serviceRawGroups.length) {
  1158. App.store.load(App.ServiceConfigGroup, App.configGroupsMapper.generateDefaultGroup(service.get('serviceName'), hosts));
  1159. App.store.commit();
  1160. service.set('configGroups', [App.ServiceConfigGroup.find(id)]);
  1161. }
  1162. else {
  1163. App.store.loadMany(App.ServiceConfigGroup, serviceRawGroups);
  1164. App.store.commit();
  1165. serviceRawGroups.forEach(function(item){
  1166. var modelGroup = App.ServiceConfigGroup.find(item.id);
  1167. var wrappedProperties = [];
  1168. item.properties.forEach(function (propertyData) {
  1169. var parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name', propertyData.name);
  1170. var overriddenSCP = App.ServiceConfigProperty.create(parentSCP);
  1171. overriddenSCP.set('isOriginalSCP', false);
  1172. overriddenSCP.set('parentSCP', parentSCP);
  1173. overriddenSCP.set('group', modelGroup);
  1174. overriddenSCP.setProperties(propertyData);
  1175. wrappedProperties.pushObject(App.ServiceConfigProperty.create(overriddenSCP));
  1176. });
  1177. modelGroup.set('properties', wrappedProperties);
  1178. }, this);
  1179. service.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName', service.get('serviceName')));
  1180. }
  1181. });
  1182. },
  1183. /**
  1184. * Click-handler on config-group to make it selected
  1185. * @param {object} event
  1186. * @method selectConfigGroup
  1187. */
  1188. selectConfigGroup: function (event) {
  1189. this.set('selectedConfigGroup', event.context);
  1190. },
  1191. /**
  1192. * Rebuild list of configs switch of config group:
  1193. * on default - display all configs from default group and configs from non-default groups as disabled
  1194. * on non-default - display all from default group as disabled and configs from selected non-default group
  1195. * @method switchConfigGroupConfigs
  1196. */
  1197. switchConfigGroupConfigs: function () {
  1198. var serviceConfigs = this.get('selectedService.configs'),
  1199. selectedGroup = this.get('selectedConfigGroup'),
  1200. overrideToAdd = this.get('overrideToAdd'),
  1201. overrides = [];
  1202. if (!selectedGroup) return;
  1203. var displayedConfigGroups = this._getDisplayedConfigGroups();
  1204. displayedConfigGroups.forEach(function (group) {
  1205. overrides.pushObjects(group.get('properties'));
  1206. });
  1207. serviceConfigs.forEach(function (config) {
  1208. this._setEditableValue(config);
  1209. this._setOverrides(config, overrides);
  1210. }, this);
  1211. }.observes('selectedConfigGroup'),
  1212. /**
  1213. * Get list of config groups to display
  1214. * Returns empty array if no <code>selectedConfigGroup</code>
  1215. * @return {Array}
  1216. * @method _getDisplayedConfigGroups
  1217. */
  1218. _getDisplayedConfigGroups: function () {
  1219. var selectedGroup = this.get('selectedConfigGroup');
  1220. if (!selectedGroup) return [];
  1221. return (selectedGroup.get('isDefault')) ?
  1222. this.get('selectedService.configGroups').filterProperty('isDefault', false) :
  1223. [this.get('selectedConfigGroup')];
  1224. },
  1225. /**
  1226. * Set <code>isEditable</code> property to <code>config</code>
  1227. * @param {Ember.Object} config
  1228. * @return {Ember.Object} updated config-object
  1229. * @method _setEditableValue
  1230. */
  1231. _setEditableValue: function (config) {
  1232. var selectedGroup = this.get('selectedConfigGroup');
  1233. if (!selectedGroup) return config;
  1234. var isEditable = config.get('isEditable'),
  1235. isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName'));
  1236. if (isServiceInstalled) {
  1237. isEditable = (!isEditable && !config.get('isReconfigurable')) ? false : selectedGroup.get('isDefault');
  1238. }
  1239. else {
  1240. isEditable = selectedGroup.get('isDefault');
  1241. }
  1242. if (config.get('group')) {
  1243. isEditable = config.get('group.name') == this.get('selectedConfigGroup.name');
  1244. }
  1245. config.set('isEditable', isEditable);
  1246. return config;
  1247. },
  1248. /**
  1249. * Set <code>overrides</code> property to <code>config</code>
  1250. * @param {Ember.Object} config
  1251. * @param {Ember.Enumerable} overrides
  1252. * @returns {Ember.Object}
  1253. * @method _setOverrides
  1254. */
  1255. _setOverrides: function (config, overrides) {
  1256. var selectedGroup = this.get('selectedConfigGroup'),
  1257. overrideToAdd = this.get('overrideToAdd'),
  1258. configOverrides = overrides.filterProperty('name', config.get('name'));
  1259. if (!selectedGroup) return config;
  1260. if (overrideToAdd && overrideToAdd.get('name') === config.get('name')) {
  1261. var valueForOverride = (config.get('widget') || config.get('displayType') == 'checkbox') ? config.get('value') : '';
  1262. var group = this.get('selectedService.configGroups').findProperty('name', selectedGroup.get('name'));
  1263. var newSCP = App.config.createOverride(config, {value: valueForOverride, recommendedValue: valueForOverride}, group);
  1264. configOverrides.push(newSCP);
  1265. group.get('properties').pushObject(newSCP);
  1266. this.set('overrideToAdd', null);
  1267. }
  1268. configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
  1269. configOverrides.setEach('parentSCP', config);
  1270. config.set('overrides', configOverrides);
  1271. return config;
  1272. },
  1273. /**
  1274. * @param serviceName
  1275. * @returns {boolean}
  1276. * @override
  1277. */
  1278. useInitialValue: function(serviceName) {
  1279. return !App.Service.find(serviceName).get('serviceName', serviceName);
  1280. },
  1281. /**
  1282. *
  1283. * @param parentProperties
  1284. * @param name
  1285. * @param fileName
  1286. * @returns {*}
  1287. * @override
  1288. */
  1289. allowUpdateProperty: function(parentProperties, name, fileName) {
  1290. if (['installerController'].contains(this.get('wizardController.name')) || !!(parentProperties && parentProperties.length)) {
  1291. return true;
  1292. } else if (['addServiceController'].contains(this.get('wizardController.name'))) {
  1293. var stackProperty = App.configsCollection.getConfigByName(name, fileName);
  1294. if (!stackProperty || !this.get('installedServices')[stackProperty.serviceName]) {
  1295. return true;
  1296. } else if (stackProperty.propertyDependsOn.length) {
  1297. return !!stackProperty.propertyDependsOn.filter(function (p) {
  1298. var service = App.config.getServiceByConfigType(p.type);
  1299. return service && !this.get('installedServices')[service.get('serviceName')];
  1300. }, this).length;
  1301. } else {
  1302. return false;
  1303. }
  1304. }
  1305. return true;
  1306. },
  1307. /**
  1308. * remove config based on recommendations
  1309. * @param config
  1310. * @param configsCollection
  1311. * @param parentProperties
  1312. * @protected
  1313. * @override
  1314. */
  1315. _removeConfigByRecommendation: function (config, configsCollection, parentProperties) {
  1316. this._super(config, configsCollection, parentProperties);
  1317. /**
  1318. * need to update wizard info when removing configs for installed services;
  1319. */
  1320. var installedServices = this.get('installedServices'), wizardController = this.get('wizardController'),
  1321. fileNamesToUpdate = wizardController ? wizardController.getDBProperty('fileNamesToUpdate') || [] : [],
  1322. fileName = Em.get(config, 'filename'), serviceName = Em.get(config, 'serviceName');
  1323. var modifiedFileNames = this.get('modifiedFileNames');
  1324. if (modifiedFileNames && !modifiedFileNames.contains(fileName)) {
  1325. modifiedFileNames.push(fileName);
  1326. } else if (wizardController && installedServices[serviceName]) {
  1327. if (!fileNamesToUpdate.contains(fileName)) {
  1328. fileNamesToUpdate.push(fileName);
  1329. }
  1330. }
  1331. if (wizardController) {
  1332. wizardController.setDBProperty('fileNamesToUpdate', fileNamesToUpdate.uniq());
  1333. }
  1334. },
  1335. /**
  1336. * @method manageConfigurationGroup
  1337. */
  1338. manageConfigurationGroup: function () {
  1339. App.router.get('manageConfigGroupsController').manageConfigurationGroups(this);
  1340. },
  1341. /**
  1342. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1343. * @return {$.ajax|null}
  1344. * @method checkMySQLHost
  1345. */
  1346. checkMySQLHost: function () {
  1347. // get ambari database type and hostname
  1348. return App.ajax.send({
  1349. name: 'ambari.service',
  1350. data: {
  1351. fields : "?fields=hostComponents/RootServiceHostComponents/properties/server.jdbc.database_name,hostComponents/RootServiceHostComponents/properties/server.jdbc.url"
  1352. },
  1353. sender: this,
  1354. success: 'getAmbariDatabaseSuccess'
  1355. });
  1356. },
  1357. /**
  1358. * Success callback for ambari database, get Ambari DB type and DB server hostname, then
  1359. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1360. * @param {object} data
  1361. * @method getAmbariDatabaseSuccess
  1362. */
  1363. getAmbariDatabaseSuccess: function (data) {
  1364. var hiveDBHostname = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_hostname').value;
  1365. var ambariServiceHostComponents = data.hostComponents;
  1366. if (ambariServiceHostComponents.length) {
  1367. var ambariDBInfo = JSON.stringify(ambariServiceHostComponents[0].RootServiceHostComponents.properties);
  1368. this.set('mySQLServerConflict', ambariDBInfo.contains('mysql') && ambariDBInfo.indexOf(hiveDBHostname) > 0);
  1369. } else {
  1370. this.set('mySQLServerConflict', false);
  1371. }
  1372. },
  1373. /**
  1374. * Check if new MySql database was chosen for Hive service
  1375. * and it is not located on the same host as Ambari server
  1376. * that using MySql database too.
  1377. *
  1378. * @method resolveHiveMysqlDatabase
  1379. **/
  1380. resolveHiveMysqlDatabase: function () {
  1381. var hiveService = this.get('content.services').findProperty('serviceName', 'HIVE');
  1382. if (!hiveService || !hiveService.get('isSelected') || hiveService.get('isInstalled')) {
  1383. this.moveNext();
  1384. return;
  1385. }
  1386. var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_database').value;
  1387. if (hiveDBType == 'New MySQL Database') {
  1388. var self = this;
  1389. return this.checkMySQLHost().done(function () {
  1390. self.mySQLWarningHandler();
  1391. });
  1392. }
  1393. else {
  1394. this.moveNext();
  1395. }
  1396. },
  1397. /**
  1398. * Show warning popup about MySQL-DB issues (on post-submit)
  1399. *
  1400. * @returns {*}
  1401. * @method mySQLWarningHandler
  1402. */
  1403. mySQLWarningHandler: function () {
  1404. var self = this;
  1405. if (this.get('mySQLServerConflict')) {
  1406. // error popup before you can proceed
  1407. return App.ModalPopup.show({
  1408. header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
  1409. body:Em.I18n.t('installer.step7.popup.mySQLWarning.body'),
  1410. secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
  1411. primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
  1412. encodeBody: false,
  1413. onPrimary: function () {
  1414. this._super();
  1415. self.set('submitButtonClicked', false);
  1416. },
  1417. onSecondary: function () {
  1418. var parent = this;
  1419. return App.ModalPopup.show({
  1420. header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
  1421. body: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'),
  1422. onPrimary: function () {
  1423. this.hide();
  1424. parent.hide();
  1425. // go back to step 5: assign masters and disable default navigation warning
  1426. if ('installerController' === self.get('content.controllerName')) {
  1427. App.router.get('installerController').gotoStep(5, true);
  1428. }
  1429. else {
  1430. if ('addServiceController' === self.get('content.controllerName')) {
  1431. App.router.get('addServiceController').gotoStep(2, true);
  1432. }
  1433. }
  1434. },
  1435. onSecondary: function () {
  1436. this._super();
  1437. self.set('submitButtonClicked', false);
  1438. }
  1439. });
  1440. }
  1441. });
  1442. }
  1443. else {
  1444. return this.moveNext();
  1445. }
  1446. },
  1447. checkDatabaseConnectionTest: function () {
  1448. var deferred = $.Deferred();
  1449. var configMap = [
  1450. {
  1451. serviceName: 'OOZIE',
  1452. ignored: [Em.I18n.t('installer.step7.oozie.database.new')]
  1453. },
  1454. {
  1455. serviceName: 'HIVE',
  1456. ignored: [Em.I18n.t('installer.step7.hive.database.new.mysql'), Em.I18n.t('installer.step7.hive.database.new.postgres')]
  1457. }
  1458. ];
  1459. configMap.forEach(function (config) {
  1460. var isConnectionNotTested = false;
  1461. var service = this.get('content.services').findProperty('serviceName', config.serviceName);
  1462. if (service && service.get('isSelected') && !service.get('isInstalled')) {
  1463. var serviceConfigs = this.get('stepConfigs').findProperty('serviceName', config.serviceName).configs;
  1464. var serviceDatabase = serviceConfigs.findProperty('name', config.serviceName.toLowerCase() + '_database').get('value');
  1465. if (!config.ignored.contains(serviceDatabase)) {
  1466. var filledProperties = App.db.get('tmp', config.serviceName + '_connection');
  1467. if (!filledProperties || App.isEmptyObject(filledProperties)) {
  1468. isConnectionNotTested = true;
  1469. } else {
  1470. for (var key in filledProperties) {
  1471. if (serviceConfigs.findProperty('name', key).get('value') !== filledProperties[key])
  1472. isConnectionNotTested = true;
  1473. }
  1474. }
  1475. }
  1476. }
  1477. config.isCheckIgnored = isConnectionNotTested;
  1478. }, this);
  1479. var ignoredServices = configMap.filterProperty('isCheckIgnored', true);
  1480. if (ignoredServices.length) {
  1481. var displayedServiceNames = ignoredServices.mapProperty('serviceName').map(function (serviceName) {
  1482. return this.get('content.services').findProperty('serviceName', serviceName).get('displayName');
  1483. }, this);
  1484. this.showDatabaseConnectionWarningPopup(displayedServiceNames, deferred);
  1485. }
  1486. else {
  1487. deferred.resolve();
  1488. }
  1489. return deferred;
  1490. },
  1491. showChangesWarningPopup: function(goToNextStep) {
  1492. return App.ModalPopup.show({
  1493. header: Em.I18n.t('common.warning'),
  1494. body: Em.I18n.t('services.service.config.exitChangesPopup.body'),
  1495. secondary: Em.I18n.t('common.cancel'),
  1496. primary: Em.I18n.t('yes'),
  1497. onPrimary: function () {
  1498. if (goToNextStep) {
  1499. goToNextStep();
  1500. this.hide();
  1501. }
  1502. },
  1503. onSecondary: function () {
  1504. this.hide();
  1505. }
  1506. });
  1507. },
  1508. showDatabaseConnectionWarningPopup: function (serviceNames, deferred) {
  1509. var self = this;
  1510. return App.ModalPopup.show({
  1511. header: Em.I18n.t('installer.step7.popup.database.connection.header'),
  1512. body: Em.I18n.t('installer.step7.popup.database.connection.body').format(serviceNames.join(', ')),
  1513. secondary: Em.I18n.t('common.cancel'),
  1514. primary: Em.I18n.t('common.proceedAnyway'),
  1515. onPrimary: function () {
  1516. deferred.resolve();
  1517. this._super();
  1518. },
  1519. onSecondary: function () {
  1520. self.set('submitButtonClicked', false);
  1521. deferred.reject();
  1522. this._super();
  1523. }
  1524. });
  1525. },
  1526. showOozieDerbyWarningPopup: function(callback) {
  1527. var self = this;
  1528. if (this.get('selectedServiceNames').contains('OOZIE')) {
  1529. var databaseType = Em.getWithDefault(App.config.findConfigProperty(this.get('stepConfigs'), 'oozie_database', 'oozie-env.xml') || {}, 'value', '');
  1530. if (databaseType == Em.I18n.t('installer.step7.oozie.database.new')) {
  1531. return App.ModalPopup.show({
  1532. header: Em.I18n.t('common.warning'),
  1533. body: Em.I18n.t('installer.step7.popup.oozie.derby.warning'),
  1534. secondary: Em.I18n.t('common.cancel'),
  1535. primary: Em.I18n.t('common.proceedAnyway'),
  1536. onPrimary: function() {
  1537. this.hide();
  1538. if (callback) {
  1539. callback();
  1540. }
  1541. },
  1542. onSecondary: function() {
  1543. self.set('submitButtonClicked', false);
  1544. this.hide();
  1545. },
  1546. onClose: function() {
  1547. this.onSecondary();
  1548. }
  1549. });
  1550. }
  1551. }
  1552. if (callback) {
  1553. callback();
  1554. }
  1555. return false;
  1556. },
  1557. /**
  1558. * Proceed to the next step
  1559. **/
  1560. moveNext: function () {
  1561. App.router.send('next');
  1562. this.set('submitButtonClicked', false);
  1563. },
  1564. /**
  1565. * Click-handler on Next button
  1566. * Disable "Submit"-button while server-side processes are running
  1567. * @method submit
  1568. */
  1569. submit: function () {
  1570. if (this.get('isSubmitDisabled')) {
  1571. return false;
  1572. }
  1573. var preInstallChecksController = App.router.get('preInstallChecksController');
  1574. if (this.get('supportsPreInstallChecks')) {
  1575. if (preInstallChecksController.get('preInstallChecksWhereRun')) {
  1576. return this.postSubmit();
  1577. }
  1578. return preInstallChecksController.notRunChecksWarnPopup(this.postSubmit.bind(this));
  1579. }
  1580. return this.postSubmit();
  1581. },
  1582. postSubmit: function () {
  1583. var self = this;
  1584. this.set('submitButtonClicked', true);
  1585. this.serverSideValidation().done(function() {
  1586. self.serverSideValidationCallback();
  1587. })
  1588. .fail(function (value) {
  1589. if ("invalid_configs" == value) {
  1590. self.set('submitButtonClicked', false);
  1591. } else {
  1592. // Failed due to validation mechanism failure.
  1593. // Should proceed with other checks
  1594. self.serverSideValidationCallback();
  1595. }
  1596. });
  1597. },
  1598. /**
  1599. * @method serverSideValidationCallback
  1600. */
  1601. serverSideValidationCallback: function() {
  1602. var self = this;
  1603. this.showOozieDerbyWarningPopup(function() {
  1604. self.checkDatabaseConnectionTest().done(function () {
  1605. self.resolveHiveMysqlDatabase();
  1606. });
  1607. });
  1608. },
  1609. toggleIssuesFilter: function () {
  1610. this.get('filterColumns').findProperty('attributeName', 'hasIssues').toggleProperty('selected');
  1611. // if currently selected service does not have issue, jump to the first service with issue.
  1612. if (this.get('selectedService.errorCount') == 0 )
  1613. {
  1614. var errorServices = this.get('stepConfigs').filterProperty('errorCount');
  1615. if (errorServices.length > 0)
  1616. {
  1617. var service = errorServices[0];
  1618. this.set('selectedService', service);
  1619. $('a[href="#' + service.serviceName + '"]').tab('show');
  1620. }
  1621. }
  1622. }
  1623. });