step7_controller.js 64 KB

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