step7_controller.js 48 KB

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