step7_controller.js 56 KB

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