step7_controller.js 49 KB

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