step7_controller.js 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617
  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. /**
  29. * @typedef {object} masterComponentHost
  30. * @property {string} component
  31. * @property {string} hostName
  32. * @property {boolean} isInstalled is component already installed on the this host or just going to be installed
  33. */
  34. /**
  35. * @typedef {object} topologyLocalDB
  36. * @property {object[]} hosts list of hosts with information of their disks usage and dirs
  37. * @property {masterComponentHost[]} masterComponentHosts
  38. * @property {?object[]} slaveComponentHosts
  39. */
  40. App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.EnhancedConfigsMixin, App.ToggleIsRequiredMixin, App.GroupsMappingMixin, App.TrackRequestMixin, {
  41. name: 'wizardStep7Controller',
  42. /**
  43. * Contains all field properties that are viewed in this step
  44. * @type {object[]}
  45. */
  46. stepConfigs: [],
  47. hash: null,
  48. selectedService: null,
  49. addMiscTabToPage: true,
  50. /**
  51. * Is Submit-click processing now
  52. * @type {bool}
  53. */
  54. submitButtonClicked: false,
  55. isRecommendedLoaded: false,
  56. /**
  57. * used in services_config.js view to mark a config with security icon
  58. */
  59. secureConfigs: require('data/HDP2/secure_mapping'),
  60. /**
  61. * If configChangeObserver Modal is shown
  62. * @type {bool}
  63. */
  64. miscModalVisible: false,
  65. overrideToAdd: null,
  66. /**
  67. * Is installer controller used
  68. * @type {bool}
  69. */
  70. isInstaller: true,
  71. /**
  72. * List of config groups
  73. * @type {object[]}
  74. */
  75. configGroups: [],
  76. /**
  77. * List of config group to be deleted
  78. * @type {object[]}
  79. */
  80. groupsToDelete: [],
  81. preSelectedConfigGroup: null,
  82. /**
  83. * Currently selected config group
  84. * @type {object}
  85. */
  86. selectedConfigGroup: null,
  87. /**
  88. * Config tags of actually installed services
  89. * @type {array}
  90. */
  91. serviceConfigTags: [],
  92. /**
  93. * Are applied to service configs loaded
  94. * @type {bool}
  95. */
  96. isAppliedConfigLoaded: true,
  97. isConfigsLoaded: Em.computed.and('wizardController.stackConfigsLoaded', 'isAppliedConfigLoaded'),
  98. transitionInProgress: Em.computed.alias('App.router.btnClickInProgress'),
  99. /**
  100. * PreInstall Checks allowed only for Install
  101. * @type {boolean}
  102. */
  103. supportsPreInstallChecks: function () {
  104. return App.get('supports.preInstallChecks') && 'installerController' === this.get('content.controllerName');
  105. }.property('App.supports.preInstallChecks', 'wizardController.name'),
  106. /**
  107. * Number of errors in the configs in the selected service
  108. * @type {number}
  109. */
  110. errorsCount: function() {
  111. return this.get('selectedService.configsWithErrors').filter(function(c) {
  112. return Em.isNone(c.get('widget'));
  113. }).length;
  114. }.property('selectedService.configsWithErrors.length'),
  115. /**
  116. * Should Next-button be disabled
  117. * @type {bool}
  118. */
  119. isSubmitDisabled: function () {
  120. if (!this.get('stepConfigs.length')) return true;
  121. if (this.get('submitButtonClicked')) return true;
  122. if (App.get('router.btnClickInProgress')) return true;
  123. return !this.get('stepConfigs').filterProperty('showConfig', true).everyProperty('errorCount', 0) || this.get("miscModalVisible");
  124. }.property('stepConfigs.@each.errorCount', 'miscModalVisible', 'submitButtonClicked', 'App.router.btnClickInProgress'),
  125. /**
  126. * List of selected to install service names
  127. * @type {string[]}
  128. */
  129. selectedServiceNames: function () {
  130. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).mapProperty('serviceName');
  131. }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
  132. /**
  133. * List of installed and selected to install service names
  134. * @type {string[]}
  135. */
  136. allSelectedServiceNames: function () {
  137. return this.get('content.services').filter(function (service) {
  138. return service.get('isInstalled') || service.get('isSelected');
  139. }).mapProperty('serviceName');
  140. }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
  141. /**
  142. * List of installed service names
  143. * @type {string[]}
  144. */
  145. installedServiceNames: function () {
  146. var serviceNames = this.get('content.services').filterProperty('isInstalled').mapProperty('serviceName');
  147. if (this.get('content.controllerName') !== 'installerController') {
  148. serviceNames = serviceNames.filter(function (_serviceName) {
  149. return !App.get('services.noConfigTypes').contains(_serviceName);
  150. });
  151. }
  152. return serviceNames;
  153. }.property('content.services').cacheable(),
  154. installedServices: function () {
  155. var self = this;
  156. return App.StackService.find().toArray().toMapByCallback('serviceName', function (item) {
  157. return self.get('installedServiceNames').contains(item.get('serviceName'));
  158. });
  159. }.property('installedServiceNames.length'),
  160. /**
  161. * List of master components
  162. * @type {Ember.Enumerable}
  163. */
  164. masterComponentHosts: Em.computed.alias('content.masterComponentHosts'),
  165. /**
  166. * List of slave components
  167. * @type {Ember.Enumerable}
  168. */
  169. slaveComponentHosts: Em.computed.alias('content.slaveGroupProperties'),
  170. /**
  171. * Filter text will be located here
  172. * @type {string}
  173. */
  174. filter: '',
  175. /**
  176. * Defines if configs can be editable
  177. * @type {boolean}
  178. */
  179. canEdit: true,
  180. /**
  181. * list of dependencies that are user to set init value of config
  182. *
  183. * @type {Object}
  184. */
  185. configDependencies: function() {
  186. var dependencies = {};
  187. var hiveMetastore = App.configsCollection.getConfigByName('hive.metastore.uris', 'hive-site.xml');
  188. var clientPort = App.configsCollection.getConfigByName('clientPort', 'zoo.cfg.xml');
  189. var atlasTls = App.configsCollection.getConfigByName('atlas.enableTLS', 'application-properties.xml');
  190. var atlasHttpPort = App.configsCollection.getConfigByName('atlas.server.http.port', 'application-properties.xml');
  191. var atlasHttpsPort = App.configsCollection.getConfigByName('atlas.server.https.port', 'application-properties.xml');
  192. if (hiveMetastore) dependencies['hive.metastore.uris'] = hiveMetastore.recommendedValue;
  193. if (clientPort) dependencies.clientPort = clientPort.recommendedValue;
  194. if (atlasTls) dependencies['atlas.enableTLS'] = atlasTls.recommendedValue;
  195. if (atlasHttpPort) dependencies['atlas.server.http.port'] = atlasHttpPort.recommendedValue;
  196. if (atlasHttpsPort) dependencies['atlas.server.https.port'] = atlasHttpsPort.recommendedValue;
  197. return dependencies;
  198. }.property(),
  199. /**
  200. * List of filters for config properties to populate filter combobox
  201. */
  202. propertyFilters: [
  203. {
  204. attributeName: 'isOverridden',
  205. attributeValue: true,
  206. caption: 'common.combobox.dropdown.overridden'
  207. },
  208. {
  209. attributeName: 'isFinal',
  210. attributeValue: true,
  211. caption: 'common.combobox.dropdown.final'
  212. },
  213. {
  214. attributeName: 'hasIssues',
  215. attributeValue: true,
  216. caption: 'common.combobox.dropdown.issues'
  217. }
  218. ],
  219. issuesFilterText: function () {
  220. return !this.get('transitionInProgress') && this.get('issuesFilterSelected') ?
  221. Em.I18n.t('installer.step7.showingPropertiesWithIssues') : '';
  222. }.property('isSubmitDisabled', 'submitButtonClicked', 'filterColumns.@each.selected'),
  223. /**
  224. * @type {string}
  225. */
  226. issuesFilterLinkText: function () {
  227. var issuesAttrSelected = this.get('issuesFilterSelected');
  228. if (!this.get('transitionInProgress')) {
  229. if (issuesAttrSelected) {
  230. return Em.I18n.t('installer.step7.showAllProperties');
  231. }
  232. if (this.get('hasStepConfigIssues')) {
  233. return Em.I18n.t('installer.step7.showPropertiesWithIssues');
  234. }
  235. }
  236. return '';
  237. }.property('isSubmitDisabled', 'submitButtonClicked', 'filterColumns.@each.selected'),
  238. /**
  239. * Dropdown menu items in filter combobox
  240. */
  241. filterColumns: function () {
  242. return this.get('propertyFilters').map(function (filter) {
  243. return Ember.Object.create({
  244. attributeName: filter.attributeName,
  245. attributeValue: filter.attributeValue,
  246. name: this.t(filter.caption),
  247. selected: false
  248. });
  249. }, this);
  250. }.property('propertyFilters'),
  251. /**
  252. * Clear controller's properties:
  253. * <ul>
  254. * <li>stepConfigs</li>
  255. * <li>filter</li>
  256. * </ul>
  257. * and deselect all <code>filterColumns</code>
  258. * @method clearStep
  259. */
  260. clearStep: function () {
  261. this.abortRequests();
  262. this.setProperties({
  263. configValidationGlobalMessage: [],
  264. submitButtonClicked: false,
  265. isSubmitDisabled: true,
  266. isRecommendedLoaded: false,
  267. initialRecommendations: []
  268. });
  269. this.get('stepConfigs').clear();
  270. this.set('filter', '');
  271. this.get('filterColumns').setEach('selected', false);
  272. },
  273. /**
  274. * Generate "finger-print" for current <code>stepConfigs[0]</code>
  275. * Used to determine, if user has some unsaved changes (comparing with <code>hash</code>)
  276. * @returns {string|null}
  277. * @method getHash
  278. */
  279. getHash: function () {
  280. if (!this.get('stepConfigs')[0]) {
  281. return null;
  282. }
  283. var hash = {};
  284. this.get('stepConfigs').forEach(function(stepConfig){
  285. stepConfig.configs.forEach(function (config) {
  286. hash[config.get('name')] = {value: config.get('value'), overrides: [], isFinal: config.get('isFinal')};
  287. if (!config.get('overrides')) return;
  288. if (!config.get('overrides.length')) return;
  289. config.get('overrides').forEach(function (override) {
  290. hash[config.get('name')].overrides.push(override.get('value'));
  291. });
  292. });
  293. });
  294. return JSON.stringify(hash);
  295. },
  296. /**
  297. * Are some changes available
  298. */
  299. hasChanges: function () {
  300. return this.get('hash') !== this.getHash();
  301. },
  302. /**
  303. * load all overrides for all config groups
  304. *
  305. * @returns {*|$.ajax}
  306. */
  307. loadOverrides: function() {
  308. return App.ajax.send({
  309. name: 'service.serviceConfigVersions.get.current.not.default',
  310. sender: this,
  311. success: 'parseOverrides'
  312. })
  313. },
  314. /**
  315. * add overriden configs to stepConfigs
  316. *
  317. * @param data
  318. */
  319. parseOverrides: function(data) {
  320. var self = this;
  321. data.items.forEach(function(group) {
  322. var stepConfig = self.get('stepConfigs').findProperty('serviceName', group.service_name),
  323. serviceConfigs = stepConfig.get('configs'),
  324. configGroup = App.ServiceConfigGroup.find().filterProperty('serviceName', group.service_name).findProperty('name', group.group_name);
  325. var isEditable = self.get('canEdit') && configGroup.get('name') === stepConfig.get('selectedConfigGroup.name');
  326. group.configurations.forEach(function (config) {
  327. for (var prop in config.properties) {
  328. var fileName = App.config.getOriginalFileName(config.type);
  329. var serviceConfig = serviceConfigs.filterProperty('name', prop).findProperty('filename', fileName);
  330. if (serviceConfig) {
  331. var value = App.config.formatPropertyValue(serviceConfig, config.properties[prop]);
  332. var isFinal = !!(config.properties_attributes && config.properties_attributes.final && config.properties_attributes.final[prop]);
  333. App.config.createOverride(serviceConfig, {
  334. "value": value,
  335. "savedValue": value,
  336. "isFinal": isFinal,
  337. "savedIsFinal": isFinal,
  338. "isEditable": isEditable
  339. }, configGroup);
  340. } else {
  341. serviceConfigs.push(App.config.createCustomGroupConfig({
  342. propertyName: prop,
  343. filename: fileName,
  344. value: config.properties[prop],
  345. savedValue: config.properties[prop],
  346. isEditable: isEditable
  347. }, configGroup));
  348. }
  349. }
  350. });
  351. });
  352. this.onLoadOverrides();
  353. },
  354. onLoadOverrides: function () {
  355. this.get('stepConfigs').forEach(function(stepConfig) {
  356. stepConfig.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName', stepConfig.get('serviceName')));
  357. stepConfig.get('configGroups').filterProperty('isDefault', false).forEach(function (configGroup) {
  358. configGroup.set('hash', this.get('wizardController').getConfigGroupHash(configGroup));
  359. }, this);
  360. this.addOverride(stepConfig);
  361. // override if a property isRequired or not
  362. this.overrideConfigIsRequired(stepConfig);
  363. }, this);
  364. console.timeEnd('loadConfigGroups execution time: ');
  365. },
  366. /**
  367. * Set <code>isEditable</code>-property to <code>serviceConfigProperty</code>
  368. * Based on user's permissions and selected config group
  369. * @param {Ember.Object} serviceConfigProperty
  370. * @param {bool} defaultGroupSelected
  371. * @returns {Ember.Object} Updated config-object
  372. * @method _updateIsEditableFlagForConfig
  373. */
  374. _updateIsEditableFlagForConfig: function (serviceConfigProperty, defaultGroupSelected) {
  375. if (App.isAuthorized('AMBARI.ADD_DELETE_CLUSTERS')) {
  376. if (App.get('isKerberosEnabled') && serviceConfigProperty.get('isConfigIdentity')) {
  377. serviceConfigProperty.set('isEditable', false);
  378. } else if (defaultGroupSelected && !Em.get(serviceConfigProperty, 'group')) {
  379. if (serviceConfigProperty.get('serviceName') === 'MISC') {
  380. var service = App.config.get('serviceByConfigTypeMap')[App.config.getConfigTagFromFileName(serviceConfigProperty.get('filename'))];
  381. serviceConfigProperty.set('isEditable', service && !this.get('installedServiceNames').contains(service.get('serviceName')));
  382. } else {
  383. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isEditable') && serviceConfigProperty.get('isReconfigurable'));
  384. }
  385. } else if (!(Em.get(serviceConfigProperty, 'group') && Em.get(serviceConfigProperty, 'group.name') === this.get('selectedConfigGroup.name'))) {
  386. serviceConfigProperty.set('isEditable', false);
  387. }
  388. } else {
  389. serviceConfigProperty.set('isEditable', false);
  390. }
  391. return serviceConfigProperty;
  392. },
  393. /**
  394. * Set configs with overrides, recommended defaults to stepConfig
  395. * @param {Ember.Object} stepConfig
  396. * @method loadComponentConfigs
  397. */
  398. addOverride: function (stepConfig) {
  399. var overrideToAdd = this.get('overrideToAdd');
  400. if (overrideToAdd) {
  401. overrideToAdd = stepConfig.get('configs').filterProperty('filename', overrideToAdd.filename)
  402. .findProperty('name', overrideToAdd.name);
  403. if (overrideToAdd) {
  404. App.config.createOverride(overrideToAdd, {isEditable: true}, stepConfig.get('selectedConfigGroup'));
  405. this.set('overrideToAdd', null);
  406. }
  407. }
  408. },
  409. /**
  410. * On load function
  411. * @method loadStep
  412. */
  413. loadStep: function () {
  414. if (!this.get('isConfigsLoaded')) {
  415. return;
  416. }
  417. console.time('wizard loadStep: ');
  418. this.clearStep();
  419. var self = this;
  420. App.config.setPreDefinedServiceConfigs(this.get('addMiscTabToPage'));
  421. var storedConfigs = this.get('content.serviceConfigProperties');
  422. var configs = storedConfigs && storedConfigs.length ? storedConfigs : App.configsCollection.getAll();
  423. this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
  424. if (this.get('wizardController.name') === 'addServiceController' && !storedConfigs) {
  425. App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags')).done(function (loadedConfigs) {
  426. configs = self.setInstalledServiceConfigs(configs, loadedConfigs, self.get('installedServiceNames'));
  427. self.applyServicesConfigs(configs);
  428. });
  429. } else {
  430. this.applyServicesConfigs(configs);
  431. }
  432. },
  433. /**
  434. * Update hawq configuration depending on the state of the cluster
  435. * @param {Array} configs
  436. */
  437. updateHawqConfigs: function (configs) {
  438. if (this.get('wizardController.name') === 'addServiceController') {
  439. if (App.get('isHaEnabled')) this.addHawqConfigsOnNnHa(configs);
  440. if (App.get('isRMHaEnabled')) this.addHawqConfigsOnRMHa(configs);
  441. }
  442. if (this.get('content.hosts') && Object.keys(this.get('content.hosts')).length === 1) this.removeHawqStandbyHostAddressConfig(configs);
  443. return configs
  444. },
  445. /**
  446. * Remove hawq_standby_address_host config from HAWQ configs
  447. * @param {Array} configs
  448. */
  449. removeHawqStandbyHostAddressConfig: function(configs) {
  450. var hawqStandbyAddressHostIndex = configs.indexOf(configs.findProperty('name', 'hawq_standby_address_host'));
  451. if (hawqStandbyAddressHostIndex > -1) configs.removeAt(hawqStandbyAddressHostIndex) ;
  452. return configs
  453. },
  454. applyServicesConfigs: function (configs) {
  455. console.time('applyServicesConfigs execution time: ');
  456. if (!this.get('installedServiceNames').contains('HAWQ') && this.get('allSelectedServiceNames').contains('HAWQ')) {
  457. this.updateHawqConfigs(configs);
  458. }
  459. if (App.get('isKerberosEnabled') && this.get('wizardController.name') === 'addServiceController') {
  460. this.addKerberosDescriptorConfigs(configs, this.get('wizardController.kerberosDescriptorConfigs') || []);
  461. }
  462. App.configTheme.resolveConfigThemeConditions(configs);
  463. var stepConfigs = this.createStepConfigs();
  464. var serviceConfigs = this.renderConfigs(stepConfigs, configs);
  465. // if HA is enabled -> Make some reconfigurations
  466. if (this.get('wizardController.name') === 'addServiceController') {
  467. this.updateComponentActionConfigs(configs, serviceConfigs);
  468. if (App.get('isHaEnabled')) {
  469. serviceConfigs = this._reconfigureServicesOnNnHa(serviceConfigs);
  470. }
  471. }
  472. this.set('stepConfigs', serviceConfigs);
  473. this.checkHostOverrideInstaller();
  474. this.selectProperService();
  475. var rangerService = App.StackService.find().findProperty('serviceName', 'RANGER');
  476. if (rangerService && !rangerService.get('isInstalled') && !rangerService.get('isSelected')) {
  477. App.config.removeRangerConfigs(this.get('stepConfigs'));
  478. }
  479. console.timeEnd('applyServicesConfigs execution time: ');
  480. console.time('loadConfigRecommendations execution time: ');
  481. this.loadConfigRecommendations(null, this.completeConfigLoading.bind(this));
  482. },
  483. /**
  484. *
  485. * Makes installed service's configs resulting into component actions (add/delete) non editable on Add Service Wizard
  486. * @param configs Object[]
  487. * @param stepConfigs Object[]
  488. * @private
  489. * @method updateComponentActionConfigs
  490. */
  491. updateComponentActionConfigs: function(configs, stepConfigs) {
  492. App.ConfigAction.find().forEach(function(item){
  493. var configName = item.get('configName');
  494. var fileName = item.get('fileName');
  495. var config = configs.filterProperty('filename', fileName).findProperty('name', configName);
  496. if (config) {
  497. var isServiceInstalled = App.Service.find().findProperty('serviceName', config.serviceName);
  498. // service already installed or is being added in add service wizard
  499. if (isServiceInstalled || stepConfigs.someProperty("serviceName", config.serviceName)) {
  500. var serviceConfigs = stepConfigs.findProperty('serviceName', config.serviceName).get('configs');
  501. var serviceConfig = serviceConfigs.filterProperty('filename', fileName).findProperty('name', configName);
  502. var notEditableText = " " + Em.I18n.t('installer.step7.addWizard.notEditable');
  503. serviceConfig.set('description', serviceConfig.get('description') + notEditableText);
  504. serviceConfig.set('isReconfigurable', false);
  505. serviceConfig.set('isEditable', false);
  506. serviceConfig.set('disabledAsComponentAction', true);
  507. config.isReconfigurable = false;
  508. config.isEditable = false;
  509. config.disabledAsComponentActio = true;
  510. }
  511. }
  512. }, this);
  513. },
  514. completeConfigLoading: function() {
  515. this.clearRecommendationsByServiceName(App.StackService.find().filter(function (s) {
  516. return s.get('isSelected') && !s.get('isInstalled');
  517. }).mapProperty('serviceName'));
  518. this.saveInitialRecommendations();
  519. this.set('isRecommendedLoaded', true);
  520. console.timeEnd('loadConfigRecommendations execution time: ');
  521. console.timeEnd('wizard loadStep: ');
  522. if (this.get('content.skipConfigStep')) {
  523. App.router.send('next');
  524. }
  525. this.set('hash', this.getHash());
  526. },
  527. /**
  528. * Update initialValues only while loading recommendations first time
  529. *
  530. * @param serviceName
  531. * @returns {boolean}
  532. * @override
  533. */
  534. updateInitialOnRecommendations: function(serviceName) {
  535. return this._super(serviceName) && !this.get('isRecommendedLoaded');
  536. },
  537. /**
  538. * Mark descriptor properties in configuration object.
  539. *
  540. * @param {Object[]} configs - config properties to change
  541. * @param {App.ServiceConfigProperty[]} descriptor - parsed kerberos descriptor
  542. * @method addKerberosDescriptorConfigs
  543. */
  544. addKerberosDescriptorConfigs: function (configs, descriptor) {
  545. descriptor.forEach(function (item) {
  546. var property = configs.findProperty('name', item.get('name'));
  547. if (property) {
  548. Em.setProperties(property, {
  549. isSecureConfig: true,
  550. displayName: Em.get(item, 'name'),
  551. isUserProperty: false,
  552. isOverridable: false,
  553. isConfigIdentity: Em.get(item, 'isConfigIdentity'),
  554. description: Em.get(item, 'isConfigIdentity')
  555. ? App.config.kerberosIdentitiesDescription(Em.get(property, 'description'))
  556. : Em.get(property, 'description'),
  557. category: 'Advanced ' + Em.get(item, 'filename')
  558. });
  559. }
  560. });
  561. },
  562. /**
  563. * Load config groups
  564. * and (if some services are already installed) load config groups for installed services
  565. * @method checkHostOverrideInstaller
  566. */
  567. checkHostOverrideInstaller: function () {
  568. if (this.get('wizardController.name') !== 'kerberosWizardController' && this.get('content.configGroups.length')) {
  569. this.restoreConfigGroups(this.get('content.configGroups'));
  570. } else {
  571. if (this.get('installedServiceNames').length > 0 && !this.get('wizardController.areInstalledConfigGroupsLoaded')) {
  572. console.time('loadConfigGroups execution time: ');
  573. this.loadConfigGroups(this.get('allSelectedServiceNames')).done(this.loadOverrides.bind(this));
  574. } else {
  575. App.store.commit();
  576. App.configGroupsMapper.map(null, false, this.get('allSelectedServiceNames'));
  577. this.onLoadOverrides();
  578. }
  579. }
  580. },
  581. /**
  582. * Create stepConfigs array with all info except configs list
  583. *
  584. * @return {Object[]}
  585. * @method createStepConfigs
  586. */
  587. createStepConfigs: function() {
  588. var stepConfigs = [];
  589. App.config.get('preDefinedServiceConfigs').forEach(function (service) {
  590. var serviceName = service.get('serviceName');
  591. if (['MISC'].concat(this.get('allSelectedServiceNames')).contains(serviceName)) {
  592. var serviceConfig = App.config.createServiceConfig(serviceName);
  593. serviceConfig.set('showConfig', App.StackService.find(serviceName).get('isInstallable'));
  594. if (this.get('wizardController.name') === 'addServiceController') {
  595. serviceConfig.set('selected', !this.get('installedServiceNames').concat('MISC').contains(serviceName));
  596. if (serviceName === 'MISC') {
  597. serviceConfig.set('configCategories', serviceConfig.get('configCategories').rejectProperty('name', 'Notifications'));
  598. }
  599. } else if (this.get('wizardController.name') === 'kerberosWizardController') {
  600. serviceConfig.set('showConfig', true);
  601. }
  602. stepConfigs.pushObject(serviceConfig);
  603. }
  604. }, this);
  605. return stepConfigs;
  606. },
  607. /**
  608. * For Namenode HA, HAWQ service requires additional config parameters in hdfs-client.xml
  609. * This method ensures that these additional parameters are added to hdfs-client.xml
  610. * @param configs existing configs on cluster
  611. * @returns {Object[]} existing configs + additional config parameters in hdfs-client.xml
  612. */
  613. addHawqConfigsOnNnHa: function(configs) {
  614. var nameService = configs.findProperty('id', App.config.configId('dfs.nameservices', 'hdfs-site')).value;
  615. var propertyNames = [
  616. 'dfs.nameservices',
  617. 'dfs.ha.namenodes.' + nameService,
  618. 'dfs.namenode.rpc-address.'+ nameService +'.nn1',
  619. 'dfs.namenode.rpc-address.'+ nameService +'.nn2',
  620. 'dfs.namenode.http-address.'+ nameService +'.nn1',
  621. 'dfs.namenode.http-address.'+ nameService +'.nn2'
  622. ];
  623. propertyNames.forEach(function(propertyName, propertyIndex) {
  624. var propertyFromHdfs = configs.findProperty('id', App.config.configId(propertyName, 'hdfs-site'));
  625. var newProperty = App.config.createDefaultConfig(propertyName, 'hdfs-client.xml', true);
  626. Em.setProperties(newProperty, {
  627. serviceName: 'HAWQ',
  628. description: propertyFromHdfs.description,
  629. displayName: propertyFromHdfs.displayName,
  630. displayType: 'string',
  631. index: propertyIndex,
  632. isOverridable: false,
  633. isReconfigurable: false,
  634. value: propertyFromHdfs.value,
  635. recommendedValue: propertyFromHdfs.recommendedValue
  636. });
  637. configs.push(App.ServiceConfigProperty.create(newProperty));
  638. });
  639. return configs;
  640. },
  641. /**
  642. * For ResourceManager HA, HAWQ service requires additional config parameters in yarn-client.xml
  643. * This method ensures that these additional parameters are added to yarn-client.xml
  644. * @param configs existing configs on cluster
  645. * @returns {Object[]} existing configs + additional config parameters in yarn-client.xml
  646. */
  647. addHawqConfigsOnRMHa: function(configs) {
  648. var rmHost1 = configs.findProperty('id', App.config.configId('yarn.resourcemanager.hostname.rm1', 'yarn-site')).value ;
  649. var rmHost2 = configs.findProperty('id', App.config.configId('yarn.resourcemanager.hostname.rm2', 'yarn-site')).value ;
  650. var yarnConfigToBeAdded = [
  651. {
  652. name: 'yarn.resourcemanager.ha',
  653. displayName: 'yarn.resourcemanager.ha',
  654. description: 'Comma separated yarn resourcemanager host addresses with port',
  655. port: '8032'
  656. },
  657. {
  658. name: 'yarn.resourcemanager.scheduler.ha',
  659. displayName: 'yarn.resourcemanager.scheduler.ha',
  660. description: 'Comma separated yarn resourcemanager scheduler addresses with port',
  661. port: '8030'
  662. }
  663. ];
  664. yarnConfigToBeAdded.forEach(function(propertyDetails) {
  665. var newProperty = App.config.createDefaultConfig(propertyDetails.name, 'yarn-client.xml', true);
  666. var value = rmHost1 + ':' + propertyDetails.port + ',' + rmHost2 + ':' + propertyDetails.port;
  667. Em.setProperties(newProperty, {
  668. serviceName: 'HAWQ',
  669. description: propertyDetails.description,
  670. displayName: propertyDetails.displayName,
  671. isOverridable: false,
  672. isReconfigurable: false,
  673. value: value,
  674. recommendedValue: value
  675. });
  676. configs.push(App.ServiceConfigProperty.create(newProperty));
  677. });
  678. return configs;
  679. },
  680. /**
  681. * render configs, distribute them by service
  682. * and wrap each in ServiceConfigProperty object
  683. * @param stepConfigs
  684. * @param configs
  685. * @return {App.ServiceConfig[]}
  686. */
  687. renderConfigs: function (stepConfigs, configs) {
  688. var localDB = {
  689. hosts: this.get('wizardController.content.hosts'),
  690. masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
  691. slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts'),
  692. selectedStack: {}
  693. };
  694. var selectedRepoVersion,
  695. repoVersion;
  696. if (this.get('wizardController.name') === 'addServiceController') {
  697. repoVersion = App.RepositoryVersion.find().filter(function(i) {
  698. return i.get('stackVersionType') === App.get('currentStackName') &&
  699. i.get('stackVersionNumber') === App.get('currentStackVersionNumber');
  700. })[0];
  701. if (repoVersion) {
  702. selectedRepoVersion = Em.get(repoVersion, 'repositoryVersion').split('-')[0];
  703. }
  704. } else {
  705. selectedRepoVersion = Em.getWithDefault(App.Stack.find().findProperty('isSelected', true) || {}, 'repositoryVersion', false);
  706. }
  707. if (selectedRepoVersion) {
  708. localDB.selectedStack = selectedRepoVersion;
  709. }
  710. var configsByService = {}, dependencies = this.get('configDependencies');
  711. configs.forEach(function (_config) {
  712. if (!configsByService[_config.serviceName]) {
  713. configsByService[_config.serviceName] = [];
  714. }
  715. var serviceConfigProperty = App.ServiceConfigProperty.create(_config);
  716. this.updateHostOverrides(serviceConfigProperty, _config);
  717. if (this.get('wizardController.name') === 'addServiceController') {
  718. this._updateIsEditableFlagForConfig(serviceConfigProperty, true);
  719. }
  720. if (!this.get('content.serviceConfigProperties.length') && !serviceConfigProperty.get('hasInitialValue')) {
  721. App.ConfigInitializer.initialValue(serviceConfigProperty, localDB, dependencies);
  722. }
  723. configsByService[_config.serviceName].pushObject(serviceConfigProperty);
  724. }, this);
  725. stepConfigs.forEach(function (service) {
  726. if (service.get('serviceName') === 'YARN') {
  727. configsByService[service.get('serviceName')] = App.config.addYarnCapacityScheduler(configsByService[service.get('serviceName')]);
  728. }
  729. service.set('configs', configsByService[service.get('serviceName')] || []);
  730. if (['addServiceController', 'installerController'].contains(this.get('wizardController.name'))) {
  731. this.addHostNamesToConfigs(service, localDB.masterComponentHosts, localDB.slaveComponentHosts);
  732. }
  733. }, this);
  734. return stepConfigs;
  735. },
  736. /**
  737. * Add host name properties to appropriate categories (for installer and add service)
  738. *
  739. * @param {Object} serviceConfig
  740. * @param {Object[]} masterComponents - info from localStorage
  741. * @param {Object[]} slaveComponents - info from localStorage
  742. */
  743. addHostNamesToConfigs: function(serviceConfig, masterComponents, slaveComponents) {
  744. serviceConfig.get('configCategories').forEach(function(c) {
  745. if (c.showHost) {
  746. var componentName = c.name;
  747. var value = this.getComponentHostValue(componentName, masterComponents, slaveComponents);
  748. var stackComponent = App.StackServiceComponent.find(componentName);
  749. var hProperty = App.config.createHostNameProperty(serviceConfig.get('serviceName'), componentName, value, stackComponent);
  750. var newConfigName = Em.get(hProperty, 'name');
  751. if (!serviceConfig.get('configs').someProperty('name', newConfigName)) {
  752. serviceConfig.get('configs').push(App.ServiceConfigProperty.create(hProperty));
  753. }
  754. }
  755. }, this);
  756. },
  757. /**
  758. * Method to get host for master or slave component
  759. *
  760. * @param componentName
  761. * @param masterComponents
  762. * @param slaveComponents
  763. * @returns {Array}
  764. */
  765. getComponentHostValue: function(componentName, masterComponents, slaveComponents) {
  766. var value = [];
  767. var masters = masterComponents && masterComponents.filterProperty('component', componentName);
  768. if (masters.length) {
  769. value = masters.mapProperty('hostName');
  770. } else {
  771. var slaves = slaveComponents && slaveComponents.findProperty('componentName', componentName);
  772. if (slaves) {
  773. value = slaves.hosts.mapProperty('hostName');
  774. }
  775. }
  776. return value || [];
  777. },
  778. /**
  779. * create new child configs from overrides, attach them to parent config
  780. * override - value of config, related to particular host(s)
  781. * @param configProperty
  782. * @param storedConfigProperty
  783. */
  784. updateHostOverrides: function (configProperty, storedConfigProperty) {
  785. if (!Em.isEmpty(storedConfigProperty.overrides)) {
  786. var overrides = [];
  787. storedConfigProperty.overrides.forEach(function (overrideEntry) {
  788. // create new override with new value
  789. var newSCP = App.ServiceConfigProperty.create(configProperty);
  790. newSCP.set('value', overrideEntry.value);
  791. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  792. newSCP.set('parentSCP', configProperty);
  793. overrides.pushObject(newSCP);
  794. });
  795. configProperty.set('overrides', overrides);
  796. }
  797. },
  798. /**
  799. * When NameNode HA is enabled some configs based on <code>dfs.nameservices</code> should be changed
  800. * This happens only if service is added AFTER NN HA is enabled
  801. *
  802. * @param {App.ServiceConfig[]} serviceConfigs
  803. * @method _reconfigureServiceOnNnHa
  804. * @private
  805. * @returns {App.ServiceConfig[]}
  806. */
  807. _reconfigureServicesOnNnHa: function (serviceConfigs) {
  808. var selectedServiceNames = this.get('selectedServiceNames');
  809. var nameServiceId = serviceConfigs.findProperty('serviceName', 'HDFS').configs.findProperty('name', 'dfs.nameservices');
  810. if (nameServiceId) {
  811. Em.A([
  812. {
  813. serviceName: 'HBASE',
  814. configToUpdate: 'hbase.rootdir'
  815. },
  816. {
  817. serviceName: 'ACCUMULO',
  818. configToUpdate: 'instance.volumes'
  819. },
  820. {
  821. serviceName: 'HAWQ',
  822. configToUpdate: 'hawq_dfs_url',
  823. regexPattern: /(^.*:[0-9]+)(?=\/)/,
  824. replacementValue: nameServiceId.get('value')
  825. }
  826. ]).forEach(function (c) {
  827. if (selectedServiceNames.contains(c.serviceName) && nameServiceId) {
  828. var cfg = serviceConfigs.findProperty('serviceName', c.serviceName).configs.findProperty('name', c.configToUpdate);
  829. var regexPattern = /\/\/.*:[0-9]+/i;
  830. var replacementValue = '//' + nameServiceId.get('value');
  831. if (!Em.isNone(c.regexPattern) && !Em.isNone(c.replacementValue)) {
  832. regexPattern = c.regexPattern;
  833. replacementValue = c.replacementValue;
  834. }
  835. var newValue = cfg.get('value').replace(regexPattern, replacementValue);
  836. cfg.setProperties({
  837. value: newValue,
  838. recommendedValue: newValue
  839. });
  840. }
  841. });
  842. }
  843. return serviceConfigs;
  844. },
  845. /**
  846. * Select first addable service for <code>addServiceWizard</code>
  847. * Select first service at all in other cases
  848. * @method selectProperService
  849. */
  850. selectProperService: function () {
  851. if (this.get('wizardController.name') === 'addServiceController') {
  852. this.set('selectedService', this.get('stepConfigs').filterProperty('selected', true).get('firstObject'));
  853. } else {
  854. this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
  855. }
  856. },
  857. /**
  858. * Load config tags
  859. * @return {$.ajax|null}
  860. * @method getConfigTags
  861. */
  862. getConfigTags: function () {
  863. this.set('isAppliedConfigLoaded', false);
  864. return App.ajax.send({
  865. name: 'config.tags',
  866. sender: this,
  867. success: 'getConfigTagsSuccess'
  868. });
  869. },
  870. /**
  871. * Success callback for config tags request
  872. * Updates <code>serviceConfigTags</code> with tags received from server
  873. * @param {object} data
  874. * @method getConfigTagsSuccess
  875. */
  876. getConfigTagsSuccess: function (data) {
  877. var installedServiceSites = [];
  878. App.StackService.find().filterProperty('isInstalled').forEach(function (service) {
  879. if (!service.get('configTypes')) return;
  880. var configTypes = Object.keys(service.get('configTypes'));
  881. installedServiceSites = installedServiceSites.concat(configTypes);
  882. }, this);
  883. installedServiceSites = installedServiceSites.uniq();
  884. var serviceConfigTags = [];
  885. for (var site in data.Clusters.desired_configs) {
  886. if (data.Clusters.desired_configs.hasOwnProperty(site)) {
  887. if (installedServiceSites.contains(site) || site === 'cluster-env') {
  888. serviceConfigTags.push({
  889. siteName: site,
  890. tagName: data.Clusters.desired_configs[site].tag,
  891. newTagName: null
  892. });
  893. }
  894. }
  895. }
  896. this.set('serviceConfigTags', serviceConfigTags);
  897. this.set('isAppliedConfigLoaded', true);
  898. },
  899. /**
  900. * set configs actual values from server
  901. * @param configs
  902. * @param configsByTags
  903. * @param installedServiceNames
  904. * @method setInstalledServiceConfigs
  905. */
  906. setInstalledServiceConfigs: function (configs, configsByTags, installedServiceNames) {
  907. var configsMap = {};
  908. configsByTags.forEach(function (configSite) {
  909. configsMap[configSite.type] = configSite.properties || {};
  910. });
  911. var allConfigs = configs.filter(function (_config) {
  912. // filter out alert_notification configs on add service //TODO find better place for this!
  913. if (_config.filename === 'alert_notification') return false;
  914. if (['MISC'].concat(installedServiceNames).contains(_config.serviceName)) {
  915. var type = _config.filename ? App.config.getConfigTagFromFileName(_config.filename) : null;
  916. var mappedConfigValue = type && configsMap[type] ? configsMap[type][_config.name] : null;
  917. if (Em.isNone(mappedConfigValue)) {
  918. //for now ranger plugin properties are not sending by recommendations if they are missed - it should be added
  919. return _config.serviceName === 'MISC' || /^ranger-/.test(_config.filename);
  920. }
  921. if (_config.savedValue != mappedConfigValue) {
  922. _config.savedValue = App.config.formatPropertyValue(_config, mappedConfigValue);
  923. }
  924. _config.value = App.config.formatPropertyValue(_config, mappedConfigValue);
  925. _config.hasInitialValue = true;
  926. this.updateDependencies(_config);
  927. delete configsMap[type][_config.name];
  928. return true;
  929. }
  930. return true;
  931. }, this);
  932. //add user properties
  933. Em.keys(configsMap).forEach(function (filename) {
  934. Em.keys(configsMap[filename]).forEach(function (propertyName) {
  935. allConfigs.push(App.config.createDefaultConfig(propertyName, App.config.getOriginalFileName(filename), false, {
  936. value: configsMap[filename][propertyName],
  937. savedValue: configsMap[filename][propertyName],
  938. hasInitialValue: true
  939. }));
  940. });
  941. });
  942. return allConfigs;
  943. },
  944. /**
  945. * update dependencies according to current config value
  946. *
  947. * @param config
  948. */
  949. updateDependencies: function(config) {
  950. if (config.filename === 'hive-site.xml') {
  951. if (config.name === 'hive.metastore.uris') {
  952. this.get('configDependencies')['hive.metastore.uris'] = config.savedValue;
  953. }
  954. else
  955. if (config.name === 'clientPort') {
  956. this.get('configDependencies').clientPort = config.savedValue;
  957. }
  958. }
  959. if (config.filename === 'application-properties.xml') {
  960. if (this.get('configDependencies').hasOwnProperty(config.name)) {
  961. this.get('configDependencies')[config.name] = config.savedValue;
  962. }
  963. }
  964. },
  965. /**
  966. * Add group ids to <code>groupsToDelete</code>
  967. * Also save <code>groupsToDelete</code> to local storage
  968. * @param {Ember.Object[]} groups
  969. * @method setGroupsToDelete
  970. */
  971. setGroupsToDelete: function (groups) {
  972. var groupsToDelete = this.get('groupsToDelete');
  973. groups.forEach(function (group) {
  974. if (!group.get('isTemporary')) {
  975. groupsToDelete.push({
  976. id: group.get('id')
  977. });
  978. }
  979. });
  980. this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
  981. },
  982. /**
  983. * Update <code>configGroups</code> with selected service configGroups
  984. * Also set default group to first position
  985. * Update <code>selectedConfigGroup</code> with new default group
  986. * @method selectedServiceObserver
  987. */
  988. selectedServiceObserver: function () {
  989. if (this.get('selectedService') && this.get('selectedService.serviceName') !== 'MISC') {
  990. var serviceGroups = this.get('selectedService.configGroups');
  991. serviceGroups.forEach(function (item, index, array) {
  992. if (item.isDefault) {
  993. array.unshift(item);
  994. array.splice(index + 1, 1);
  995. }
  996. });
  997. this.set('configGroups', serviceGroups);
  998. this.set('selectedConfigGroup', serviceGroups.findProperty('isDefault'));
  999. }
  1000. }.observes('selectedService.configGroups.[]'),
  1001. /**
  1002. * load default groups for each service in case of initial load
  1003. * @param serviceConfigGroups
  1004. * @method restoreConfigGroups
  1005. */
  1006. restoreConfigGroups: function (serviceConfigGroups) {
  1007. var services = this.get('stepConfigs');
  1008. services.forEach(function (service) {
  1009. if (service.get('serviceName') === 'MISC') return;
  1010. var serviceRawGroups = serviceConfigGroups.filterProperty('service_name', service.serviceName);
  1011. if (serviceRawGroups.length) {
  1012. App.store.commit();
  1013. App.store.loadMany(App.ServiceConfigGroup, serviceRawGroups);
  1014. App.store.commit();
  1015. serviceRawGroups.forEach(function(item){
  1016. var modelGroup = App.ServiceConfigGroup.find(item.id);
  1017. modelGroup.set('properties', []);
  1018. item.properties.forEach(function (propertyData) {
  1019. var overriddenSCP, parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name', propertyData.name);
  1020. if (parentSCP) {
  1021. App.config.createOverride(parentSCP, propertyData, modelGroup)
  1022. } else {
  1023. overriddenSCP = App.config.createCustomGroupConfig({
  1024. propertyName: propertyData.name,
  1025. filename: propertyData.filename,
  1026. value: propertyData.value,
  1027. savedValue: propertyData.value,
  1028. isEditable: false
  1029. }, modelGroup);
  1030. this.get('stepConfigs').findProperty('serviceName', service.serviceName).get('configs').pushObject(overriddenSCP);
  1031. }
  1032. }, this);
  1033. }, this);
  1034. service.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName', service.get('serviceName')));
  1035. }
  1036. }, this);
  1037. },
  1038. /**
  1039. * Click-handler on config-group to make it selected
  1040. * @param {object} event
  1041. * @method selectConfigGroup
  1042. */
  1043. selectConfigGroup: function (event) {
  1044. this.set('selectedConfigGroup', event.context);
  1045. },
  1046. /**
  1047. * Rebuild list of configs switch of config group:
  1048. * on default - display all configs from default group and configs from non-default groups as disabled
  1049. * on non-default - display all from default group as disabled and configs from selected non-default group
  1050. * @method switchConfigGroupConfigs
  1051. */
  1052. switchConfigGroupConfigs: function () {
  1053. var serviceConfigs = this.get('selectedService.configs'),
  1054. selectedGroup = this.get('selectedConfigGroup'),
  1055. overrides = [];
  1056. if (!selectedGroup) return;
  1057. var displayedConfigGroups = this._getDisplayedConfigGroups();
  1058. displayedConfigGroups.forEach(function (group) {
  1059. overrides.pushObjects(group.get('properties'));
  1060. });
  1061. serviceConfigs.forEach(function (config) {
  1062. this._setEditableValue(config);
  1063. this._setOverrides(config, overrides);
  1064. }, this);
  1065. }.observes('selectedConfigGroup'),
  1066. /**
  1067. * Get list of config groups to display
  1068. * Returns empty array if no <code>selectedConfigGroup</code>
  1069. * @return {Array}
  1070. * @method _getDisplayedConfigGroups
  1071. */
  1072. _getDisplayedConfigGroups: function () {
  1073. var selectedGroup = this.get('selectedConfigGroup');
  1074. if (!selectedGroup) return [];
  1075. return selectedGroup.get('isDefault') ?
  1076. this.get('selectedService.configGroups').filterProperty('isDefault', false) :
  1077. [this.get('selectedConfigGroup')];
  1078. },
  1079. /**
  1080. * Set <code>isEditable</code> property to <code>config</code>
  1081. * @param {Ember.Object} config
  1082. * @return {Ember.Object} updated config-object
  1083. * @method _setEditableValue
  1084. */
  1085. _setEditableValue: function (config) {
  1086. var selectedGroup = this.get('selectedConfigGroup');
  1087. if (!selectedGroup) return config;
  1088. if (App.get('isKerberosEnabled') && config.get('isConfigIdentity')) {
  1089. config.set('isEditable', false);
  1090. } else {
  1091. var isEditable = config.get('isEditable'),
  1092. isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName'));
  1093. if (isServiceInstalled) {
  1094. isEditable = config.get('isReconfigurable') && selectedGroup.get('isDefault') && !config.get('disabledAsComponentAction');
  1095. } else {
  1096. isEditable = selectedGroup.get('isDefault') && !config.get('disabledAsComponentAction');
  1097. }
  1098. if (config.get('group')) {
  1099. isEditable = config.get('group.name') === this.get('selectedConfigGroup.name');
  1100. }
  1101. config.set('isEditable', isEditable);
  1102. }
  1103. return config;
  1104. },
  1105. /**
  1106. * Set <code>overrides</code> property to <code>config</code>
  1107. * @param {Ember.Object} config
  1108. * @param {Ember.Enumerable} overrides
  1109. * @returns {Ember.Object}
  1110. * @method _setOverrides
  1111. */
  1112. _setOverrides: function (config, overrides) {
  1113. if (config.get('group')) return config;
  1114. var selectedGroup = this.get('selectedConfigGroup'),
  1115. overrideToAdd = this.get('overrideToAdd'),
  1116. configOverrides = overrides.filterProperty('id', config.get('id'));
  1117. if (!selectedGroup) return config;
  1118. if (overrideToAdd && overrideToAdd.get('id') === config.get('id')) {
  1119. var valueForOverride = (config.get('widget') || config.get('displayType') === 'checkbox') ? config.get('value') : '';
  1120. var group = this.get('selectedService.configGroups').findProperty('name', selectedGroup.get('name'));
  1121. var newSCP = App.config.createOverride(config, {value: valueForOverride, recommendedValue: valueForOverride}, group);
  1122. configOverrides.push(newSCP);
  1123. this.set('overrideToAdd', null);
  1124. }
  1125. configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
  1126. configOverrides.setEach('parentSCP', config);
  1127. config.set('overrides', configOverrides);
  1128. return config;
  1129. },
  1130. /**
  1131. * @param serviceName
  1132. * @returns {boolean}
  1133. * @override
  1134. */
  1135. useInitialValue: function(serviceName) {
  1136. return !App.Service.find(serviceName).get('serviceName', serviceName);
  1137. },
  1138. /**
  1139. *
  1140. * @param parentProperties
  1141. * @param name
  1142. * @param fileName
  1143. * @returns {*}
  1144. * @override
  1145. */
  1146. allowUpdateProperty: function(parentProperties, name, fileName) {
  1147. if (name.contains('proxyuser')) return true;
  1148. if (['installerController'].contains(this.get('wizardController.name')) || !!(parentProperties && parentProperties.length)) {
  1149. return true;
  1150. } else if (['addServiceController'].contains(this.get('wizardController.name'))) {
  1151. var stackProperty = App.configsCollection.getConfigByName(name, fileName);
  1152. if (!stackProperty || !this.get('installedServices')[stackProperty.serviceName]) {
  1153. return true;
  1154. } else if (stackProperty.propertyDependsOn.length) {
  1155. return !!stackProperty.propertyDependsOn.filter(function (p) {
  1156. var service = App.config.get('serviceByConfigTypeMap')[p.type];
  1157. return service && !this.get('installedServices')[service.get('serviceName')];
  1158. }, this).length;
  1159. } else {
  1160. return false;
  1161. }
  1162. }
  1163. return true;
  1164. },
  1165. /**
  1166. * remove config based on recommendations
  1167. * @param config
  1168. * @param configsCollection
  1169. * @param parentProperties
  1170. * @protected
  1171. * @override
  1172. */
  1173. _removeConfigByRecommendation: function (config, configsCollection, parentProperties) {
  1174. this._super(config, configsCollection, parentProperties);
  1175. /**
  1176. * need to update wizard info when removing configs for installed services;
  1177. */
  1178. var installedServices = this.get('installedServices'), wizardController = this.get('wizardController'),
  1179. fileNamesToUpdate = wizardController ? wizardController.getDBProperty('fileNamesToUpdate') || [] : [],
  1180. fileName = Em.get(config, 'filename'), serviceName = Em.get(config, 'serviceName');
  1181. var modifiedFileNames = this.get('modifiedFileNames');
  1182. if (modifiedFileNames && !modifiedFileNames.contains(fileName)) {
  1183. modifiedFileNames.push(fileName);
  1184. } else if (wizardController && installedServices[serviceName]) {
  1185. if (!fileNamesToUpdate.contains(fileName)) {
  1186. fileNamesToUpdate.push(fileName);
  1187. }
  1188. }
  1189. if (wizardController) {
  1190. wizardController.setDBProperty('fileNamesToUpdate', fileNamesToUpdate.uniq());
  1191. }
  1192. },
  1193. /**
  1194. * @method manageConfigurationGroup
  1195. */
  1196. manageConfigurationGroup: function () {
  1197. App.router.get('manageConfigGroupsController').manageConfigurationGroups(this);
  1198. },
  1199. /**
  1200. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1201. * @return {$.ajax|null}
  1202. * @method checkMySQLHost
  1203. */
  1204. checkMySQLHost: function () {
  1205. // get ambari database type and hostname
  1206. return App.ajax.send({
  1207. name: 'ambari.service',
  1208. data: {
  1209. fields : "?fields=hostComponents/RootServiceHostComponents/properties/server.jdbc.database_name,hostComponents/RootServiceHostComponents/properties/server.jdbc.url,hostComponents/RootServiceHostComponents/properties/server.jdbc.database"
  1210. },
  1211. sender: this,
  1212. success: 'getAmbariDatabaseSuccess'
  1213. });
  1214. },
  1215. /**
  1216. * Success callback for ambari database, get Ambari DB type and DB server hostname, then
  1217. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1218. * @param {object} data
  1219. * @method getAmbariDatabaseSuccess
  1220. */
  1221. getAmbariDatabaseSuccess: function (data) {
  1222. var ambariServerDBType = Em.getWithDefault(data.hostComponents, '0.RootServiceHostComponents.properties', {})['server.jdbc.database'],
  1223. ambariServerHostName = Em.getWithDefault(data.hostComponents, '0.RootServiceHostComponents.host_name', false),
  1224. hiveConnectionURL = Em.getWithDefault(App.config.findConfigProperty(this.get('stepConfigs'), 'javax.jdo.option.ConnectionURL', 'hive-site.xml') || {}, 'value', '');
  1225. if (ambariServerHostName) {
  1226. this.set('mySQLServerConflict', ambariServerDBType.contains('mysql') && hiveConnectionURL.contains(ambariServerHostName));
  1227. } else {
  1228. this.set('mySQLServerConflict', false);
  1229. }
  1230. },
  1231. /**
  1232. * Check if new MySql database was chosen for Hive service
  1233. * and it is not located on the same host as Ambari server
  1234. * that using MySql database too.
  1235. *
  1236. * @method resolveHiveMysqlDatabase
  1237. */
  1238. resolveHiveMysqlDatabase: function () {
  1239. var hiveService = this.get('content.services').findProperty('serviceName', 'HIVE');
  1240. if (!hiveService || !hiveService.get('isSelected') || hiveService.get('isInstalled')) {
  1241. return this.moveNext();
  1242. }
  1243. var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_database').value;
  1244. if (hiveDBType === 'New MySQL Database') {
  1245. var self = this;
  1246. return this.checkMySQLHost().done(function () {
  1247. self.mySQLWarningHandler();
  1248. });
  1249. }
  1250. return this.moveNext();
  1251. },
  1252. /**
  1253. * Show warning popup about MySQL-DB issues (on post-submit)
  1254. *
  1255. * @returns {*}
  1256. * @method mySQLWarningHandler
  1257. */
  1258. mySQLWarningHandler: function () {
  1259. var self = this;
  1260. if (this.get('mySQLServerConflict')) {
  1261. // error popup before you can proceed
  1262. return App.ModalPopup.show({
  1263. header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
  1264. body:Em.I18n.t('installer.step7.popup.mySQLWarning.body'),
  1265. secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
  1266. primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
  1267. encodeBody: false,
  1268. onPrimary: function () {
  1269. this._super();
  1270. self.set('submitButtonClicked', false);
  1271. },
  1272. onSecondary: function () {
  1273. var parent = this;
  1274. return App.ModalPopup.show({
  1275. header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
  1276. body: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'),
  1277. onPrimary: function () {
  1278. this.hide();
  1279. parent.hide();
  1280. // go back to step 5: assign masters and disable default navigation warning
  1281. if ('installerController' === self.get('content.controllerName')) {
  1282. App.router.get('installerController').gotoStep(5, true);
  1283. }
  1284. else {
  1285. if ('addServiceController' === self.get('content.controllerName')) {
  1286. App.router.get('addServiceController').gotoStep(2, true);
  1287. }
  1288. }
  1289. },
  1290. onSecondary: function () {
  1291. this._super();
  1292. self.set('submitButtonClicked', false);
  1293. }
  1294. });
  1295. }
  1296. });
  1297. }
  1298. return this.moveNext();
  1299. },
  1300. checkDatabaseConnectionTest: function () {
  1301. var deferred = $.Deferred();
  1302. var configMap = [
  1303. {
  1304. serviceName: 'OOZIE',
  1305. ignored: [Em.I18n.t('installer.step7.oozie.database.new')]
  1306. },
  1307. {
  1308. serviceName: 'HIVE',
  1309. ignored: [Em.I18n.t('installer.step7.hive.database.new.mysql'), Em.I18n.t('installer.step7.hive.database.new.postgres')]
  1310. }
  1311. ];
  1312. configMap.forEach(function (config) {
  1313. var isConnectionNotTested = false;
  1314. var service = this.get('content.services').findProperty('serviceName', config.serviceName);
  1315. if (service && service.get('isSelected') && !service.get('isInstalled')) {
  1316. var serviceConfigs = this.get('stepConfigs').findProperty('serviceName', config.serviceName).configs;
  1317. var serviceDatabase = serviceConfigs.findProperty('name', config.serviceName.toLowerCase() + '_database').get('value');
  1318. if (!config.ignored.contains(serviceDatabase)) {
  1319. var filledProperties = App.db.get('tmp', config.serviceName + '_connection');
  1320. if (!filledProperties || App.isEmptyObject(filledProperties)) {
  1321. isConnectionNotTested = true;
  1322. } else {
  1323. for (var key in filledProperties) {
  1324. if (serviceConfigs.findProperty('name', key).get('value') !== filledProperties[key])
  1325. isConnectionNotTested = true;
  1326. }
  1327. }
  1328. }
  1329. }
  1330. config.isCheckIgnored = isConnectionNotTested;
  1331. }, this);
  1332. var ignoredServices = configMap.filterProperty('isCheckIgnored', true);
  1333. if (ignoredServices.length) {
  1334. var displayedServiceNames = ignoredServices.mapProperty('serviceName').map(function (serviceName) {
  1335. return this.get('content.services').findProperty('serviceName', serviceName).get('displayName');
  1336. }, this);
  1337. this.showDatabaseConnectionWarningPopup(displayedServiceNames, deferred);
  1338. }
  1339. else {
  1340. deferred.resolve();
  1341. }
  1342. return deferred;
  1343. },
  1344. showChangesWarningPopup: function(goToNextStep) {
  1345. return App.ModalPopup.show({
  1346. header: Em.I18n.t('common.warning'),
  1347. body: Em.I18n.t('services.service.config.exitChangesPopup.body'),
  1348. secondary: Em.I18n.t('common.cancel'),
  1349. primary: Em.I18n.t('yes'),
  1350. onPrimary: function () {
  1351. if (goToNextStep) {
  1352. goToNextStep();
  1353. this.hide();
  1354. }
  1355. },
  1356. onSecondary: function () {
  1357. this.hide();
  1358. }
  1359. });
  1360. },
  1361. showDatabaseConnectionWarningPopup: function (serviceNames, deferred) {
  1362. var self = this;
  1363. return App.ModalPopup.show({
  1364. header: Em.I18n.t('installer.step7.popup.database.connection.header'),
  1365. body: Em.I18n.t('installer.step7.popup.database.connection.body').format(serviceNames.join(', ')),
  1366. secondary: Em.I18n.t('common.cancel'),
  1367. primary: Em.I18n.t('common.proceedAnyway'),
  1368. onPrimary: function () {
  1369. deferred.resolve();
  1370. this._super();
  1371. },
  1372. onClose: function () {
  1373. this.onSecondary();
  1374. },
  1375. onSecondary: function () {
  1376. this._super();
  1377. self.set('submitButtonClicked', false);
  1378. App.set('router.nextBtnClickInProgress', false);
  1379. deferred.reject();
  1380. }
  1381. });
  1382. },
  1383. showOozieDerbyWarningPopup: function(callback) {
  1384. var self = this;
  1385. if (this.get('selectedServiceNames').contains('OOZIE')) {
  1386. var databaseType = Em.getWithDefault(App.config.findConfigProperty(this.get('stepConfigs'), 'oozie_database', 'oozie-env.xml') || {}, 'value', '');
  1387. if (databaseType === Em.I18n.t('installer.step7.oozie.database.new')) {
  1388. return App.ModalPopup.show({
  1389. header: Em.I18n.t('common.warning'),
  1390. body: Em.I18n.t('installer.step7.popup.oozie.derby.warning'),
  1391. secondary: Em.I18n.t('common.cancel'),
  1392. primary: Em.I18n.t('common.proceedAnyway'),
  1393. onPrimary: function() {
  1394. this.hide();
  1395. if (callback) {
  1396. callback();
  1397. }
  1398. },
  1399. onSecondary: function() {
  1400. App.set('router.nextBtnClickInProgress', false);
  1401. self.set('submitButtonClicked', false);
  1402. this.hide();
  1403. },
  1404. onClose: function() {
  1405. this.onSecondary();
  1406. }
  1407. });
  1408. }
  1409. }
  1410. if (callback) {
  1411. callback();
  1412. }
  1413. return false;
  1414. },
  1415. /**
  1416. * Proceed to the next step
  1417. **/
  1418. moveNext: function () {
  1419. App.set('router.nextBtnClickInProgress', false);
  1420. App.router.send('next');
  1421. this.set('submitButtonClicked', false);
  1422. },
  1423. /**
  1424. * Click-handler on Next button
  1425. * Disable "Submit"-button while server-side processes are running
  1426. * @method submit
  1427. */
  1428. submit: function () {
  1429. if (this.get('isSubmitDisabled') || App.get('router.nextBtnClickInProgress')) {
  1430. return false;
  1431. }
  1432. App.set('router.nextBtnClickInProgress', true);
  1433. if (this.get('supportsPreInstallChecks')) {
  1434. var preInstallChecksController = App.router.get('preInstallChecksController');
  1435. if (preInstallChecksController.get('preInstallChecksWhereRun')) {
  1436. return this.postSubmit();
  1437. }
  1438. return preInstallChecksController.notRunChecksWarnPopup(this.postSubmit.bind(this));
  1439. }
  1440. return this.postSubmit();
  1441. },
  1442. postSubmit: function () {
  1443. var self = this;
  1444. this.set('submitButtonClicked', true);
  1445. this.serverSideValidation().done(function() {
  1446. self.serverSideValidationCallback();
  1447. })
  1448. .fail(function (value) {
  1449. if ("invalid_configs" === value) {
  1450. self.set('submitButtonClicked', false);
  1451. App.set('router.nextBtnClickInProgress', false);
  1452. } else {
  1453. // Failed due to validation mechanism failure.
  1454. // Should proceed with other checks
  1455. self.serverSideValidationCallback();
  1456. }
  1457. });
  1458. },
  1459. /**
  1460. * @method serverSideValidationCallback
  1461. */
  1462. serverSideValidationCallback: function() {
  1463. var self = this;
  1464. this.showOozieDerbyWarningPopup(function() {
  1465. self.checkDatabaseConnectionTest().done(function () {
  1466. self.resolveHiveMysqlDatabase();
  1467. });
  1468. });
  1469. },
  1470. toggleIssuesFilter: function () {
  1471. var errorServices = [],
  1472. issueServices = [];
  1473. this.get('filterColumns').findProperty('attributeName', 'hasIssues').toggleProperty('selected');
  1474. // if currently selected service does not have issue, jump to the first service with issue.
  1475. if (this.get('selectedService.errorCount') === 0 )
  1476. {
  1477. this.get('stepConfigs').filterProperty('showConfig', true).forEach(function(service) {
  1478. if (service.get('errorCount') > 0) errorServices.push(service);
  1479. if (service.get('hasConfigIssues') === true) issueServices.push(service);
  1480. });
  1481. if (errorServices.length === 0 && issueServices.length === 0) return;
  1482. this.switchToService(errorServices.length > 0 ? errorServices[0] : issueServices[0]);
  1483. }
  1484. },
  1485. switchToService: function(service) {
  1486. this.set('selectedService', service);
  1487. $('a[href="#' + service.serviceName + '"]').tab('show');
  1488. },
  1489. issuesFilterSelected: function() {
  1490. return this.get('filterColumns').findProperty('attributeName', 'hasIssues').get('selected');
  1491. }.property('filterColumns.@each.selected'),
  1492. hasStepConfigIssues: function() {
  1493. return !this.get('stepConfigs').filterProperty('showConfig', true).everyProperty('hasConfigIssues', false);
  1494. }.property('stepConfigs.@each.hasConfigIssues')
  1495. });