step7_controller.js 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329
  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. serviceConfigsData: require('data/service_configs'),
  107. /**
  108. * Are advanced configs loaded
  109. * @type {bool}
  110. */
  111. isAdvancedConfigLoaded: true,
  112. /**
  113. * Are applied to service configs loaded
  114. * @type {bool}
  115. */
  116. isAppliedConfigLoaded: true,
  117. isConfigsLoaded: function () {
  118. return (this.get('isAdvancedConfigLoaded') && this.get('isAppliedConfigLoaded'));
  119. }.property('isAdvancedConfigLoaded', 'isAppliedConfigLoaded'),
  120. /**
  121. * Should Next-button be disabled
  122. * @type {bool}
  123. */
  124. isSubmitDisabled: function () {
  125. if (!this.get('stepConfigs.length')) return true;
  126. if (this.get('submitButtonClicked')) return true;
  127. return (!this.get('stepConfigs').filterProperty('showConfig', true).everyProperty('errorCount', 0) || this.get("miscModalVisible"));
  128. }.property('stepConfigs.@each.errorCount', 'miscModalVisible', 'submitButtonClicked'),
  129. /**
  130. * List of selected to install service names
  131. * @type {string[]}
  132. */
  133. selectedServiceNames: function () {
  134. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).mapProperty('serviceName');
  135. }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
  136. /**
  137. * List of installed and selected to install service names
  138. * @type {string[]}
  139. */
  140. allSelectedServiceNames: function () {
  141. return this.get('content.services').filter(function (service) {
  142. return service.get('isInstalled') || service.get('isSelected');
  143. }).mapProperty('serviceName');
  144. }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
  145. /**
  146. * List of installed service names
  147. * @type {string[]}
  148. */
  149. installedServiceNames: function () {
  150. var serviceNames = this.get('content.services').filterProperty('isInstalled').mapProperty('serviceName');
  151. if (this.get('content.controllerName') !== 'installerController') {
  152. serviceNames = serviceNames.filter(function (_serviceName) {
  153. return !App.get('services.noConfigTypes').contains(_serviceName);
  154. });
  155. }
  156. return serviceNames;
  157. }.property('content.services').cacheable(),
  158. /**
  159. * List of master components
  160. * @type {Ember.Enumerable}
  161. */
  162. masterComponentHosts: function () {
  163. return this.get('content.masterComponentHosts');
  164. }.property('content.masterComponentHosts'),
  165. /**
  166. * List of slave components
  167. * @type {Ember.Enumerable}
  168. */
  169. slaveComponentHosts: function () {
  170. return this.get('content.slaveGroupProperties');
  171. }.property('content.slaveGroupProperties', 'content.slaveComponentHosts'),
  172. customData: [],
  173. /**
  174. * Filter text will be located here
  175. * @type {string}
  176. */
  177. filter: '',
  178. /**
  179. * List of filters for config properties to populate filter combobox
  180. */
  181. propertyFilters: [
  182. {
  183. attributeName: 'isOverridden',
  184. attributeValue: true,
  185. caption: 'common.combobox.dropdown.overridden'
  186. },
  187. {
  188. attributeName: 'isFinal',
  189. attributeValue: true,
  190. caption: 'common.combobox.dropdown.final'
  191. },
  192. {
  193. attributeName: 'isValid',
  194. attributeValue: false,
  195. caption: 'common.combobox.dropdown.issues'
  196. },
  197. {
  198. attributeName: 'warn',
  199. attributeValue: true,
  200. caption: 'common.combobox.dropdown.warnings'
  201. }
  202. ],
  203. /**
  204. * Dropdown menu items in filter combobox
  205. */
  206. filterColumns: function () {
  207. return this.get('propertyFilters').map(function (filter) {
  208. return Ember.Object.create({
  209. attributeName: filter.attributeName,
  210. attributeValue: filter.attributeValue,
  211. name: this.t(filter.caption),
  212. selected: false
  213. })
  214. }, this);
  215. }.property('propertyFilters'),
  216. /**
  217. * Clear controller's properties:
  218. * <ul>
  219. * <li>stepConfigs</li>
  220. * <li>filter</li>
  221. * </ul>
  222. * and desect all <code>filterColumns</code>
  223. * @method clearStep
  224. */
  225. clearStep: function () {
  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.get('isAdmin')) {
  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. }
  666. this.set('stepConfigs', serviceConfigs);
  667. },
  668. /**
  669. * Set secure properties for installed services. Mark secure properties and
  670. * properties with default empty value as non required to pass validation.
  671. *
  672. * @param {Em.Object} serviceConfigObj
  673. * @param {String} serviceName
  674. */
  675. setSecureConfigs: function (serviceConfigObj, serviceName) {
  676. var configProperties = serviceConfigObj.get('configs');
  677. if (!configProperties) return;
  678. var secureConfigs = this.get('secureConfigs').filterProperty('serviceName', serviceName);
  679. secureConfigs.forEach(function (secureConfig) {
  680. var property = configProperties.findProperty('name', secureConfig.name);
  681. if (property) {
  682. property.set('isRequired', secureConfig.value != "");
  683. if (!property.get('isRequired')) property.set('errorMessage', '');
  684. }
  685. });
  686. },
  687. /**
  688. *
  689. * @param selectedService
  690. * @param serviceName
  691. */
  692. addSecureConfigs: function (selectedService, serviceName) {
  693. var secureService = this.get('secureServices').findProperty('serviceName', serviceName);
  694. if (!secureService) {
  695. return;
  696. }
  697. secureService.configCategories.forEach(function (category) {
  698. selectedService.get('configCategories').push(category);
  699. });
  700. secureService.configs.forEach(function (conf) {
  701. conf.isVisible = !conf.displayType.contains('masterHost') && !conf.displayType.contains('slaveHost');
  702. var config = App.ServiceConfigProperty.create(conf);
  703. selectedService.get('configs').push(config);
  704. }, this);
  705. },
  706. /**
  707. * Select first addable service for <code>addServiceWizard</code>
  708. * Select first service at all in other cases
  709. * @method selectProperService
  710. */
  711. selectProperService: function () {
  712. if (this.get('wizardController.name') === 'addServiceController') {
  713. this.set('selectedService', this.get('stepConfigs').filterProperty('selected', true).get('firstObject'));
  714. } else {
  715. this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
  716. }
  717. },
  718. /**
  719. * Load config tags
  720. * @return {$.ajax|null}
  721. * @method getConfigTags
  722. */
  723. getConfigTags: function () {
  724. this.set('isAppliedConfigLoaded', false);
  725. return App.ajax.send({
  726. name: 'config.tags',
  727. sender: this,
  728. success: 'getConfigTagsSuccess'
  729. });
  730. },
  731. /**
  732. * Success callback for config tags request
  733. * Updates <code>serviceConfigTags</code> with tags received from server
  734. * @param {object} data
  735. * @method getConfigTagsSuccess
  736. */
  737. getConfigTagsSuccess: function (data) {
  738. var installedServiceSites = [];
  739. App.StackService.find().filterProperty('isInstalled').forEach(function (service) {
  740. if (!service.get('configTypes')) return;
  741. var configTypes = Object.keys(service.get('configTypes'));
  742. installedServiceSites = installedServiceSites.concat(configTypes);
  743. }, this);
  744. installedServiceSites = installedServiceSites.uniq();
  745. var serviceConfigTags = [];
  746. for (var site in data.Clusters.desired_configs) {
  747. if (data.Clusters.desired_configs.hasOwnProperty(site)) {
  748. if (installedServiceSites.contains(site)) {
  749. serviceConfigTags.push({
  750. siteName: site,
  751. tagName: data.Clusters.desired_configs[site].tag,
  752. newTagName: null
  753. });
  754. }
  755. }
  756. }
  757. this.set('serviceConfigTags', serviceConfigTags);
  758. this.set('isAppliedConfigLoaded', true);
  759. },
  760. /**
  761. * set configs actual values from server
  762. * @param serviceConfigTags
  763. * @param configs
  764. * @param configsByTags
  765. * @param installedServiceNames
  766. * @method setInstalledServiceConfigs
  767. */
  768. setInstalledServiceConfigs: function (serviceConfigTags, configs, configsByTags, installedServiceNames) {
  769. var configsMap = {};
  770. var configTypeMap = {};
  771. var configMixin = App.get('config');
  772. var self = this;
  773. configsByTags.forEach(function (configSite) {
  774. configsMap[configSite.type] = configSite.properties;
  775. });
  776. configs.forEach(function (_config) {
  777. var nonServiceTab = require('data/service_configs');
  778. var type = _config.filename ? App.config.getConfigTagFromFileName(_config.filename) : null;
  779. var mappedConfigValue = type && configsMap[type] ? configsMap[type][_config.name] : null;
  780. if (!Em.isNone(mappedConfigValue) && ((installedServiceNames && installedServiceNames.contains(_config.serviceName) || nonServiceTab.someProperty('serviceName', _config.serviceName)))) {
  781. // prevent overriding already edited properties
  782. if (_config.defaultValue != mappedConfigValue) {
  783. _config.value = mappedConfigValue;
  784. }
  785. _config.defaultValue = mappedConfigValue;
  786. _config.hasInitialValue = true;
  787. App.config.handleSpecialProperties(_config);
  788. delete configsMap[type][_config.name];
  789. }
  790. });
  791. self.setServiceDatabaseConfigs(configs);
  792. //add user properties
  793. Em.keys(configsMap).forEach(function (filename) {
  794. Em.keys(configsMap[filename]).forEach(function (propertyName) {
  795. configs.push(configMixin.addUserProperty({
  796. id: 'site property',
  797. name: propertyName,
  798. serviceName: configMixin.getServiceNameByConfigType(filename),
  799. value: configsMap[filename][propertyName],
  800. defaultValue: configsMap[filename][propertyName],
  801. filename: configMixin.get('filenameExceptions').contains(filename) ? filename : filename + '.xml',
  802. category: 'Advanced',
  803. hasInitialValue: true,
  804. isUserProperty: true,
  805. isOverridable: true,
  806. overrides: [],
  807. isRequired: true,
  808. isVisible: true,
  809. showLabel: true
  810. }, false, []));
  811. });
  812. });
  813. },
  814. /**
  815. * Check if Oozie, Hive or MetricsSink use existing database then need
  816. * to restore missed properties
  817. *
  818. * @param {Object[]} configs
  819. **/
  820. setServiceDatabaseConfigs: function (configs) {
  821. var serviceNames = this.get('installedServiceNames').filter(function (serviceName) {
  822. return ['OOZIE', 'HIVE', 'HDFS'].contains(serviceName);
  823. });
  824. serviceNames.forEach(function (serviceName) {
  825. var propertyPrefix = serviceName.toLowerCase();
  826. if (/HDFS/gi.test(serviceName)) propertyPrefix = 'sink';
  827. var dbTypeConfig = configs.findProperty('name', propertyPrefix + '_database');
  828. if (!/existing/gi.test(dbTypeConfig.value)) return;
  829. var dbHostName = propertyPrefix + '_hostname';
  830. var database = dbTypeConfig.value.match(/MySQL|PostgreSQL|Oracle|Derby|MSSQL/gi)[0];
  831. var dbPrefix = database.toLowerCase();
  832. if (database.toLowerCase() == 'mssql') {
  833. dbHostName = 'sink.dbservername';
  834. if (/integrated/gi.test(dbTypeConfig.value)) {
  835. dbPrefix = 'mssql_server';
  836. } else {
  837. dbPrefix = 'mssql_server_2';
  838. }
  839. }
  840. var propertyName = propertyPrefix + '_existing_' + dbPrefix + '_host';
  841. var existingDBConfig = configs.findProperty('name', propertyName);
  842. if (!existingDBConfig.value)
  843. existingDBConfig.value = existingDBConfig.defaultValue = configs.findProperty('name', dbHostName).value;
  844. }, this);
  845. },
  846. /**
  847. * Add group ids to <code>groupsToDelete</code>
  848. * Also save <code>groupsToDelete</code> to local storage
  849. * @param {Ember.Object[]} groups
  850. * @method setGroupsToDelete
  851. */
  852. setGroupsToDelete: function (groups) {
  853. var groupsToDelete = this.get('groupsToDelete');
  854. groups.forEach(function (group) {
  855. if (group.get('id'))
  856. groupsToDelete.push({
  857. id: group.get('id')
  858. });
  859. });
  860. this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
  861. },
  862. /**
  863. * Update <code>configGroups</code> with selected service configGroups
  864. * Also set default group to first position
  865. * Update <code>selectedConfigGroup</code> with new default group
  866. * @method selectedServiceObserver
  867. */
  868. selectedServiceObserver: function () {
  869. if (this.get('selectedService') && (this.get('selectedService.serviceName') !== 'MISC')) {
  870. var serviceGroups = this.get('selectedService.configGroups');
  871. serviceGroups.forEach(function (item, index, array) {
  872. if (item.isDefault) {
  873. array.unshift(item);
  874. array.splice(index + 1, 1);
  875. }
  876. });
  877. this.set('configGroups', serviceGroups);
  878. this.set('selectedConfigGroup', serviceGroups.findProperty('isDefault'));
  879. }
  880. }.observes('selectedService.configGroups.@each'),
  881. /**
  882. * load default groups for each service in case of initial load
  883. * @param serviceConfigGroups
  884. * @method loadConfigGroups
  885. */
  886. loadConfigGroups: function (serviceConfigGroups) {
  887. var services = this.get('stepConfigs');
  888. var hosts = this.get('wizardController.allHosts').mapProperty('hostName');
  889. var manageCGController = App.router.get('manageConfigGroupsController');
  890. this.setupManageConfigGroupsController();
  891. services.forEach(function (service) {
  892. if (service.get('serviceName') === 'MISC') return;
  893. var serviceRawGroups = serviceConfigGroups.filterProperty('service.id', service.serviceName);
  894. if (!serviceRawGroups.length) {
  895. service.set('configGroups', [
  896. App.ConfigGroup.create({
  897. name: service.displayName + " Default",
  898. description: "Default cluster level " + service.serviceName + " configuration",
  899. isDefault: true,
  900. hosts: Em.copy(hosts),
  901. publicHosts: Em.copy(manageCGController.hostsToPublic(hosts)),
  902. service: Em.Object.create({
  903. id: service.serviceName
  904. }),
  905. serviceName: service.serviceName
  906. })
  907. ]);
  908. }
  909. else {
  910. var defaultGroup = App.ConfigGroup.create(serviceRawGroups.findProperty('isDefault'));
  911. var serviceGroups = service.get('configGroups');
  912. serviceRawGroups.filterProperty('isDefault', false).forEach(function (configGroup) {
  913. var readyGroup = App.ConfigGroup.create(configGroup);
  914. var wrappedProperties = [];
  915. readyGroup.get('properties').forEach(function (propertyData) {
  916. var parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name', propertyData.name);
  917. var overriddenSCP = App.ServiceConfigProperty.create(parentSCP);
  918. overriddenSCP.set('isOriginalSCP', false);
  919. overriddenSCP.set('parentSCP', parentSCP);
  920. overriddenSCP.set('group', readyGroup);
  921. overriddenSCP.setProperties(propertyData);
  922. wrappedProperties.pushObject(App.ServiceConfigProperty.create(overriddenSCP));
  923. });
  924. wrappedProperties.setEach('group', readyGroup);
  925. readyGroup.set('properties', wrappedProperties);
  926. readyGroup.set('parentConfigGroup', defaultGroup);
  927. serviceGroups.pushObject(readyGroup);
  928. });
  929. defaultGroup.set('childConfigGroups', serviceGroups);
  930. serviceGroups.pushObject(defaultGroup);
  931. }
  932. });
  933. },
  934. setupManageConfigGroupsController: function () {
  935. var manageCGController = App.router.get('manageConfigGroupsController');
  936. manageCGController.set('isInstaller', true);
  937. manageCGController.set('isAddService', this.get('wizardController.name') === 'addServiceController');
  938. },
  939. /**
  940. * Click-handler on config-group to make it selected
  941. * @param {object} event
  942. * @method selectConfigGroup
  943. */
  944. selectConfigGroup: function (event) {
  945. this.set('selectedConfigGroup', event.context);
  946. },
  947. /**
  948. * Rebuild list of configs switch of config group:
  949. * on default - display all configs from default group and configs from non-default groups as disabled
  950. * on non-default - display all from default group as disabled and configs from selected non-default group
  951. * @method switchConfigGroupConfigs
  952. */
  953. switchConfigGroupConfigs: function () {
  954. var serviceConfigs = this.get('selectedService.configs'),
  955. selectedGroup = this.get('selectedConfigGroup'),
  956. overrideToAdd = this.get('overrideToAdd'),
  957. overrides = [];
  958. if (!selectedGroup) return;
  959. var displayedConfigGroups = this._getDisplayedConfigGroups();
  960. displayedConfigGroups.forEach(function (group) {
  961. overrides.pushObjects(group.get('properties'));
  962. });
  963. serviceConfigs.forEach(function (config) {
  964. this._setEditableValue(config);
  965. this._setOverrides(config, overrides);
  966. }, this);
  967. }.observes('selectedConfigGroup'),
  968. /**
  969. * Get list of config groups to display
  970. * Returns empty array if no <code>selectedConfigGroup</code>
  971. * @return {Array}
  972. * @method _getDisplayedConfigGroups
  973. */
  974. _getDisplayedConfigGroups: function () {
  975. var selectedGroup = this.get('selectedConfigGroup');
  976. if (!selectedGroup) return [];
  977. return (selectedGroup.get('isDefault')) ?
  978. this.get('selectedService.configGroups').filterProperty('isDefault', false) :
  979. [this.get('selectedConfigGroup')];
  980. },
  981. /**
  982. * Set <code>isEditable</code> property to <code>config</code>
  983. * @param {Ember.Object} config
  984. * @return {Ember.Object} updated config-object
  985. * @method _setEditableValue
  986. */
  987. _setEditableValue: function (config) {
  988. var selectedGroup = this.get('selectedConfigGroup');
  989. if (!selectedGroup) return config;
  990. var isEditable = config.get('isEditable'),
  991. isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName'));
  992. if (isServiceInstalled) {
  993. isEditable = (!isEditable && !config.get('isReconfigurable')) ? false : selectedGroup.get('isDefault');
  994. }
  995. else {
  996. isEditable = selectedGroup.get('isDefault');
  997. }
  998. if (config.get('group')) {
  999. isEditable = config.get('group.name') == this.get('selectedConfigGroup.name');
  1000. }
  1001. config.set('isEditable', isEditable);
  1002. return config;
  1003. },
  1004. /**
  1005. * Set <code>overrides</code> property to <code>config</code>
  1006. * @param {Ember.Object} config
  1007. * @param {Ember.Enumerable} overrides
  1008. * @returns {Ember.Object}
  1009. * @method _setOverrides
  1010. */
  1011. _setOverrides: function (config, overrides) {
  1012. var selectedGroup = this.get('selectedConfigGroup'),
  1013. overrideToAdd = this.get('overrideToAdd'),
  1014. configOverrides = overrides.filterProperty('name', config.get('name'));
  1015. if (!selectedGroup) return config;
  1016. if (overrideToAdd && overrideToAdd.get('name') === config.get('name')) {
  1017. configOverrides.push(this.addOverrideProperty(config));
  1018. this.set('overrideToAdd', null);
  1019. }
  1020. configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
  1021. configOverrides.setEach('parentSCP', config);
  1022. config.set('overrides', configOverrides);
  1023. return config;
  1024. },
  1025. /**
  1026. * create overriden property and push it into Config group
  1027. * @param {App.ServiceConfigProperty} serviceConfigProperty
  1028. * @return {App.ServiceConfigProperty}
  1029. * @method addOverrideProperty
  1030. */
  1031. addOverrideProperty: function (serviceConfigProperty) {
  1032. var overrides = serviceConfigProperty.get('overrides') || [];
  1033. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  1034. var group = this.get('selectedService.configGroups').findProperty('name', this.get('selectedConfigGroup.name'));
  1035. newSCP.set('group', group);
  1036. newSCP.set('value', '');
  1037. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  1038. newSCP.set('parentSCP', serviceConfigProperty);
  1039. newSCP.set('isEditable', true);
  1040. group.get('properties').pushObject(newSCP);
  1041. overrides.pushObject(newSCP);
  1042. return newSCP;
  1043. },
  1044. /**
  1045. * @method manageConfigurationGroup
  1046. */
  1047. manageConfigurationGroup: function () {
  1048. App.router.get('mainServiceInfoConfigsController').manageConfigurationGroups(this);
  1049. },
  1050. /**
  1051. * Make some configs visible depending on active services
  1052. * @method activateSpecialConfigs
  1053. */
  1054. activateSpecialConfigs: function () {
  1055. if (this.get('addMiscTabToPage')) {
  1056. var miscConfigs = this.get('stepConfigs').findProperty('serviceName', 'MISC').configs;
  1057. if (this.get('wizardController.name') == "addServiceController") {
  1058. miscConfigs.findProperty('name', 'smokeuser').set('value', this.get('content.smokeuser')).set('isEditable', false);
  1059. miscConfigs.findProperty('name', 'user_group').set('value', this.get('content.group')).set('isEditable', false);
  1060. }
  1061. App.config.miscConfigVisibleProperty(miscConfigs, this.get('selectedServiceNames'));
  1062. }
  1063. var wizardController = this.get('wizardController');
  1064. if (wizardController.get('name') === "kerberosWizardController") {
  1065. var kerberosConfigs = this.get('stepConfigs').findProperty('serviceName', 'KERBEROS').configs;
  1066. kerberosConfigs.findProperty('name', 'kdc_type').set('value', wizardController.get('content.kerberosOption'));
  1067. }
  1068. },
  1069. /**
  1070. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1071. * @return {$.ajax|null}
  1072. * @method checkMySQLHost
  1073. */
  1074. checkMySQLHost: function () {
  1075. // get ambari database type and hostname
  1076. return App.ajax.send({
  1077. name: 'config.ambari.database.info',
  1078. sender: this,
  1079. success: 'getAmbariDatabaseSuccess'
  1080. });
  1081. },
  1082. /**
  1083. * Success callback for ambari database, get Ambari DB type and DB server hostname, then
  1084. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1085. * @param {object} data
  1086. * @method getAmbariDatabaseSuccess
  1087. */
  1088. getAmbariDatabaseSuccess: function (data) {
  1089. var hiveDBHostname = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hivemetastore_host').value;
  1090. var ambariServiceHostComponents = data.hostComponents;
  1091. if (!!ambariServiceHostComponents.length) {
  1092. var ambariDBInfo = JSON.stringify(ambariServiceHostComponents[0].RootServiceHostComponents.properties);
  1093. this.set('mySQLServerConflict', ambariDBInfo.indexOf('mysql') > 0 && ambariDBInfo.indexOf(hiveDBHostname) > 0);
  1094. } else {
  1095. this.set('mySQLServerConflict', false);
  1096. }
  1097. },
  1098. /**
  1099. * Check if new MySql database was chosen for Hive service
  1100. * and it is not located on the same host as Ambari server
  1101. * that using MySql database too.
  1102. *
  1103. * @method resolveHiveMysqlDatabase
  1104. **/
  1105. resolveHiveMysqlDatabase: function () {
  1106. var hiveService = this.get('content.services').findProperty('serviceName', 'HIVE');
  1107. if (!hiveService || !hiveService.get('isSelected') || hiveService.get('isInstalled')) {
  1108. this.moveNext();
  1109. return;
  1110. }
  1111. var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_database').value;
  1112. if (hiveDBType == 'New MySQL Database') {
  1113. var self = this;
  1114. this.checkMySQLHost().done(function () {
  1115. if (self.get('mySQLServerConflict')) {
  1116. // error popup before you can proceed
  1117. return App.ModalPopup.show({
  1118. header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
  1119. bodyClass: Ember.View.extend({
  1120. template: Ember.Handlebars.compile(Em.I18n.t('installer.step7.popup.mySQLWarning.body'))
  1121. }),
  1122. secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
  1123. primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
  1124. onSecondary: function () {
  1125. var parent = this;
  1126. return App.ModalPopup.show({
  1127. header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
  1128. bodyClass: Ember.View.extend({
  1129. template: Ember.Handlebars.compile(Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'))
  1130. }),
  1131. onPrimary: function () {
  1132. this.hide();
  1133. parent.hide();
  1134. // go back to step 5: assign masters and disable default navigation warning
  1135. App.router.get('installerController').gotoStep(5, true);
  1136. }
  1137. });
  1138. }
  1139. });
  1140. } else {
  1141. self.moveNext();
  1142. }
  1143. });
  1144. } else {
  1145. this.moveNext();
  1146. }
  1147. },
  1148. checkDatabaseConnectionTest: function () {
  1149. var deferred = $.Deferred();
  1150. var configMap = [
  1151. {
  1152. serviceName: 'OOZIE',
  1153. ignored: [Em.I18n.t('installer.step7.oozie.database.new')]
  1154. },
  1155. {
  1156. serviceName: 'HIVE',
  1157. ignored: [Em.I18n.t('installer.step7.hive.database.new.mysql'), Em.I18n.t('installer.step7.hive.database.new.postgres')]
  1158. }
  1159. ];
  1160. configMap.forEach(function (config) {
  1161. var isConnectionNotTested = false;
  1162. var service = this.get('content.services').findProperty('serviceName', config.serviceName);
  1163. if (service && service.get('isSelected') && !service.get('isInstalled')) {
  1164. var serviceConfigs = this.get('stepConfigs').findProperty('serviceName', config.serviceName).configs;
  1165. var serviceDatabase = serviceConfigs.findProperty('name', config.serviceName.toLowerCase() + '_database').get('value');
  1166. if (!config.ignored.contains(serviceDatabase)) {
  1167. var filledProperties = App.db.get('tmp', config.serviceName + '_connection');
  1168. if (!filledProperties || App.isEmptyObject(filledProperties)) {
  1169. isConnectionNotTested = true;
  1170. } else {
  1171. for (var key in filledProperties) {
  1172. if (serviceConfigs.findProperty('name', key).get('value') !== filledProperties[key])
  1173. isConnectionNotTested = true;
  1174. }
  1175. }
  1176. }
  1177. }
  1178. config.isCheckIgnored = isConnectionNotTested;
  1179. }, this);
  1180. var ignoredServices = configMap.filterProperty('isCheckIgnored', true);
  1181. if (ignoredServices.length) {
  1182. var displayedServiceNames = ignoredServices.mapProperty('serviceName').map(function (serviceName) {
  1183. return this.get('content.services').findProperty('serviceName', serviceName).get('displayName');
  1184. }, this);
  1185. this.showDatabaseConnectionWarningPopup(displayedServiceNames, deferred);
  1186. }
  1187. else {
  1188. deferred.resolve();
  1189. }
  1190. return deferred;
  1191. },
  1192. showDatabaseConnectionWarningPopup: function (serviceNames, deferred) {
  1193. return App.ModalPopup.show({
  1194. header: Em.I18n.t('installer.step7.popup.database.connection.header'),
  1195. body: Em.I18n.t('installer.step7.popup.database.connection.body').format(serviceNames.join(', ')),
  1196. secondary: Em.I18n.t('common.cancel'),
  1197. primary: Em.I18n.t('common.proceedAnyway'),
  1198. onPrimary: function () {
  1199. deferred.resolve();
  1200. this._super();
  1201. },
  1202. onSecondary: function () {
  1203. deferred.reject();
  1204. this._super();
  1205. }
  1206. })
  1207. },
  1208. /**
  1209. * Proceed to the next step
  1210. **/
  1211. moveNext: function () {
  1212. App.router.send('next');
  1213. },
  1214. /**
  1215. * Click-handler on Next button
  1216. * Disable "Submit"-button while server-side processes are running
  1217. * @method submit
  1218. */
  1219. submit: function () {
  1220. if (this.get('isSubmitDisabled')) {
  1221. return;
  1222. }
  1223. var self = this;
  1224. this.set('submitButtonClicked', true);
  1225. this.serverSideValidation().done(function () {
  1226. self.checkDatabaseConnectionTest().done(function () {
  1227. self.resolveHiveMysqlDatabase();
  1228. self.set('submitButtonClicked', false);
  1229. });
  1230. }).fail(function (value) {
  1231. if ("invalid_configs" == value) {
  1232. self.set('submitButtonClicked', false);
  1233. } else {
  1234. // Failed due to validation mechanism failure.
  1235. // Should proceed with other checks
  1236. self.checkDatabaseConnectionTest().done(function () {
  1237. self.resolveHiveMysqlDatabase();
  1238. self.set('submitButtonClicked', false);
  1239. });
  1240. }
  1241. });
  1242. }
  1243. });