step7_controller.js 56 KB

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