step7_controller.js 49 KB

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