step7_controller.js 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347
  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. App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.EnhancedConfigsMixin, {
  29. name: 'wizardStep7Controller',
  30. /**
  31. * Contains all field properties that are viewed in this step
  32. * @type {object[]}
  33. */
  34. stepConfigs: [],
  35. selectedService: null,
  36. slaveHostToGroup: null,
  37. addMiscTabToPage: true,
  38. /**
  39. * Is Submit-click processing now
  40. * @type {bool}
  41. */
  42. submitButtonClicked: false,
  43. isRecommendedLoaded: false,
  44. /**
  45. * used in services_config.js view to mark a config with security icon
  46. */
  47. secureConfigs: require('data/HDP2/secure_mapping'),
  48. /**
  49. * config categories with secure properties
  50. * use only for add service wizard when security is enabled;
  51. */
  52. secureServices: function () {
  53. return $.extend(true, [], require('data/HDP2/secure_configs'));
  54. }.property(),
  55. /**
  56. * uses for add service - find out is security is enabled
  57. */
  58. securityEnabled: function () {
  59. return App.router.get('mainAdminKerberosController.securityEnabled');
  60. }.property('App.router.mainAdminKerberosController.securityEnabled'),
  61. /**
  62. * If configChangeObserver Modal is shown
  63. * @type {bool}
  64. */
  65. miscModalVisible: false,
  66. overrideToAdd: null,
  67. /**
  68. * Is installer controller used
  69. * @type {bool}
  70. */
  71. isInstaller: true,
  72. /**
  73. * List of config groups
  74. * @type {object[]}
  75. */
  76. configGroups: [],
  77. /**
  78. * List of config group to be deleted
  79. * @type {object[]}
  80. */
  81. groupsToDelete: [],
  82. preSelectedConfigGroup: null,
  83. /**
  84. * Currently selected config group
  85. * @type {object}
  86. */
  87. selectedConfigGroup: null,
  88. /**
  89. * Config tags of actually installed services
  90. * @type {array}
  91. */
  92. serviceConfigTags: [],
  93. /**
  94. * Are advanced configs loaded
  95. * @type {bool}
  96. */
  97. isAdvancedConfigLoaded: true,
  98. /**
  99. * Are applied to service configs loaded
  100. * @type {bool}
  101. */
  102. isAppliedConfigLoaded: true,
  103. isConfigsLoaded: function () {
  104. return (this.get('isAdvancedConfigLoaded') && this.get('isAppliedConfigLoaded'));
  105. }.property('isAdvancedConfigLoaded', 'isAppliedConfigLoaded'),
  106. /**
  107. * Number of errors in the configs in the selected service
  108. * @type {number}
  109. */
  110. errorsCount: function () {
  111. return this.get('selectedService.configs').filter(function (config) {
  112. return Em.isNone(config.get('widget'));
  113. }).filterProperty('isValid', false).filterProperty('isVisible').length;
  114. }.property('selectedService.configs.@each.isValid'),
  115. /**
  116. * Should Next-button be disabled
  117. * @type {bool}
  118. */
  119. isSubmitDisabled: function () {
  120. if (!this.get('stepConfigs.length')) return true;
  121. if (this.get('submitButtonClicked')) return true;
  122. return (!this.get('stepConfigs').filterProperty('showConfig', true).everyProperty('errorCount', 0) || this.get("miscModalVisible"));
  123. }.property('stepConfigs.@each.errorCount', 'miscModalVisible', 'submitButtonClicked'),
  124. /**
  125. * List of selected to install service names
  126. * @type {string[]}
  127. */
  128. selectedServiceNames: function () {
  129. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).mapProperty('serviceName');
  130. }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
  131. /**
  132. * List of installed and selected to install service names
  133. * @type {string[]}
  134. */
  135. allSelectedServiceNames: function () {
  136. return this.get('content.services').filter(function (service) {
  137. return service.get('isInstalled') || service.get('isSelected');
  138. }).mapProperty('serviceName');
  139. }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
  140. /**
  141. * List of installed service names
  142. * @type {string[]}
  143. */
  144. installedServiceNames: function () {
  145. var serviceNames = this.get('content.services').filterProperty('isInstalled').mapProperty('serviceName');
  146. if (this.get('content.controllerName') !== 'installerController') {
  147. serviceNames = serviceNames.filter(function (_serviceName) {
  148. return !App.get('services.noConfigTypes').contains(_serviceName);
  149. });
  150. }
  151. return serviceNames;
  152. }.property('content.services').cacheable(),
  153. /**
  154. * List of master components
  155. * @type {Ember.Enumerable}
  156. */
  157. masterComponentHosts: function () {
  158. return this.get('content.masterComponentHosts');
  159. }.property('content.masterComponentHosts'),
  160. /**
  161. * List of slave components
  162. * @type {Ember.Enumerable}
  163. */
  164. slaveComponentHosts: function () {
  165. return this.get('content.slaveGroupProperties');
  166. }.property('content.slaveGroupProperties', 'content.slaveComponentHosts'),
  167. customData: [],
  168. /**
  169. * Filter text will be located here
  170. * @type {string}
  171. */
  172. filter: '',
  173. /**
  174. * List of filters for config properties to populate filter combobox
  175. */
  176. propertyFilters: [
  177. {
  178. attributeName: 'isOverridden',
  179. attributeValue: true,
  180. caption: 'common.combobox.dropdown.overridden'
  181. },
  182. {
  183. attributeName: 'isFinal',
  184. attributeValue: true,
  185. caption: 'common.combobox.dropdown.final'
  186. },
  187. {
  188. attributeName: 'hasIssues',
  189. attributeValue: true,
  190. caption: 'common.combobox.dropdown.issues'
  191. }
  192. ],
  193. issuesFilterText: function () {
  194. return (this.get('isSubmitDisabled') && !this.get('submitButtonClicked') &&
  195. this.get('filterColumns').findProperty('attributeName', 'hasIssues').get('selected')) ?
  196. Em.I18n.t('installer.step7.showingPropertiesWithIssues') : '';
  197. }.property('isSubmitDisabled', 'submitButtonClicked', 'filterColumns.@each.selected'),
  198. issuesFilterLinkText: function () {
  199. if (this.get('filterColumns').findProperty('attributeName', 'hasIssues').get('selected')) {
  200. return Em.I18n.t('installer.step7.showAllProperties');
  201. }
  202. return (this.get('isSubmitDisabled') && !this.get('submitButtonClicked')) ?
  203. (
  204. this.get('filterColumns').findProperty('attributeName', 'hasIssues').get('selected') ?
  205. Em.I18n.t('installer.step7.showAllProperties') : Em.I18n.t('installer.step7.showPropertiesWithIssues')
  206. ) : '';
  207. }.property('isSubmitDisabled', 'submitButtonClicked', 'filterColumns.@each.selected'),
  208. /**
  209. * Dropdown menu items in filter combobox
  210. */
  211. filterColumns: function () {
  212. return this.get('propertyFilters').map(function (filter) {
  213. return Ember.Object.create({
  214. attributeName: filter.attributeName,
  215. attributeValue: filter.attributeValue,
  216. name: this.t(filter.caption),
  217. selected: false
  218. });
  219. }, this);
  220. }.property('propertyFilters'),
  221. /**
  222. * Clear controller's properties:
  223. * <ul>
  224. * <li>stepConfigs</li>
  225. * <li>filter</li>
  226. * </ul>
  227. * and desect all <code>filterColumns</code>
  228. * @method clearStep
  229. */
  230. clearStep: function () {
  231. this.setProperties({
  232. configValidationGlobalMessage: [],
  233. submitButtonClicked: false,
  234. isSubmitDisabled: true,
  235. isRecommendedLoaded: false
  236. });
  237. this.get('stepConfigs').clear();
  238. this.set('filter', '');
  239. this.get('filterColumns').setEach('selected', false);
  240. },
  241. /**
  242. * Load config groups for installed services
  243. * One ajax-request for each service
  244. * @param {string[]} servicesNames
  245. * @method loadInstalledServicesConfigGroups
  246. */
  247. loadInstalledServicesConfigGroups: function (servicesNames) {
  248. servicesNames.forEach(function (serviceName) {
  249. App.ajax.send({
  250. name: 'config.tags_and_groups',
  251. sender: this,
  252. data: {
  253. serviceName: serviceName,
  254. serviceConfigsDef: App.config.get('preDefinedServiceConfigs').findProperty('serviceName', serviceName)
  255. },
  256. success: 'loadServiceTagsSuccess'
  257. });
  258. }, this);
  259. },
  260. /**
  261. * Create site to tag map. Format:
  262. * <code>
  263. * {
  264. * site1: tag1,
  265. * site1: tag2,
  266. * site2: tag3
  267. * ...
  268. * }
  269. * </code>
  270. * @param {object} desired_configs
  271. * @param {string[]} sites
  272. * @returns {object}
  273. * @private
  274. * @method _createSiteToTagMap
  275. */
  276. _createSiteToTagMap: function (desired_configs, sites) {
  277. var siteToTagMap = {};
  278. for (var site in desired_configs) {
  279. if (desired_configs.hasOwnProperty(site)) {
  280. if (!!sites[site]) {
  281. siteToTagMap[site] = desired_configs[site].tag;
  282. }
  283. }
  284. }
  285. return siteToTagMap;
  286. },
  287. /**
  288. * Load config groups success callback
  289. * @param {object} data
  290. * @param {object} opt
  291. * @param {object} params
  292. * @method loadServiceTagsSuccess
  293. */
  294. loadServiceTagsSuccess: function (data, opt, params) {
  295. var serviceName = params.serviceName,
  296. service = this.get('stepConfigs').findProperty('serviceName', serviceName),
  297. defaultConfigGroupHosts = this.get('wizardController.allHosts').mapProperty('hostName'),
  298. siteToTagMap = this._createSiteToTagMap(data.Clusters.desired_configs, params.serviceConfigsDef.get('configTypes')),
  299. selectedConfigGroup;
  300. this.set('loadedClusterSiteToTagMap', siteToTagMap);
  301. //parse loaded config groups
  302. var configGroups = [];
  303. if (data.config_groups.length) {
  304. data.config_groups.forEach(function (item) {
  305. item = item.ConfigGroup;
  306. if (item.tag === serviceName) {
  307. var groupHosts = item.hosts.mapProperty('host_name');
  308. var newConfigGroup = App.ConfigGroup.create({
  309. id: item.id,
  310. name: item.group_name,
  311. description: item.description,
  312. isDefault: false,
  313. parentConfigGroup: null,
  314. service: App.Service.find().findProperty('serviceName', item.tag),
  315. hosts: groupHosts,
  316. configSiteTags: []
  317. });
  318. groupHosts.forEach(function (host) {
  319. defaultConfigGroupHosts = defaultConfigGroupHosts.without(host);
  320. }, this);
  321. item.desired_configs.forEach(function (config) {
  322. newConfigGroup.configSiteTags.push(App.ConfigSiteTag.create({
  323. site: config.type,
  324. tag: config.tag
  325. }));
  326. }, this);
  327. configGroups.push(newConfigGroup);
  328. }
  329. }, this);
  330. }
  331. var defaultConfigGroup = App.ConfigGroup.create({
  332. name: App.format.role(serviceName) + " Default",
  333. description: "Default cluster level " + serviceName + " configuration",
  334. isDefault: true,
  335. hosts: defaultConfigGroupHosts,
  336. parentConfigGroup: null,
  337. service: Em.Object.create({
  338. id: serviceName
  339. }),
  340. serviceName: serviceName,
  341. configSiteTags: []
  342. });
  343. if (!selectedConfigGroup) {
  344. selectedConfigGroup = defaultConfigGroup;
  345. }
  346. configGroups = configGroups.sortProperty('name');
  347. configGroups.unshift(defaultConfigGroup);
  348. service.set('configGroups', configGroups);
  349. var loadedGroupToOverrideSiteToTagMap = {};
  350. var configGroupsWithOverrides = selectedConfigGroup.get('isDefault') ? service.get('configGroups') : [selectedConfigGroup];
  351. configGroupsWithOverrides.forEach(function (item) {
  352. var groupName = item.get('name');
  353. loadedGroupToOverrideSiteToTagMap[groupName] = {};
  354. item.get('configSiteTags').forEach(function (siteTag) {
  355. var site = siteTag.get('site');
  356. loadedGroupToOverrideSiteToTagMap[groupName][site] = siteTag.get('tag');
  357. }, this);
  358. }, this);
  359. this.set('preSelectedConfigGroup', selectedConfigGroup);
  360. App.config.loadServiceConfigGroupOverrides(service.get('configs'), loadedGroupToOverrideSiteToTagMap, service.get('configGroups'), this.onLoadOverrides, this);
  361. },
  362. onLoadOverrides: function (configs) {
  363. var serviceName = configs[0].serviceName,
  364. service = this.get('stepConfigs').findProperty('serviceName', serviceName);
  365. var serviceConfig = App.config.createServiceConfig(serviceName);
  366. if (serviceConfig.get('serviceName') === 'HDFS') {
  367. App.config.OnNnHAHideSnn(serviceConfig);
  368. }
  369. service.set('selectedConfigGroup', this.get('preSelectedConfigGroup'));
  370. this.loadComponentConfigs(service.get('configs'), serviceConfig, service);
  371. service.set('configs', serviceConfig.get('configs'));
  372. },
  373. /**
  374. * Set <code>isEditable</code>-property to <code>serviceConfigProperty</code>
  375. * Based on user's permissions and selected config group
  376. * @param {Ember.Object} serviceConfigProperty
  377. * @param {bool} defaultGroupSelected
  378. * @returns {Ember.Object} Updated config-object
  379. * @method _updateIsEditableFlagForConfig
  380. */
  381. _updateIsEditableFlagForConfig: function (serviceConfigProperty, defaultGroupSelected) {
  382. if (App.isAccessible('ADMIN')) {
  383. if (defaultGroupSelected && !this.get('isHostsConfigsPage') && !Em.get(serviceConfigProperty, 'group')) {
  384. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  385. } else if (Em.get(serviceConfigProperty, 'group') && Em.get(serviceConfigProperty, 'group.name') == this.get('selectedConfigGroup.name')) {
  386. serviceConfigProperty.set('isEditable', true);
  387. } else {
  388. serviceConfigProperty.set('isEditable', false);
  389. }
  390. }
  391. else {
  392. serviceConfigProperty.set('isEditable', false);
  393. }
  394. return serviceConfigProperty;
  395. },
  396. /**
  397. * Set <code>overrides</code>-property to <code>serviceConfigProperty<code>
  398. * @param {Ember.Object} serviceConfigProperty
  399. * @param {Ember.Object} component
  400. * @return {Ember.Object} Updated config-object
  401. * @method _updateOverridesForConfig
  402. */
  403. _updateOverridesForConfig: function (serviceConfigProperty, component) {
  404. var overrides = serviceConfigProperty.get('overrides');
  405. if (Em.isNone(overrides)) {
  406. serviceConfigProperty.set('overrides', Em.A([]));
  407. return serviceConfigProperty;
  408. }
  409. serviceConfigProperty.set('overrides', null);
  410. var defaultGroupSelected = component.get('selectedConfigGroup.isDefault');
  411. // Wrap each override to App.ServiceConfigProperty
  412. overrides.forEach(function (override) {
  413. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  414. newSCP.set('value', override.value);
  415. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  416. newSCP.set('parentSCP', serviceConfigProperty);
  417. if (defaultGroupSelected) {
  418. var group = component.get('configGroups').findProperty('name', override.group.get('name'));
  419. // prevent cycle in proto object, clean link
  420. if (group.get('properties').length == 0) {
  421. group.set('properties', Em.A([]));
  422. }
  423. group.get('properties').push(newSCP);
  424. newSCP.set('group', override.group);
  425. newSCP.set('isEditable', false);
  426. }
  427. var parentOverridesArray = serviceConfigProperty.get('overrides');
  428. if (Em.isNone(parentOverridesArray)) {
  429. parentOverridesArray = Em.A([]);
  430. serviceConfigProperty.set('overrides', parentOverridesArray);
  431. }
  432. serviceConfigProperty.get('overrides').pushObject(newSCP);
  433. }, this);
  434. return serviceConfigProperty;
  435. },
  436. /**
  437. * Set configs with overrides, recommended defaults to component
  438. * @param {Ember.Object[]} configs
  439. * @param {Ember.Object} componentConfig
  440. * @param {Ember.Object} component
  441. * @method loadComponentConfigs
  442. */
  443. loadComponentConfigs: function (configs, componentConfig, component) {
  444. var defaultGroupSelected = component.get('selectedConfigGroup.isDefault');
  445. configs.forEach(function (serviceConfigProperty) {
  446. if (!serviceConfigProperty) return;
  447. if (Em.isNone(serviceConfigProperty.get('isOverridable'))) {
  448. serviceConfigProperty.set('isOverridable', true);
  449. }
  450. this._updateOverridesForConfig(serviceConfigProperty, component);
  451. this._updateIsEditableFlagForConfig(serviceConfigProperty, defaultGroupSelected);
  452. componentConfig.get('configs').pushObject(serviceConfigProperty);
  453. serviceConfigProperty.validate();
  454. }, this);
  455. component.get('configGroups').filterProperty('isDefault', false).forEach(function (configGroup) {
  456. configGroup.set('hash', this.get('wizardController').getConfigGroupHash(configGroup));
  457. }, this);
  458. var overrideToAdd = this.get('overrideToAdd');
  459. if (overrideToAdd) {
  460. overrideToAdd = componentConfig.get('configs').findProperty('name', overrideToAdd.name);
  461. if (overrideToAdd) {
  462. this.addOverrideProperty(overrideToAdd);
  463. component.set('overrideToAdd', null);
  464. }
  465. }
  466. },
  467. /**
  468. * Resolve dependency between configs.
  469. * @param serviceName {String}
  470. * @param configs {Ember.Enumerable}
  471. */
  472. resolveServiceDependencyConfigs: function (serviceName, configs) {
  473. switch (serviceName) {
  474. case 'STORM':
  475. this.resolveStormConfigs(configs);
  476. break;
  477. case 'YARN':
  478. this.resolveYarnConfigs(configs);
  479. break;
  480. }
  481. },
  482. /**
  483. * Update some Storm configs
  484. * If Ganglia is selected to install or already installed, Ganglia host should be added to configs
  485. * @param {Ember.Enumerable} configs
  486. * @method resolveStormConfigs
  487. */
  488. resolveStormConfigs: function (configs) {
  489. var dependentConfigs, gangliaServerHost, gangliaHostId, hosts;
  490. dependentConfigs = ['nimbus.childopts', 'supervisor.childopts', 'worker.childopts'];
  491. // if Ganglia selected or installed, set ganglia host to configs
  492. if (this.get('installedServiceNames').contains('STORM') && this.get('installedServiceNames').contains('GANGLIA')) return;
  493. if (this.get('allSelectedServiceNames').contains('GANGLIA') || this.get('installedServiceNames').contains('GANGLIA')) {
  494. if (this.get('wizardController.name') === 'addServiceController') {
  495. gangliaServerHost = this.get('wizardController').getDBProperty('masterComponentHosts').findProperty('component', 'GANGLIA_SERVER').hostName;
  496. } else {
  497. hosts = this.get('wizardController').getDBProperty('hosts');
  498. gangliaHostId = this.get('wizardController').getDBProperty('masterComponentHosts').findProperty('component', 'GANGLIA_SERVER').host_id;
  499. for (var hostName in hosts) {
  500. if (hosts[hostName].id == gangliaHostId) gangliaServerHost = hosts[hostName].name;
  501. }
  502. }
  503. dependentConfigs.forEach(function (configName) {
  504. var config = configs.findProperty('name', configName);
  505. if (!Em.isNone(config.value)) {
  506. var replaceStr = config.value.match(/.jar=host[^,]+/)[0];
  507. var replaceWith = replaceStr.slice(0, replaceStr.lastIndexOf('=') - replaceStr.length + 1) + gangliaServerHost;
  508. config.value = config.recommendedValue = config.value.replace(replaceStr, replaceWith);
  509. }
  510. }, this);
  511. }
  512. },
  513. /**
  514. * Update some Storm configs
  515. * If SLIDER is selected to install or already installed,
  516. * some Yarn properties must be changed
  517. * @param {Ember.Enumerable} configs
  518. * @method resolveYarnConfigs
  519. */
  520. resolveYarnConfigs: function (configs) {
  521. var cfgToChange = configs.findProperty('name', 'hadoop.registry.rm.enabled');
  522. if (cfgToChange) {
  523. var res = this.get('allSelectedServiceNames').contains('SLIDER');
  524. if (Em.get(cfgToChange, 'value') !== res) {
  525. Em.set(cfgToChange, 'recommendedValue', res);
  526. Em.set(cfgToChange, 'value', res);
  527. }
  528. }
  529. },
  530. /**
  531. * On load function
  532. * @method loadStep
  533. */
  534. loadStep: function () {
  535. console.log("TRACE: Loading step7: Configure Services");
  536. if (!this.get('isConfigsLoaded')) {
  537. return;
  538. }
  539. this.clearStep();
  540. var self = this;
  541. //STEP 1: Load advanced configs
  542. var advancedConfigs = this.get('content.advancedServiceConfig');
  543. //STEP 2: Load on-site configs by service from local DB
  544. var storedConfigs = this.get('content.serviceConfigProperties');
  545. //STEP 3: Merge pre-defined configs with loaded on-site configs
  546. var configs = App.config.mergePreDefinedWithStored(
  547. storedConfigs,
  548. advancedConfigs,
  549. this.get('selectedServiceNames').concat(this.get('installedServiceNames'))
  550. );
  551. App.config.setPreDefinedServiceConfigs(this.get('addMiscTabToPage'));
  552. //STEP 4: Add advanced configs
  553. App.config.addAdvancedConfigs(configs, advancedConfigs);
  554. this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
  555. if (this.get('wizardController.name') === 'addServiceController') {
  556. App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags')).done(function (loadedConfigs) {
  557. self.setInstalledServiceConfigs(self.get('serviceConfigTags'), configs, loadedConfigs, self.get('installedServiceNames'));
  558. self.applyServicesConfigs(configs, storedConfigs);
  559. });
  560. } else {
  561. this.applyServicesConfigs(configs, storedConfigs);
  562. }
  563. },
  564. applyServicesConfigs: function (configs, storedConfigs) {
  565. if (this.get('allSelectedServiceNames').contains('YARN')) {
  566. configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml', []);
  567. }
  568. var dependedServices = ["STORM", "YARN"];
  569. dependedServices.forEach(function (serviceName) {
  570. if (this.get('allSelectedServiceNames').contains(serviceName)) {
  571. this.resolveServiceDependencyConfigs(serviceName, configs);
  572. }
  573. }, this);
  574. //STEP 6: Distribute configs by service and wrap each one in App.ServiceConfigProperty (configs -> serviceConfigs)
  575. var self = this;
  576. if (self.get('securityEnabled') && self.get('wizardController.name') == 'addServiceController') {
  577. self.addKerberosDescriptorConfigs(configs, self.get('wizardController.kerberosDescriptorConfigs') || []);
  578. }
  579. self.setStepConfigs(configs, storedConfigs);
  580. this.loadServerSideConfigsRecommendations().always(function () {
  581. self.set('isRecommendedLoaded', true);
  582. // format descriptor configs
  583. var serviceConfigProperties = (self.get('content.serviceConfigProperties') || []).mapProperty('name');
  584. var recommendedToDelete = self.get('_dependentConfigValues').filterProperty('toDelete');
  585. recommendedToDelete.forEach(function (c) {
  586. var name = Em.get(c, 'propertyName');
  587. if (serviceConfigProperties.contains(name)) {
  588. Em.set(self.get('_dependentConfigValues').findProperty('propertyName', name), 'toDelete', false);
  589. }
  590. });
  591. self.updateDependentConfigs();
  592. self.checkHostOverrideInstaller();
  593. self.activateSpecialConfigs();
  594. self.selectProperService();
  595. self.restoreRecommendedConfigs();
  596. if (self.get('content.skipConfigStep')) {
  597. App.router.send('next');
  598. }
  599. });
  600. },
  601. /**
  602. * After user navigates back to step7, values for depended configs should be set to values set by user and not to default values
  603. * @method restoreRecommendedConfigs
  604. */
  605. restoreRecommendedConfigs: function () {
  606. var recommendationsConfigs = this.get('recommendationsConfigs') || {};
  607. var serviceConfigProperties = this.get('content.serviceConfigProperties') || [];
  608. var stepConfigs = this.get('stepConfigs');
  609. Em.keys(recommendationsConfigs).forEach(function (file) {
  610. (Em.keys(recommendationsConfigs[file].properties).concat(Em.keys(recommendationsConfigs[file].property_attributes || {}))).forEach(function (configName) {
  611. stepConfigs.forEach(function (stepConfig) {
  612. stepConfig.get('configs').filterProperty('name', configName).forEach(function (configProperty) {
  613. if (Em.get(configProperty, 'filename').contains(file)) {
  614. var scps = serviceConfigProperties.filterProperty('name', configName).filter(function (cp) {
  615. return Em.get(cp, 'filename').contains(file);
  616. });
  617. if (scps.length) {
  618. Em.set(configProperty, 'value', Em.get(scps[0], 'value'));
  619. }
  620. }
  621. });
  622. });
  623. });
  624. });
  625. },
  626. /**
  627. * Mark descriptor properties in configuration object.
  628. *
  629. * @param {Object[]} configs - config properties to change
  630. * @param {App.ServiceConfigProperty[]} descriptor - parsed kerberos descriptor
  631. * @method addKerberosDescriptorConfigs
  632. */
  633. addKerberosDescriptorConfigs: function (configs, descriptor) {
  634. descriptor.forEach(function (item) {
  635. var property = configs.findProperty('name', item.get('name'));
  636. if (property) {
  637. Em.setProperties(property, {
  638. isSecureConfig: true,
  639. displayName: Em.get(item, 'name'),
  640. isUserProperty: false,
  641. isOverridable: false,
  642. category: 'Advanced ' + Em.get(item, 'filename')
  643. });
  644. }
  645. });
  646. },
  647. /**
  648. * Load config groups
  649. * and (if some services are already installed) load config groups for installed services
  650. * @method checkHostOverrideInstaller
  651. */
  652. checkHostOverrideInstaller: function () {
  653. if (this.get('wizardController.name') !== 'kerberosWizardController') {
  654. this.loadConfigGroups(this.get('content.configGroups'));
  655. }
  656. if (this.get('installedServiceNames').length > 0) {
  657. this.loadInstalledServicesConfigGroups(this.get('installedServiceNames'));
  658. }
  659. },
  660. /**
  661. * Set init <code>stepConfigs</code> value
  662. * Set <code>selected</code> for addable services if addServiceController is used
  663. * Remove SNameNode if HA is enabled (and if addServiceController is used)
  664. * @param {Ember.Object[]} configs
  665. * @param {Ember.Object[]} storedConfigs
  666. * @method setStepConfigs
  667. */
  668. setStepConfigs: function (configs, storedConfigs) {
  669. var localDB = {
  670. hosts: this.get('wizardController.content.hosts'),
  671. masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
  672. slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts')
  673. };
  674. var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allSelectedServiceNames'), this.get('installedServiceNames'), localDB);
  675. if (this.get('wizardController.name') === 'addServiceController') {
  676. serviceConfigs.setEach('showConfig', true);
  677. serviceConfigs.setEach('selected', false);
  678. this.get('selectedServiceNames').forEach(function (serviceName) {
  679. if (!serviceConfigs.findProperty('serviceName', serviceName)) return;
  680. serviceConfigs.findProperty('serviceName', serviceName).set('selected', true);
  681. }, this);
  682. this.get('installedServiceNames').forEach(function (serviceName) {
  683. var serviceConfigObj = serviceConfigs.findProperty('serviceName', serviceName);
  684. var isInstallableService = App.StackService.find(serviceName).get('isInstallable');
  685. if (!isInstallableService) serviceConfigObj.set('showConfig', false);
  686. }, this);
  687. // if HA is enabled -> Remove SNameNode, hbase.rootdir should use Name Service ID
  688. if (App.get('isHaEnabled')) {
  689. var c = serviceConfigs.findProperty('serviceName', 'HDFS').configs,
  690. nameServiceId = c.findProperty('name', 'dfs.nameservices'),
  691. removedConfigs = c.filterProperty('category', 'SECONDARY_NAMENODE');
  692. removedConfigs.map(function (config) {
  693. c = c.without(config);
  694. });
  695. serviceConfigs.findProperty('serviceName', 'HDFS').configs = c;
  696. if(this.get('selectedServiceNames').contains('HBASE') && nameServiceId){
  697. var hRootDir = serviceConfigs.findProperty('serviceName', 'HBASE').configs.findProperty('name','hbase.rootdir'),
  698. valueToChange = hRootDir.get('value').replace(/\/\/.*:/i, '//' + nameServiceId.get('value') + ':');
  699. hRootDir.setProperties({
  700. 'value': valueToChange,
  701. 'recommendedValue' : valueToChange
  702. });
  703. }
  704. }
  705. }
  706. // Remove Notifications from MISC if it isn't Installer Controller
  707. if (this.get('wizardController.name') !== 'installerController') {
  708. var miscService = serviceConfigs.findProperty('serviceName', 'MISC');
  709. if (miscService) {
  710. c = miscService.configs;
  711. removedConfigs = c.filterProperty('category', 'Notifications');
  712. removedConfigs.map(function (config) {
  713. c = c.without(config);
  714. });
  715. miscService.configs = c;
  716. }
  717. }
  718. this.set('stepConfigs', serviceConfigs);
  719. },
  720. /**
  721. * Select first addable service for <code>addServiceWizard</code>
  722. * Select first service at all in other cases
  723. * @method selectProperService
  724. */
  725. selectProperService: function () {
  726. if (this.get('wizardController.name') === 'addServiceController') {
  727. this.set('selectedService', this.get('stepConfigs').filterProperty('selected', true).get('firstObject'));
  728. } else {
  729. this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
  730. }
  731. },
  732. /**
  733. * Load config tags
  734. * @return {$.ajax|null}
  735. * @method getConfigTags
  736. */
  737. getConfigTags: function () {
  738. this.set('isAppliedConfigLoaded', false);
  739. return App.ajax.send({
  740. name: 'config.tags',
  741. sender: this,
  742. success: 'getConfigTagsSuccess'
  743. });
  744. },
  745. /**
  746. * Success callback for config tags request
  747. * Updates <code>serviceConfigTags</code> with tags received from server
  748. * @param {object} data
  749. * @method getConfigTagsSuccess
  750. */
  751. getConfigTagsSuccess: function (data) {
  752. var installedServiceSites = [];
  753. App.StackService.find().filterProperty('isInstalled').forEach(function (service) {
  754. if (!service.get('configTypes')) return;
  755. var configTypes = Object.keys(service.get('configTypes'));
  756. installedServiceSites = installedServiceSites.concat(configTypes);
  757. }, this);
  758. installedServiceSites = installedServiceSites.uniq();
  759. var serviceConfigTags = [];
  760. for (var site in data.Clusters.desired_configs) {
  761. if (data.Clusters.desired_configs.hasOwnProperty(site)) {
  762. if (installedServiceSites.contains(site)) {
  763. serviceConfigTags.push({
  764. siteName: site,
  765. tagName: data.Clusters.desired_configs[site].tag,
  766. newTagName: null
  767. });
  768. }
  769. }
  770. }
  771. this.set('serviceConfigTags', serviceConfigTags);
  772. this.set('isAppliedConfigLoaded', true);
  773. },
  774. /**
  775. * set configs actual values from server
  776. * @param serviceConfigTags
  777. * @param configs
  778. * @param configsByTags
  779. * @param installedServiceNames
  780. * @method setInstalledServiceConfigs
  781. */
  782. setInstalledServiceConfigs: function (serviceConfigTags, configs, configsByTags, installedServiceNames) {
  783. var configsMap = {};
  784. var configMixin = App.get('config');
  785. var nonServiceTab = require('data/service_configs');
  786. var self = this;
  787. configsByTags.forEach(function (configSite) {
  788. configsMap[configSite.type] = configSite.properties || {};
  789. });
  790. configs.forEach(function (_config) {
  791. var type = _config.filename ? App.config.getConfigTagFromFileName(_config.filename) : null;
  792. var mappedConfigValue = type && configsMap[type] ? configsMap[type][_config.name] : null;
  793. if (!Em.isNone(mappedConfigValue) && ((installedServiceNames && installedServiceNames.contains(_config.serviceName) || nonServiceTab.someProperty('serviceName', _config.serviceName)))) {
  794. // prevent overriding already edited properties
  795. if (_config.savedValue != mappedConfigValue) {
  796. _config.value = mappedConfigValue;
  797. }
  798. _config.savedValue = mappedConfigValue;
  799. _config.hasInitialValue = true;
  800. App.config.handleSpecialProperties(_config);
  801. delete configsMap[type][_config.name];
  802. }
  803. });
  804. self.setServiceDatabaseConfigs(configs);
  805. //add user properties
  806. Em.keys(configsMap).forEach(function (filename) {
  807. Em.keys(configsMap[filename]).forEach(function (propertyName) {
  808. configs.push(configMixin.addUserProperty({
  809. id: 'site property',
  810. name: propertyName,
  811. serviceName: configMixin.getServiceNameByConfigType(filename),
  812. value: configsMap[filename][propertyName],
  813. savedValue: configsMap[filename][propertyName],
  814. filename: configMixin.get('filenameExceptions').contains(filename) ? filename : filename + '.xml',
  815. category: 'Advanced',
  816. hasInitialValue: true,
  817. isUserProperty: true,
  818. isOverridable: true,
  819. overrides: [],
  820. isRequired: true,
  821. isVisible: true,
  822. showLabel: true
  823. }, false, []));
  824. });
  825. });
  826. },
  827. /**
  828. * Check if Oozie or Hive use existing database then need
  829. * to restore missed properties
  830. *
  831. * @param {Object[]} configs
  832. **/
  833. setServiceDatabaseConfigs: function (configs) {
  834. var serviceNames = this.get('installedServiceNames').filter(function (serviceName) {
  835. return ['OOZIE', 'HIVE'].contains(serviceName);
  836. });
  837. serviceNames.forEach(function (serviceName) {
  838. var propertyPrefix = serviceName.toLowerCase();
  839. var dbTypeConfig = configs.findProperty('name', propertyPrefix + '_database');
  840. if (!/existing/gi.test(dbTypeConfig.value)) return;
  841. var dbHostName = propertyPrefix + '_hostname';
  842. var database = dbTypeConfig.value.match(/MySQL|PostgreSQL|Oracle|Derby|MSSQL/gi)[0];
  843. var dbPrefix = database.toLowerCase();
  844. if (database.toLowerCase() == 'mssql') {
  845. if (/integrated/gi.test(dbTypeConfig.value)) {
  846. dbPrefix = 'mssql_server_2';
  847. } else {
  848. dbPrefix = 'mssql_server';
  849. }
  850. }
  851. var propertyName = propertyPrefix + '_existing_' + dbPrefix + '_host';
  852. var existingDBConfig = configs.findProperty('name', propertyName);
  853. if (!existingDBConfig.value)
  854. existingDBConfig.value = existingDBConfig.savedValue = configs.findProperty('name', dbHostName).value;
  855. }, this);
  856. },
  857. /**
  858. * Add group ids to <code>groupsToDelete</code>
  859. * Also save <code>groupsToDelete</code> to local storage
  860. * @param {Ember.Object[]} groups
  861. * @method setGroupsToDelete
  862. */
  863. setGroupsToDelete: function (groups) {
  864. var groupsToDelete = this.get('groupsToDelete');
  865. groups.forEach(function (group) {
  866. if (group.get('id'))
  867. groupsToDelete.push({
  868. id: group.get('id')
  869. });
  870. });
  871. this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
  872. },
  873. /**
  874. * Update <code>configGroups</code> with selected service configGroups
  875. * Also set default group to first position
  876. * Update <code>selectedConfigGroup</code> with new default group
  877. * @method selectedServiceObserver
  878. */
  879. selectedServiceObserver: function () {
  880. if (this.get('selectedService') && (this.get('selectedService.serviceName') !== 'MISC')) {
  881. var serviceGroups = this.get('selectedService.configGroups');
  882. serviceGroups.forEach(function (item, index, array) {
  883. if (item.isDefault) {
  884. array.unshift(item);
  885. array.splice(index + 1, 1);
  886. }
  887. });
  888. this.set('configGroups', serviceGroups);
  889. this.set('selectedConfigGroup', serviceGroups.findProperty('isDefault'));
  890. }
  891. }.observes('selectedService.configGroups.@each'),
  892. /**
  893. * load default groups for each service in case of initial load
  894. * @param serviceConfigGroups
  895. * @method loadConfigGroups
  896. */
  897. loadConfigGroups: function (serviceConfigGroups) {
  898. var services = this.get('stepConfigs');
  899. var hosts = this.get('wizardController.allHosts').mapProperty('hostName');
  900. services.forEach(function (service) {
  901. if (service.get('serviceName') === 'MISC') return;
  902. var serviceRawGroups = serviceConfigGroups.filterProperty('service.id', service.serviceName);
  903. if (!serviceRawGroups.length) {
  904. service.set('configGroups', [
  905. App.ConfigGroup.create({
  906. name: service.displayName + " Default",
  907. description: "Default cluster level " + service.serviceName + " configuration",
  908. isDefault: true,
  909. hosts: Em.copy(hosts),
  910. service: Em.Object.create({
  911. id: service.serviceName
  912. }),
  913. serviceName: service.serviceName
  914. })
  915. ]);
  916. }
  917. else {
  918. var defaultGroup = App.ConfigGroup.create(serviceRawGroups.findProperty('isDefault'));
  919. var serviceGroups = service.get('configGroups');
  920. serviceRawGroups.filterProperty('isDefault', false).forEach(function (configGroup) {
  921. var readyGroup = App.ConfigGroup.create(configGroup);
  922. var wrappedProperties = [];
  923. readyGroup.get('properties').forEach(function (propertyData) {
  924. var parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name', propertyData.name);
  925. var overriddenSCP = App.ServiceConfigProperty.create(parentSCP);
  926. overriddenSCP.set('isOriginalSCP', false);
  927. overriddenSCP.set('parentSCP', parentSCP);
  928. overriddenSCP.set('group', readyGroup);
  929. overriddenSCP.setProperties(propertyData);
  930. wrappedProperties.pushObject(App.ServiceConfigProperty.create(overriddenSCP));
  931. });
  932. wrappedProperties.setEach('group', readyGroup);
  933. readyGroup.set('properties', wrappedProperties);
  934. readyGroup.set('parentConfigGroup', defaultGroup);
  935. serviceGroups.pushObject(readyGroup);
  936. });
  937. defaultGroup.set('childConfigGroups', serviceGroups);
  938. serviceGroups.pushObject(defaultGroup);
  939. }
  940. });
  941. },
  942. /**
  943. * Click-handler on config-group to make it selected
  944. * @param {object} event
  945. * @method selectConfigGroup
  946. */
  947. selectConfigGroup: function (event) {
  948. this.set('selectedConfigGroup', event.context);
  949. },
  950. /**
  951. * Rebuild list of configs switch of config group:
  952. * on default - display all configs from default group and configs from non-default groups as disabled
  953. * on non-default - display all from default group as disabled and configs from selected non-default group
  954. * @method switchConfigGroupConfigs
  955. */
  956. switchConfigGroupConfigs: function () {
  957. var serviceConfigs = this.get('selectedService.configs'),
  958. selectedGroup = this.get('selectedConfigGroup'),
  959. overrideToAdd = this.get('overrideToAdd'),
  960. overrides = [];
  961. if (!selectedGroup) return;
  962. var displayedConfigGroups = this._getDisplayedConfigGroups();
  963. displayedConfigGroups.forEach(function (group) {
  964. overrides.pushObjects(group.get('properties'));
  965. });
  966. serviceConfigs.forEach(function (config) {
  967. this._setEditableValue(config);
  968. this._setOverrides(config, overrides);
  969. }, this);
  970. }.observes('selectedConfigGroup'),
  971. /**
  972. * Get list of config groups to display
  973. * Returns empty array if no <code>selectedConfigGroup</code>
  974. * @return {Array}
  975. * @method _getDisplayedConfigGroups
  976. */
  977. _getDisplayedConfigGroups: function () {
  978. var selectedGroup = this.get('selectedConfigGroup');
  979. if (!selectedGroup) return [];
  980. return (selectedGroup.get('isDefault')) ?
  981. this.get('selectedService.configGroups').filterProperty('isDefault', false) :
  982. [this.get('selectedConfigGroup')];
  983. },
  984. /**
  985. * Set <code>isEditable</code> property to <code>config</code>
  986. * @param {Ember.Object} config
  987. * @return {Ember.Object} updated config-object
  988. * @method _setEditableValue
  989. */
  990. _setEditableValue: function (config) {
  991. var selectedGroup = this.get('selectedConfigGroup');
  992. if (!selectedGroup) return config;
  993. var isEditable = config.get('isEditable'),
  994. isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName'));
  995. if (isServiceInstalled) {
  996. isEditable = (!isEditable && !config.get('isReconfigurable')) ? false : selectedGroup.get('isDefault');
  997. }
  998. else {
  999. isEditable = selectedGroup.get('isDefault');
  1000. }
  1001. if (config.get('group')) {
  1002. isEditable = config.get('group.name') == this.get('selectedConfigGroup.name');
  1003. }
  1004. config.set('isEditable', isEditable);
  1005. return config;
  1006. },
  1007. /**
  1008. * Set <code>overrides</code> property to <code>config</code>
  1009. * @param {Ember.Object} config
  1010. * @param {Ember.Enumerable} overrides
  1011. * @returns {Ember.Object}
  1012. * @method _setOverrides
  1013. */
  1014. _setOverrides: function (config, overrides) {
  1015. var selectedGroup = this.get('selectedConfigGroup'),
  1016. overrideToAdd = this.get('overrideToAdd'),
  1017. configOverrides = overrides.filterProperty('name', config.get('name'));
  1018. if (!selectedGroup) return config;
  1019. if (overrideToAdd && overrideToAdd.get('name') === config.get('name')) {
  1020. configOverrides.push(this.addOverrideProperty(config));
  1021. this.set('overrideToAdd', null);
  1022. }
  1023. configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
  1024. configOverrides.setEach('parentSCP', config);
  1025. config.set('overrides', configOverrides);
  1026. return config;
  1027. },
  1028. /**
  1029. * create overriden property and push it into Config group
  1030. * @param {App.ServiceConfigProperty} serviceConfigProperty
  1031. * @return {App.ServiceConfigProperty}
  1032. * @method addOverrideProperty
  1033. */
  1034. addOverrideProperty: function (serviceConfigProperty) {
  1035. var overrides = serviceConfigProperty.get('overrides') || [];
  1036. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  1037. var group = this.get('selectedService.configGroups').findProperty('name', this.get('selectedConfigGroup.name'));
  1038. var valueForOverride = (serviceConfigProperty.get('widget') || serviceConfigProperty.get('displayType') == 'checkbox') ? serviceConfigProperty.get('value') : '';
  1039. newSCP.set('group', group);
  1040. newSCP.set('value', valueForOverride);
  1041. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  1042. newSCP.set('parentSCP', serviceConfigProperty);
  1043. newSCP.set('isEditable', true);
  1044. group.get('properties').pushObject(newSCP);
  1045. overrides.pushObject(newSCP);
  1046. newSCP.validate();
  1047. return newSCP;
  1048. },
  1049. /**
  1050. * @method manageConfigurationGroup
  1051. */
  1052. manageConfigurationGroup: function () {
  1053. App.router.get('manageConfigGroupsController').manageConfigurationGroups(this);
  1054. },
  1055. /**
  1056. * Make some configs visible depending on active services
  1057. * @method activateSpecialConfigs
  1058. */
  1059. activateSpecialConfigs: function () {
  1060. if (this.get('addMiscTabToPage')) {
  1061. var serviceToShow = this.get('selectedServiceNames').concat('MISC');
  1062. var miscConfigs = this.get('stepConfigs').findProperty('serviceName', 'MISC').configs;
  1063. if (this.get('wizardController.name') == "addServiceController") {
  1064. miscConfigs.findProperty('name', 'smokeuser').set('value', this.get('content.smokeuser')).set('isEditable', false);
  1065. miscConfigs.findProperty('name', 'user_group').set('value', this.get('content.group')).set('isEditable', false);
  1066. }
  1067. App.config.miscConfigVisibleProperty(miscConfigs, serviceToShow);
  1068. }
  1069. var wizardController = this.get('wizardController');
  1070. if (wizardController.get('name') === "kerberosWizardController") {
  1071. var kerberosConfigs = this.get('stepConfigs').findProperty('serviceName', 'KERBEROS').configs;
  1072. kerberosConfigs.findProperty('name', 'kdc_type').set('value', wizardController.get('content.kerberosOption'));
  1073. }
  1074. },
  1075. /**
  1076. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1077. * @return {$.ajax|null}
  1078. * @method checkMySQLHost
  1079. */
  1080. checkMySQLHost: function () {
  1081. // get ambari database type and hostname
  1082. return App.ajax.send({
  1083. name: 'ambari.service',
  1084. data: {
  1085. fields : "?fields=hostComponents/RootServiceHostComponents/properties/server.jdbc.database_name,hostComponents/RootServiceHostComponents/properties/server.jdbc.url"
  1086. },
  1087. sender: this,
  1088. success: 'getAmbariDatabaseSuccess'
  1089. });
  1090. },
  1091. /**
  1092. * Success callback for ambari database, get Ambari DB type and DB server hostname, then
  1093. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1094. * @param {object} data
  1095. * @method getAmbariDatabaseSuccess
  1096. */
  1097. getAmbariDatabaseSuccess: function (data) {
  1098. var hiveDBHostname = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_ambari_host').value;
  1099. var ambariServiceHostComponents = data.hostComponents;
  1100. if (!!ambariServiceHostComponents.length) {
  1101. var ambariDBInfo = JSON.stringify(ambariServiceHostComponents[0].RootServiceHostComponents.properties);
  1102. this.set('mySQLServerConflict', ambariDBInfo.indexOf('mysql') > 0 && ambariDBInfo.indexOf(hiveDBHostname) > 0);
  1103. } else {
  1104. this.set('mySQLServerConflict', false);
  1105. }
  1106. },
  1107. /**
  1108. * Check if new MySql database was chosen for Hive service
  1109. * and it is not located on the same host as Ambari server
  1110. * that using MySql database too.
  1111. *
  1112. * @method resolveHiveMysqlDatabase
  1113. **/
  1114. resolveHiveMysqlDatabase: function () {
  1115. var hiveService = this.get('content.services').findProperty('serviceName', 'HIVE');
  1116. if (!hiveService || !hiveService.get('isSelected') || hiveService.get('isInstalled')) {
  1117. this.moveNext();
  1118. return;
  1119. }
  1120. var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_database').value;
  1121. if (hiveDBType == 'New MySQL Database') {
  1122. var self = this;
  1123. this.checkMySQLHost().done(function () {
  1124. if (self.get('mySQLServerConflict')) {
  1125. // error popup before you can proceed
  1126. return App.ModalPopup.show({
  1127. header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
  1128. body:Em.I18n.t('installer.step7.popup.mySQLWarning.body'),
  1129. secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
  1130. primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
  1131. onSecondary: function () {
  1132. var parent = this;
  1133. return App.ModalPopup.show({
  1134. header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
  1135. body: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'),
  1136. onPrimary: function () {
  1137. this.hide();
  1138. parent.hide();
  1139. // go back to step 5: assign masters and disable default navigation warning
  1140. App.router.get('installerController').gotoStep(5, true);
  1141. }
  1142. });
  1143. }
  1144. });
  1145. } else {
  1146. self.moveNext();
  1147. }
  1148. });
  1149. } else {
  1150. this.moveNext();
  1151. }
  1152. },
  1153. checkDatabaseConnectionTest: function () {
  1154. var deferred = $.Deferred();
  1155. var configMap = [
  1156. {
  1157. serviceName: 'OOZIE',
  1158. ignored: [Em.I18n.t('installer.step7.oozie.database.new')]
  1159. },
  1160. {
  1161. serviceName: 'HIVE',
  1162. ignored: [Em.I18n.t('installer.step7.hive.database.new.mysql'), Em.I18n.t('installer.step7.hive.database.new.postgres')]
  1163. }
  1164. ];
  1165. configMap.forEach(function (config) {
  1166. var isConnectionNotTested = false;
  1167. var service = this.get('content.services').findProperty('serviceName', config.serviceName);
  1168. if (service && service.get('isSelected') && !service.get('isInstalled')) {
  1169. var serviceConfigs = this.get('stepConfigs').findProperty('serviceName', config.serviceName).configs;
  1170. var serviceDatabase = serviceConfigs.findProperty('name', config.serviceName.toLowerCase() + '_database').get('value');
  1171. if (!config.ignored.contains(serviceDatabase)) {
  1172. var filledProperties = App.db.get('tmp', config.serviceName + '_connection');
  1173. if (!filledProperties || App.isEmptyObject(filledProperties)) {
  1174. isConnectionNotTested = true;
  1175. } else {
  1176. for (var key in filledProperties) {
  1177. if (serviceConfigs.findProperty('name', key).get('value') !== filledProperties[key])
  1178. isConnectionNotTested = true;
  1179. }
  1180. }
  1181. }
  1182. }
  1183. config.isCheckIgnored = isConnectionNotTested;
  1184. }, this);
  1185. var ignoredServices = configMap.filterProperty('isCheckIgnored', true);
  1186. if (ignoredServices.length) {
  1187. var displayedServiceNames = ignoredServices.mapProperty('serviceName').map(function (serviceName) {
  1188. return this.get('content.services').findProperty('serviceName', serviceName).get('displayName');
  1189. }, this);
  1190. this.showDatabaseConnectionWarningPopup(displayedServiceNames, deferred);
  1191. }
  1192. else {
  1193. deferred.resolve();
  1194. }
  1195. return deferred;
  1196. },
  1197. showDatabaseConnectionWarningPopup: function (serviceNames, deferred) {
  1198. var self = this;
  1199. return App.ModalPopup.show({
  1200. header: Em.I18n.t('installer.step7.popup.database.connection.header'),
  1201. body: Em.I18n.t('installer.step7.popup.database.connection.body').format(serviceNames.join(', ')),
  1202. secondary: Em.I18n.t('common.cancel'),
  1203. primary: Em.I18n.t('common.proceedAnyway'),
  1204. onPrimary: function () {
  1205. deferred.resolve();
  1206. this._super();
  1207. },
  1208. onSecondary: function () {
  1209. self.set('submitButtonClicked', false);
  1210. deferred.reject();
  1211. this._super();
  1212. }
  1213. })
  1214. },
  1215. /**
  1216. * Proceed to the next step
  1217. **/
  1218. moveNext: function () {
  1219. App.router.send('next');
  1220. },
  1221. /**
  1222. * Click-handler on Next button
  1223. * Disable "Submit"-button while server-side processes are running
  1224. * @method submit
  1225. */
  1226. submit: function () {
  1227. if (this.get('isSubmitDisabled')) {
  1228. return;
  1229. }
  1230. var self = this;
  1231. this.set('submitButtonClicked', true);
  1232. this.serverSideValidation().done(function () {
  1233. self.checkDatabaseConnectionTest().done(function () {
  1234. self.resolveHiveMysqlDatabase();
  1235. self.set('submitButtonClicked', false);
  1236. });
  1237. }).fail(function (value) {
  1238. if ("invalid_configs" == value) {
  1239. self.set('submitButtonClicked', false);
  1240. } else {
  1241. // Failed due to validation mechanism failure.
  1242. // Should proceed with other checks
  1243. self.checkDatabaseConnectionTest().done(function () {
  1244. self.resolveHiveMysqlDatabase();
  1245. self.set('submitButtonClicked', false);
  1246. });
  1247. }
  1248. });
  1249. },
  1250. toggleIssuesFilter: function () {
  1251. this.get('filterColumns').findProperty('attributeName', 'hasIssues').toggleProperty('selected');
  1252. }
  1253. });