step7_controller.js 56 KB

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