step7_controller.js 56 KB

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