step8_controller.js 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966
  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. var stringUtils = require('utils/string_utils');
  20. App.WizardStep8Controller = Em.Controller.extend({
  21. name: 'wizardStep8Controller',
  22. rawContent: require('data/review_configs'),
  23. totalHosts: [],
  24. clusterInfo: [],
  25. services: [],
  26. configs: [],
  27. globals: [],
  28. ajaxQueue: [],
  29. configMapping: function(){
  30. return App.config.get('configMapping').all(true);
  31. }.property('App.config.configMapping'),
  32. slaveComponentConfig: null,
  33. isSubmitDisabled: false,
  34. isBackBtnDisabled: false,
  35. hasErrorOccurred: false,
  36. servicesInstalled: false,
  37. serviceConfigTags: [],
  38. securityEnabled: function() {
  39. return App.router.get('mainAdminSecurityController.securityEnabled');
  40. }.property('App.router.mainAdminSecurityController.securityEnabled'),
  41. /**
  42. * During page save time, we set the host overrides to the server.
  43. * The new host -> site:tag map is stored below. This will be
  44. * useful during save, to update the host's host components. Also,
  45. * it will be useful in deletion of overrides.
  46. *
  47. * Example:
  48. * {
  49. * 'hostname1': {
  50. * 'global': {
  51. * 'tagName': 'tag3187261938_hostname1',
  52. * 'map': {
  53. * 'hadoop_heapsize': '2048m'
  54. * }
  55. * }
  56. * }
  57. * }
  58. *
  59. * @see loadedHostToOverrideSiteToTagMap
  60. */
  61. savedHostToOverrideSiteToTagMap: {},
  62. selectedConfigGroup: null,
  63. configGroups: [],
  64. selectedServices: function () {
  65. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false);
  66. }.property('content.services').cacheable(),
  67. clearStep: function () {
  68. this.get('services').clear();
  69. this.get('configs').clear();
  70. this.get('globals').clear();
  71. this.get('clusterInfo').clear();
  72. this.get('serviceConfigTags').clear();
  73. this.set('servicesInstalled', false);
  74. },
  75. loadStep: function () {
  76. console.log("TRACE: Loading step8: Review Page");
  77. if (this.get('content.controllerName') != 'installerController') {
  78. App.router.get('mainAdminSecurityController').setSecurityStatus();
  79. }
  80. this.clearStep();
  81. if (this.get('content.serviceConfigProperties')) {
  82. this.formatProperties();
  83. this.loadGlobals();
  84. this.loadConfigs();
  85. }
  86. this.loadClusterInfo();
  87. this.loadServices();
  88. this.set('isSubmitDisabled', false);
  89. this.set('isBackBtnDisabled', false);
  90. },
  91. /**
  92. * replace whitespace character with coma between directories
  93. */
  94. formatProperties: function(){
  95. this.get('content.serviceConfigProperties').forEach(function(_configProperty){
  96. _configProperty.value = App.config.trimProperty(_configProperty,false);
  97. });
  98. },
  99. loadGlobals: function () {
  100. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  101. if (globals.someProperty('name', 'hive_database')) {
  102. var hiveDb = globals.findProperty('name', 'hive_database');
  103. var hiveDbType = {name: 'hive_database_type', value: 'mysql'};
  104. var hiveJdbcDriver = {name: 'hive_jdbc_driver'};
  105. if (hiveDb.value === 'New MySQL Database') {
  106. if (globals.someProperty('name', 'hive_ambari_host')) {
  107. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_ambari_host').value;
  108. hiveDbType.value = 'mysql';
  109. hiveJdbcDriver.value = 'com.mysql.jdbc.Driver';
  110. }
  111. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
  112. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
  113. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
  114. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
  115. } else if (hiveDb.value === 'Existing MySQL Database'){
  116. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_existing_mysql_host').value;
  117. hiveDbType.value = 'mysql';
  118. hiveJdbcDriver.value = 'com.mysql.jdbc.Driver';
  119. globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
  120. globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
  121. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
  122. globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
  123. } else { //existing oracle database
  124. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_existing_oracle_host').value;
  125. hiveDbType.value = 'oracle';
  126. hiveJdbcDriver.value = 'oracle.jdbc.driver.OracleDriver';
  127. globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
  128. globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
  129. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
  130. globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
  131. }
  132. globals.push(hiveDbType);
  133. globals.push(hiveJdbcDriver);
  134. }
  135. if (globals.someProperty('name', 'oozie_database')) {
  136. var oozieDb = globals.findProperty('name', 'oozie_database');
  137. var oozieDbType = {name:'oozie_database_type'};
  138. var oozieJdbcDriver = {name: 'oozie_jdbc_driver'};
  139. if (oozieDb.value === 'New Derby Database') {
  140. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_ambari_host').value;
  141. oozieDbType.value = 'derby';
  142. oozieJdbcDriver.value = 'org.apache.derby.jdbc.EmbeddedDriver';
  143. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  144. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  145. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  146. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  147. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  148. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  149. } else if (oozieDb.value === 'Existing MySQL Database') {
  150. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_existing_mysql_host').value;
  151. oozieDbType.value = 'mysql';
  152. oozieJdbcDriver.value = 'com.mysql.jdbc.Driver';
  153. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  154. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  155. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
  156. globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
  157. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  158. } else { // existing oracle database
  159. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_existing_oracle_host').value;
  160. oozieDbType.value = 'oracle';
  161. oozieJdbcDriver.value = 'oracle.jdbc.driver.OracleDriver';
  162. globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
  163. globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
  164. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
  165. globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
  166. globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
  167. }
  168. globals.push(oozieDbType);
  169. globals.push(oozieJdbcDriver);
  170. }
  171. this.set('globals', globals);
  172. },
  173. loadConfigs: function () {
  174. //storedConfigs contains custom configs as well
  175. var serviceConfigProperties = this.get('content.serviceConfigProperties').filterProperty('id', 'site property');
  176. serviceConfigProperties.forEach(function(_config){
  177. _config.value = (typeof _config.value === "boolean") ? _config.value.toString() : _config.value;
  178. });
  179. var storedConfigs = serviceConfigProperties.filterProperty('value');
  180. var uiConfigs = this.loadUiSideConfigs();
  181. this.set('configs', storedConfigs.concat(uiConfigs));
  182. },
  183. loadUiSideConfigs: function () {
  184. var uiConfig = [];
  185. var configs = this.get('configMapping').filterProperty('foreignKey', null);
  186. this.addDynamicProperties(configs);
  187. configs.forEach(function (_config) {
  188. var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
  189. uiConfig.pushObject({
  190. "id": "site property",
  191. "name": _config.name,
  192. "value": valueWithOverrides.value,
  193. "filename": _config.filename,
  194. "overrides": valueWithOverrides.overrides
  195. });
  196. }, this);
  197. var dependentConfig = $.extend(true, [], this.get('configMapping').filterProperty('foreignKey'));
  198. dependentConfig.forEach(function (_config) {
  199. App.config.setConfigValue(uiConfig, this.get('content.serviceConfigProperties'), _config, this.get('globals'));
  200. uiConfig.pushObject({
  201. "id": "site property",
  202. "name": _config._name || _config.name,
  203. "value": _config.value,
  204. "filename": _config.filename
  205. });
  206. }, this);
  207. return uiConfig;
  208. },
  209. addDynamicProperties: function(configs) {
  210. var templetonHiveProperty = this.get('content.serviceConfigProperties').someProperty('name', 'templeton.hive.properties');
  211. if (!templetonHiveProperty) {
  212. configs.pushObject({
  213. "name": "templeton.hive.properties",
  214. "templateName": ["hivemetastore_host"],
  215. "foreignKey": null,
  216. "value": "hive.metastore.local=false,hive.metastore.uris=thrift://<templateName[0]>:9083,hive.metastore.sasl.enabled=yes,hive.metastore.execute.setugi=true,hive.metastore.warehouse.dir=/apps/hive/warehouse",
  217. "filename": "webhcat-site.xml"
  218. });
  219. }
  220. },
  221. getRegisteredHosts: function () {
  222. var allHosts = this.get('content.hosts');
  223. var hosts = [];
  224. for (var hostName in allHosts) {
  225. if (allHosts[hostName].bootStatus == 'REGISTERED') {
  226. allHosts[hostName].hostName = allHosts[hostName].name;
  227. hosts.pushObject(allHosts[hostName]);
  228. }
  229. }
  230. return hosts;
  231. },
  232. /**
  233. * Set all site property that are derived from other puppet-variable
  234. * @return {
  235. * value: '...',
  236. * overrides: {
  237. * 'value1': [h1, h2],
  238. * 'value2': [h3]
  239. * }
  240. * }
  241. */
  242. getGlobConfigValueWithOverrides: function (templateName, expression, name) {
  243. var express = expression.match(/<(.*?)>/g);
  244. var value = expression;
  245. if (express == null) {
  246. return { value : expression, overrides: []}; // if site property do not map any global property then return the value
  247. }
  248. var overrideHostToValue = {};
  249. express.forEach(function (_express) {
  250. //console.log("The value of template is: " + _express);
  251. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  252. if (this.get('globals').someProperty('name', templateName[index])) {
  253. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  254. var globalObj = this.get('globals').findProperty('name', templateName[index]);
  255. var globValue = globalObj.value;
  256. // Hack for templeton.zookeeper.hosts
  257. var preReplaceValue = null;
  258. if (value !== null) { // if the property depends on more than one template name like <templateName[0]>/<templateName[1]> then don't proceed to the next if the prior is null or not found in the global configs
  259. preReplaceValue = value;
  260. value = this._replaceConfigValues(name, _express, value, globValue);
  261. }
  262. if(globalObj.overrides!=null){
  263. globalObj.overrides.forEach(function(override){
  264. var ov = override.value;
  265. var hostsArray = override.hosts;
  266. hostsArray.forEach(function(host){
  267. if(!(host in overrideHostToValue)){
  268. overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
  269. }else{
  270. overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
  271. }
  272. }, this);
  273. }, this);
  274. }
  275. } else {
  276. /*
  277. console.log("ERROR: The variable name is: " + templateName[index]);
  278. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  279. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  280. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  281. */
  282. value = null;
  283. }
  284. }, this);
  285. var valueWithOverrides = {
  286. value: value,
  287. overrides: []
  288. };
  289. var overrideValueToHostMap = {};
  290. if(!jQuery.isEmptyObject(overrideHostToValue)){
  291. for(var host in overrideHostToValue){
  292. var hostVal = overrideHostToValue[host];
  293. if(!(hostVal in overrideValueToHostMap)){
  294. overrideValueToHostMap[hostVal] = [];
  295. }
  296. overrideValueToHostMap[hostVal].push(host);
  297. }
  298. }
  299. for(var val in overrideValueToHostMap){
  300. valueWithOverrides.overrides.push({
  301. value: val,
  302. hosts: overrideValueToHostMap[val]
  303. });
  304. }
  305. return valueWithOverrides;
  306. },
  307. _replaceConfigValues: function (name, express, value, globValue) {
  308. return value.replace(express, globValue);
  309. },
  310. /**
  311. * Load all info about cluster to <code>clusterInfo</code> variable
  312. */
  313. loadClusterInfo: function () {
  314. //Admin name
  315. var admin = this.rawContent.findProperty('config_name', 'Admin');
  316. admin.config_value = App.db.getLoginName();
  317. console.log("STEP8: the value of content cluster name: " + App.db.getLoginName());
  318. if (admin.config_value) {
  319. this.get('clusterInfo').pushObject(Ember.Object.create(admin));
  320. }
  321. // cluster name
  322. var cluster = this.rawContent.findProperty('config_name', 'cluster');
  323. cluster.config_value = this.get('content.cluster.name');
  324. console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
  325. this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
  326. //hosts
  327. var masterHosts = this.get('content.masterComponentHosts').mapProperty('hostName').uniq();
  328. var slaveHosts = this.get('content.slaveComponentHosts');
  329. var hostObj = [];
  330. slaveHosts.forEach(function (_hosts) {
  331. hostObj = hostObj.concat(_hosts.hosts);
  332. }, this);
  333. slaveHosts = hostObj.mapProperty('hostName').uniq();
  334. var componentHosts = masterHosts.concat(slaveHosts).uniq();
  335. var totalHosts = App.Host.find().mapProperty('hostName').concat(componentHosts).uniq();
  336. var newHostsCount = totalHosts.length - App.Host.find().content.length;
  337. this.set('totalHosts', totalHosts);
  338. var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
  339. totalHostsObj.config_value = totalHosts.length + ' (' + newHostsCount + ' new)';
  340. this.get('clusterInfo').pushObject(Ember.Object.create(totalHostsObj));
  341. //repo
  342. if (['addHostController', 'addServiceController'].contains(this.get('content.controllerName'))) {
  343. this.loadRepoInfo();
  344. } else { // from install wizard
  345. var selectedStack = this.get('content.stacks').findProperty('isSelected', true);
  346. var allRepos = [];
  347. if (selectedStack && selectedStack.operatingSystems) {
  348. selectedStack.operatingSystems.forEach (function(os){
  349. if (os.selected) {
  350. switch (os.osType) {
  351. case 'redhat6':
  352. var repo = Em.Object.create({
  353. base_url: os.baseUrl,
  354. os_type: Em.I18n.t("installer.step8.repoInfo.osType.redhat6")
  355. });
  356. allRepos.push(repo);
  357. break;
  358. case 'redhat5':
  359. var repo = Em.Object.create({
  360. base_url: os.baseUrl,
  361. os_type: Em.I18n.t("installer.step8.repoInfo.osType.redhat5")
  362. });
  363. allRepos.push(repo);
  364. break;
  365. case 'sles11':
  366. var repo = Em.Object.create({
  367. base_url: os.baseUrl,
  368. os_type: Em.I18n.t("installer.step8.repoInfo.osType.sles11")
  369. });
  370. allRepos.push(repo);
  371. break;
  372. }
  373. }
  374. }, this);
  375. }
  376. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  377. this.get('clusterInfo').set('repoInfo', allRepos);
  378. }
  379. },
  380. /**
  381. * get the repositories info of HDP from server. Used only in addHost controller.
  382. */
  383. loadRepoInfo: function(){
  384. var nameVersionCombo = App.get('currentStackVersion');
  385. var stackName = nameVersionCombo.split('-')[0];
  386. var stackVersion = nameVersionCombo.split('-')[1];
  387. App.ajax.send({
  388. name: 'cluster.load_repositories',
  389. sender: this,
  390. data: {
  391. stackName: stackName,
  392. stackVersion: stackVersion
  393. },
  394. success: 'loadRepoInfoSuccessCallback',
  395. error: 'loadRepositoriesErrorCallback'
  396. });
  397. },
  398. loadRepoInfoSuccessCallback: function (data) {
  399. var allRepos = [];
  400. data.items.forEach(function(item) {
  401. var os = item.repositories[0].Repositories;
  402. switch (os.os_type) {
  403. case 'redhat6':
  404. var repo = Em.Object.create({
  405. base_url: os.base_url,
  406. os_type: Em.I18n.t("installer.step8.repoInfo.osType.redhat6")
  407. });
  408. allRepos.push(repo);
  409. break;
  410. case 'redhat5':
  411. var repo = Em.Object.create({
  412. base_url: os.base_url,
  413. os_type: Em.I18n.t("installer.step8.repoInfo.osType.redhat5")
  414. });
  415. allRepos.push(repo);
  416. break;
  417. case 'sles11':
  418. var repo = Em.Object.create({
  419. base_url: os.base_url,
  420. os_type: Em.I18n.t("installer.step8.repoInfo.osType.sles11")
  421. });
  422. allRepos.push(repo);
  423. break;
  424. }
  425. }, this);
  426. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  427. this.get('clusterInfo').set('repoInfo', allRepos);
  428. },
  429. loadRepoInfoErrorCallback: function(request, ajaxOptions, error) {
  430. console.log('Error message is: ' + request.responseText);
  431. var allRepos = [];
  432. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  433. this.get('clusterInfo').set('repoInfo', allRepos);
  434. },
  435. /**
  436. * Load all info about services to <code>services</code> variable
  437. */
  438. loadServices: function () {
  439. var selectedServices = this.get('selectedServices');
  440. this.set('services', selectedServices.mapProperty('serviceName'));
  441. selectedServices.forEach(function (_service) {
  442. console.log('INFO: step8: Name of the service from getService function: ' + _service.serviceName);
  443. var reviewService = this.rawContent.findProperty('config_name', 'services');
  444. var serviceObj = reviewService.config_value.findProperty('service_name', _service.serviceName);
  445. if (serviceObj) {
  446. switch (serviceObj.service_name) {
  447. case 'HDFS':
  448. this.loadHDFS(serviceObj);
  449. break;
  450. case 'GLUSTERFS':
  451. this.loadGLUSTERFS(serviceObj);
  452. break;
  453. case 'MAPREDUCE':
  454. this.loadMapReduce(serviceObj);
  455. break;
  456. case 'MAPREDUCE2':
  457. this.loadMapReduce2(serviceObj);
  458. break;
  459. case 'YARN':
  460. this.loadYARN(serviceObj);
  461. break;
  462. case 'HIVE':
  463. this.loadHive(serviceObj);
  464. break;
  465. case 'HBASE':
  466. this.loadHbase(serviceObj);
  467. break;
  468. case 'ZOOKEEPER':
  469. this.loadZk(serviceObj);
  470. break;
  471. case 'OOZIE':
  472. this.loadOozie(serviceObj);
  473. break;
  474. case 'NAGIOS':
  475. this.loadNagios(serviceObj);
  476. break;
  477. case 'GANGLIA':
  478. this.loadGanglia(serviceObj);
  479. break;
  480. case 'HUE':
  481. this.loadHue(serviceObj);
  482. break;
  483. case 'FALCON':
  484. this.loadFalcon(serviceObj);
  485. break;
  486. /* case 'TEZ':
  487. break;
  488. case 'PIG':
  489. this.loadPig(serviceObj);
  490. break;
  491. case 'SQOOP':
  492. this.loadSqoop(serviceObj);
  493. break;
  494. */
  495. case 'STORM':
  496. if (App.testMode) {
  497. this.loadSTORM(serviceObj);
  498. }
  499. case 'HCATALOG':
  500. break;
  501. default:
  502. }
  503. }
  504. }, this);
  505. },
  506. /**
  507. * load all info about HDFS service
  508. * @param hdfsObj
  509. */
  510. loadHDFS: function (hdfsObj) {
  511. hdfsObj.get('service_components').forEach(function (_component) {
  512. switch (_component.get('display_name')) {
  513. case 'NameNode':
  514. this.loadNnValue(_component);
  515. break;
  516. case 'SecondaryNameNode':
  517. this.loadSnnValue(_component);
  518. break;
  519. case 'DataNodes':
  520. this.loadDnValue(_component);
  521. break;
  522. default:
  523. }
  524. }, this);
  525. //var
  526. this.get('services').pushObject(hdfsObj);
  527. },
  528. /**
  529. * load all info about GLUSTERFS service
  530. * @param glusterfsObj
  531. */
  532. loadGLUSTERFS: function (glusterfsObj) {
  533. glusterfsObj.get('service_components').forEach(function (_component) {
  534. switch (_component.get('display_name')) {
  535. case 'GLUSTERFS Client':
  536. this.loadGLUSTERFSClientValue(_component);
  537. break;
  538. default:
  539. }
  540. }, this);
  541. this.get('services').pushObject(glusterfsObj);
  542. },
  543. loadGLUSTERFSClientValue: function (glusterfsComponent) {
  544. var glusterfsClientHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'Client');
  545. var totalGLUSTERFSHosts = glusterfsClientHosts.hosts.length;
  546. glusterfsComponent.set('component_value', totalGLUSTERFSHosts + ' hosts');
  547. },
  548. loadNnValue: function (nnComponent) {
  549. var nnHostName = this.get('content.masterComponentHosts').findProperty('display_name', nnComponent.display_name);
  550. nnComponent.set('component_value', nnHostName.hostName);
  551. },
  552. loadSnnValue: function (snnComponent) {
  553. var snnHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'SNameNode');
  554. snnComponent.set('component_value', snnHostName.hostName);
  555. },
  556. loadDnValue: function (dnComponent) {
  557. var dnHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'DataNode');
  558. var totalDnHosts = dnHosts.hosts.length;
  559. /* var totalGroups = this.get('slaveComponentConfig.components').findProperty('componentName', 'DATANODE').groups.length;
  560. var groupLabel;
  561. if (totalGroups == 1) {
  562. groupLabel = 'group';
  563. } else {
  564. groupLabel = 'groups';
  565. }
  566. */
  567. dnComponent.set('component_value', totalDnHosts + Em.I18n.t('installer.step8.hosts'));
  568. },
  569. /**
  570. * Load all info about mapReduce service
  571. * @param mrObj
  572. */
  573. loadMapReduce: function (mrObj) {
  574. mrObj.get('service_components').forEach(function (_component) {
  575. switch (_component.get('display_name')) {
  576. case 'JobTracker':
  577. this.loadJtValue(_component);
  578. break;
  579. case 'TaskTrackers':
  580. this.loadTtValue(_component);
  581. break;
  582. default:
  583. }
  584. }, this);
  585. this.get('services').pushObject(mrObj);
  586. },
  587. loadMapReduce2: function(mrObj){
  588. mrObj.get('service_components').forEach(function (_component) {
  589. switch (_component.get('display_name')) {
  590. case 'History Server':
  591. _component.set('component_value', this.get('content.masterComponentHosts').findProperty('component', 'HISTORYSERVER').hostName);
  592. break;
  593. }
  594. }, this);
  595. this.get('services').pushObject(mrObj);
  596. },
  597. loadYARN: function(mrObj){
  598. mrObj.get('service_components').forEach(function (_component) {
  599. switch (_component.get('display_name')) {
  600. case 'NodeManager':
  601. this.loadNMValue(_component);
  602. break;
  603. case 'ResourceManager':
  604. _component.set('component_value', this.get('content.masterComponentHosts').findProperty('component', 'RESOURCEMANAGER').hostName);
  605. break;
  606. case 'History Server':
  607. _component.set('component_value', this.get('content.masterComponentHosts').findProperty('component', 'HISTORYSERVER').hostName);
  608. break;
  609. }
  610. }, this);
  611. this.get('services').pushObject(mrObj);
  612. },
  613. loadNMValue: function (nmComponent) {
  614. var nmHosts = this.get('content.slaveComponentHosts').findProperty('componentName', 'NODEMANAGER');
  615. nmComponent.set('component_value', nmHosts.hosts.length + Em.I18n.t('installer.step8.hosts'));
  616. },
  617. loadJtValue: function (jtComponent) {
  618. var jtHostName = this.get('content.masterComponentHosts').findProperty('display_name', jtComponent.display_name);
  619. jtComponent.set('component_value', jtHostName.hostName);
  620. },
  621. loadTtValue: function (ttComponent) {
  622. var ttHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'TaskTracker');
  623. var totalTtHosts = ttHosts.hosts.length;
  624. ttComponent.set('component_value', totalTtHosts + Em.I18n.t('installer.step8.hosts'));
  625. },
  626. /**
  627. * Load all info about Hive service
  628. * @param hiveObj
  629. */
  630. loadHive: function (hiveObj) {
  631. hiveObj.get('service_components').forEach(function (_component) {
  632. switch (_component.get('display_name')) {
  633. case 'Hive Metastore':
  634. this.loadHiveMetaStoreValue(_component);
  635. break;
  636. case 'Database':
  637. this.loadHiveDbValue(_component);
  638. break;
  639. default:
  640. }
  641. }, this);
  642. this.get('services').pushObject(hiveObj);
  643. },
  644. loadHiveMetaStoreValue: function (metaStoreComponent) {
  645. var hiveHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'HiveServer2');
  646. metaStoreComponent.set('component_value', hiveHostName.hostName);
  647. },
  648. loadHiveDbValue: function (dbComponent) {
  649. var hiveDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_database');
  650. if (hiveDb.value === 'New MySQL Database') {
  651. dbComponent.set('component_value', 'MySQL (New Database)');
  652. } else if(hiveDb.value === 'Existing MySQL Database'){
  653. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_existing_mysql_database');
  654. dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
  655. } else { // existing oracle database
  656. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'hive_existing_oracle_database');
  657. dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
  658. }
  659. },
  660. /**
  661. * Load all info about Hbase
  662. * @param hbaseObj
  663. */
  664. loadHbase: function (hbaseObj) {
  665. hbaseObj.service_components.forEach(function (_component) {
  666. switch (_component.display_name) {
  667. case 'Master':
  668. this.loadMasterValue(_component);
  669. break;
  670. case 'RegionServers':
  671. this.loadRegionServerValue(_component);
  672. break;
  673. default:
  674. }
  675. }, this);
  676. this.get('services').pushObject(hbaseObj);
  677. },
  678. loadMasterValue: function (hbaseMaster) {
  679. var hbaseHostName = this.get('content.masterComponentHosts').filterProperty('display_name', 'HBase Master');
  680. if (hbaseHostName.length == 1) {
  681. hbaseMaster.set('component_value', hbaseHostName[0].hostName);
  682. } else {
  683. hbaseMaster.set('component_value', hbaseHostName[0].hostName + Em.I18n.t('installer.step8.other').format(hbaseHostName.length - 1));
  684. }
  685. },
  686. loadRegionServerValue: function (rsComponent) {
  687. var rsHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'RegionServer');
  688. var totalRsHosts = rsHosts.hosts.length;
  689. /* var totalGroups = this.get('slaveComponentConfig.components').findProperty('componentName', 'HBASE_REGIONSERVER').groups.length;
  690. var groupLabel;
  691. if (totalGroups == 1) {
  692. groupLabel = 'group';
  693. } else {
  694. groupLabel = 'groups';
  695. } */
  696. rsComponent.set('component_value', totalRsHosts + Em.I18n.t('installer.step8.hosts'));
  697. },
  698. /**
  699. * Load all info about ZooKeeper service
  700. * @param zkObj
  701. */
  702. loadZk: function (zkObj) {
  703. zkObj.get('service_components').forEach(function (_component) {
  704. switch (_component.get('display_name')) {
  705. case 'Servers':
  706. this.loadZkServerValue(_component);
  707. break;
  708. default:
  709. }
  710. }, this);
  711. this.get('services').pushObject(zkObj);
  712. },
  713. loadZkServerValue: function (serverComponent) {
  714. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('display_name', 'ZooKeeper').length;
  715. var hostSuffix;
  716. if (zkHostNames === 1) {
  717. hostSuffix = Em.I18n.t('installer.step8.host');
  718. } else {
  719. hostSuffix = Em.I18n.t('installer.step8.hosts');
  720. }
  721. serverComponent.set('component_value', zkHostNames + ' ' + hostSuffix);
  722. },
  723. /**
  724. * Load all info about Hue services
  725. * @param hueObj
  726. */
  727. loadHue: function (hueObj) {
  728. hueObj.get('service_components').forEach(function (_component) {
  729. switch (_component.get('display_name')) {
  730. case 'Server':
  731. this.loadHueServerValue(_component);
  732. break;
  733. default:
  734. }
  735. }, this);
  736. this.get('services').pushObject(hueObj);
  737. },
  738. loadHueServerValue: function (hueServer) {
  739. var hueServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Hue Server');
  740. hueServer.set('component_value', hueServerName.hostName);
  741. },
  742. /**
  743. * Load all info about Oozie services
  744. * @param oozieObj
  745. */
  746. loadOozie: function (oozieObj) {
  747. oozieObj.get('service_components').forEach(function (_component) {
  748. switch (_component.get('display_name')) {
  749. case 'Server':
  750. this.loadOozieServerValue(_component);
  751. break;
  752. case 'Database':
  753. // TODO: uncomment when ready to integrate with Oozie Database other than Derby
  754. this.loadOozieDbValue(_component);
  755. break;
  756. default:
  757. }
  758. }, this);
  759. this.get('services').pushObject(oozieObj);
  760. },
  761. loadOozieServerValue: function (oozieServer) {
  762. var oozieServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Oozie Server');
  763. oozieServer.set('component_value', oozieServerName.hostName);
  764. },
  765. loadOozieDbValue: function (dbComponent) {
  766. var oozieDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_database');
  767. if (oozieDb.value === 'New Derby Database'){
  768. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_derby_database');
  769. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  770. }/* else if (oozieDb.value === 'New MySQL Database') {
  771. dbComponent.set('component_value', 'MySQL (New Database)');
  772. } */else if(oozieDb.value === 'Existing MySQL Database'){
  773. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mysql_database');
  774. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  775. } else { // existing oracle database
  776. var db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_oracle_database');
  777. dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
  778. }
  779. },
  780. /**
  781. * Load all info about Nagios service
  782. * @param nagiosObj
  783. */
  784. loadNagios: function (nagiosObj) {
  785. nagiosObj.service_components.forEach(function (_component) {
  786. switch (_component.display_name) {
  787. case 'Server':
  788. this.loadNagiosServerValue(_component);
  789. break;
  790. case 'Administrator':
  791. this.loadNagiosAdminValue(_component);
  792. break;
  793. default:
  794. }
  795. }, this);
  796. this.get('services').pushObject(nagiosObj);
  797. },
  798. loadNagiosServerValue: function (nagiosServer) {
  799. var nagiosServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Nagios Server');
  800. nagiosServer.set('component_value', nagiosServerName.hostName);
  801. },
  802. loadNagiosAdminValue: function (nagiosAdmin) {
  803. var config = this.get('content.serviceConfigProperties');
  804. var adminLoginName = config.findProperty('name', 'nagios_web_login');
  805. var adminEmail = config.findProperty('name', 'nagios_contact');
  806. nagiosAdmin.set('component_value', adminLoginName.value + ' / (' + adminEmail.value + ')');
  807. },
  808. /**
  809. * Load all info about ganglia
  810. * @param gangliaObj
  811. */
  812. loadGanglia: function (gangliaObj) {
  813. gangliaObj.get('service_components').forEach(function (_component) {
  814. switch (_component.get('display_name')) {
  815. case 'Server':
  816. this.loadGangliaServerValue(_component);
  817. break;
  818. default:
  819. }
  820. }, this);
  821. this.get('services').pushObject(gangliaObj);
  822. },
  823. loadGangliaServerValue: function (gangliaServer) {
  824. var gangliaServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Ganglia Server');
  825. gangliaServer.set('component_value', gangliaServerName.hostName);
  826. },
  827. loadSqoop: function (sqoopObj) {
  828. this.get('services').pushObject(sqoopObj);
  829. },
  830. loadPig: function (pigObj) {
  831. this.get('services').pushObject(pigObj);
  832. },
  833. loadFalcon: function (falconObj) {
  834. falconObj.get('service_components').forEach(function(component) {
  835. switch (component.get('display_name')) {
  836. case 'Server':
  837. this.loadFalconValue(component);
  838. break;
  839. }
  840. }, this);
  841. this.get('services').pushObject(falconObj);
  842. },
  843. loadFalconValue: function(component) {
  844. var falconHost = this.get('content.masterComponentHosts').filterProperty('display_name', 'Falcon Server');
  845. component.set('component_value', falconHost[0].hostName);
  846. },
  847. loadSTORM: function (stormObj) {
  848. stormObj.get('service_components').forEach(function(component) {
  849. switch (component.get('display_name')) {
  850. case 'Nimbus':
  851. this.loadNimbusValue(component);
  852. break;
  853. case 'SuperVisor':
  854. this.loadSuperVisorValue(component);
  855. break;
  856. default:
  857. }
  858. }, this);
  859. this.get('services').pushObject(stormObj);
  860. },
  861. loadNimbusValue: function(component) {
  862. var nimbusHost = this.get('content.masterComponentHosts').filterProperty('display_name', component.get('display_name'));
  863. component.set('component_value', nimbusHost[0].hostName);
  864. },
  865. loadSuperVisorValue: function(component) {
  866. var hostsCount = this.get('content.slaveComponentHosts').findProperty('componentName', 'CLIENT').hosts.length;
  867. var hostsText = hostsCount > 1 ? hostsCount + ' hosts' : hostsCount + ' host'
  868. component.set('component_value', hostsText);
  869. },
  870. /**
  871. * Onclick handler for <code>next</code> button
  872. */
  873. submit: function () {
  874. if (this.get('isSubmitDisabled')) {
  875. return;
  876. }
  877. if ((this.get('content.controllerName') == 'addHostController') && this.get('securityEnabled')) {
  878. var self = this;
  879. App.showConfirmationPopup(function() {
  880. self.submitProceed();
  881. }, Em.I18n.t('installer.step8.securityConfirmationPopupBody'));
  882. }
  883. else {
  884. this.submitProceed();
  885. }
  886. },
  887. submitProceed: function() {
  888. this.set('isSubmitDisabled', true);
  889. this.set('isBackBtnDisabled', true);
  890. if (this.get('content.controllerName') == 'addHostController') {
  891. App.router.get('addHostController').setLowerStepsDisable(4);
  892. }
  893. // checkpoint the cluster status on the server so that the user can resume from where they left off
  894. switch (this.get('content.controllerName')) {
  895. case 'installerController':
  896. App.clusterStatus.setClusterStatus({
  897. clusterName: this.get('clusterName'),
  898. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  899. wizardControllerName: this.get('content.controllerName'),
  900. localdb: App.db.data
  901. });
  902. break;
  903. case 'addHostController':
  904. App.clusterStatus.setClusterStatus({
  905. clusterName: this.get('clusterName'),
  906. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  907. wizardControllerName: this.get('content.controllerName'),
  908. localdb: App.db.data
  909. });
  910. break;
  911. case 'addServiceController':
  912. App.clusterStatus.setClusterStatus({
  913. clusterName: this.get('clusterName'),
  914. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  915. wizardControllerName: this.get('content.controllerName'),
  916. localdb: App.db.data
  917. });
  918. break;
  919. default:
  920. break;
  921. }
  922. // delete any existing clusters to start from a clean slate
  923. // before creating a new cluster in install wizard
  924. // TODO: modify for multi-cluster support
  925. if (this.get('content.controllerName') == 'installerController' && (!App.testMode)) {
  926. var clusterNames = this.getExistingClusterNames();
  927. this.deleteClusters(clusterNames);
  928. }
  929. this.setLocalRepositories();
  930. this.createCluster();
  931. this.createSelectedServices();
  932. this.createConfigurations();
  933. this.createComponents();
  934. this.registerHostsToCluster();
  935. if (App.supports.hostOverridesInstaller) {
  936. this.createConfigurationGroups();
  937. }
  938. this.createAllHostComponents();
  939. this.createHostOverrideConfigurations();
  940. this.ajaxQueueFinished = function () {
  941. console.log('everything is loaded');
  942. App.router.send('next');
  943. };
  944. this.doNextAjaxCall();
  945. },
  946. /**
  947. * Used in progress bar
  948. */
  949. ajaxQueueLength: function () {
  950. return this.get('ajaxQueue').length;
  951. }.property('ajaxQueue.length'),
  952. /**
  953. * Used in progress bar
  954. */
  955. ajaxQueueLeft: 0,
  956. setAmbariUIDb: function () {
  957. var dbContent = this.get('content.slaveGroupProperties');
  958. var slaveComponentConfig = this.get("slaveComponentConfig");
  959. this.persistKeyValues(slaveComponentConfig.version, dbContent);
  960. this.persistKeyValues('current_version', slaveComponentConfig.version);
  961. },
  962. persistKeyValues: function (key, value) {
  963. var str = "{ '" + key + "' : '" + JSON.stringify(value) + "'}";
  964. var obj = eval("(" + str + ")");
  965. this.ajax({
  966. type: "POST",
  967. url: App.apiPrefix + '/persist',
  968. data: JSON.stringify(obj),
  969. beforeSend: function () {
  970. console.log('BeforeSend: persistKeyValues', obj);
  971. }
  972. });
  973. },
  974. clusterName: function () {
  975. return this.get('content.cluster.name');
  976. }.property('content.cluster.name'),
  977. clusterNames: [],
  978. // returns an array of existing cluster names.
  979. // returns an empty array if there are no existing clusters.
  980. getExistingClusterNames: function () {
  981. var url = App.apiPrefix + '/clusters';
  982. App.ajax.send({
  983. name: 'wizard.step8.existing_cluster_names',
  984. sender: this,
  985. success: 'getExistingClusterNamesSuccessCallBack',
  986. error: 'getExistingClusterNamesErrorCallback'
  987. });
  988. return this.get('clusterNames');
  989. },
  990. getExistingClusterNamesSuccessCallBack: function (data) {
  991. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  992. console.log("Got existing cluster names: " + clusterNames);
  993. this.set('clusterNames', clusterNames);
  994. },
  995. getExistingClusterNamesErrorCallback: function () {
  996. console.log("Failed to get existing cluster names");
  997. this.set('clusterNames', []);
  998. },
  999. deleteClusters: function (clusterNames) {
  1000. clusterNames.forEach(function (clusterName) {
  1001. App.ajax.send({
  1002. name: 'wizard.step8.delete_cluster',
  1003. sender: this,
  1004. data: {
  1005. name: clusterName
  1006. },
  1007. success: 'deleteClustersSuccessCallback',
  1008. error: 'deleteClustersErrorCallback'
  1009. });
  1010. }, this);
  1011. },
  1012. deleteClustersSuccessCallback: function(data, opt, params) {
  1013. console.log('DELETE cluster ' + params.name + ' succeeded');
  1014. },
  1015. deleteClustersErrorCallback: function(request, ajaxOptions, error, opt) {
  1016. console.log('DELETE cluster failed');
  1017. },
  1018. /**
  1019. * Updates local repositories for the Ambari server.
  1020. */
  1021. setLocalRepositories: function () {
  1022. if (this.get('content.controllerName') !== 'installerController' || !App.supports.localRepositories) {
  1023. return false;
  1024. }
  1025. var self = this;
  1026. var apiUrl = App.get('stack2VersionURL');
  1027. var stacks = this.get('content.stacks');
  1028. stacks.forEach(function (stack) {
  1029. stack.operatingSystems.forEach(function (os) {
  1030. if (os.baseUrl !== os.originalBaseUrl) {
  1031. console.log("Updating local repository URL from " + os.originalBaseUrl + " -> " + os.baseUrl + ". ", os);
  1032. var url = App.apiPrefix + apiUrl + "/operatingSystems/" + os.osType + "/repositories/" + stack.name;
  1033. self.ajax({
  1034. type: 'PUT',
  1035. url: url,
  1036. data: JSON.stringify({
  1037. "Repositories": {
  1038. "base_url": os.baseUrl
  1039. }
  1040. }),
  1041. beforeSend: function () {
  1042. console.log("BeforeSend: setLocalRepositories PUT to ", url);
  1043. }
  1044. });
  1045. }
  1046. });
  1047. });
  1048. },
  1049. /**
  1050. * The following create* functions are called upon submitting Step 8.
  1051. */
  1052. createCluster: function () {
  1053. if (this.get('content.controllerName') !== 'installerController') {
  1054. return false;
  1055. }
  1056. var clusterName = this.get('clusterName');
  1057. var url = App.apiPrefix + '/clusters/' + clusterName;
  1058. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  1059. this.ajax({
  1060. type: 'POST',
  1061. url: url,
  1062. data: JSON.stringify({ "Clusters": {"version": stackVersion }}),
  1063. beforeSend: function () {
  1064. console.log("BeforeSend: createCluster for " + clusterName);
  1065. }
  1066. });
  1067. },
  1068. createSelectedServices: function () {
  1069. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services';
  1070. var data = this.createServiceData();
  1071. var httpMethod = 'POST';
  1072. if (!data.length) {
  1073. return;
  1074. }
  1075. this.ajax({
  1076. type: httpMethod,
  1077. url: url,
  1078. data: JSON.stringify(data),
  1079. beforeSend: function () {
  1080. console.log('BeforeSend: createSelectedServices ', data);
  1081. }
  1082. });
  1083. },
  1084. createServiceData: function () {
  1085. var services = this.get('selectedServices').mapProperty('serviceName');
  1086. var data = [];
  1087. services.forEach(function (_service) {
  1088. data.pushObject({"ServiceInfo": { "service_name": _service }});
  1089. }, this);
  1090. return data;
  1091. },
  1092. createComponents: function () {
  1093. var serviceComponents = require('data/service_components');
  1094. var services = this.get('selectedServices').mapProperty('serviceName');
  1095. services.forEach(function (_service) {
  1096. var components = serviceComponents.filterProperty('service_name', _service);
  1097. var componentsData = components.map(function (_component) {
  1098. return { "ServiceComponentInfo": { "component_name": _component.component_name } };
  1099. });
  1100. // Service must be specified in terms of a query for creating multiple components at the same time.
  1101. // See AMBARI-1018.
  1102. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services?ServiceInfo/service_name=' + _service;
  1103. var data = {
  1104. "components": componentsData
  1105. }
  1106. this.ajax({
  1107. type: 'POST',
  1108. url: url,
  1109. data: JSON.stringify(data),
  1110. beforeSend: function () {
  1111. console.log('BeforeSend: createComponents for ' + _service, componentsData);
  1112. }
  1113. });
  1114. }, this);
  1115. },
  1116. registerHostsToCluster: function () {
  1117. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1118. var data = this.createRegisterHostData();
  1119. if (data.length == 0) {
  1120. return;
  1121. }
  1122. this.ajax({
  1123. type: 'POST',
  1124. url: url,
  1125. data: JSON.stringify(data),
  1126. beforeSend: function () {
  1127. console.log('BeforeSend: registerHostsToCluster', data);
  1128. }
  1129. });
  1130. },
  1131. createRegisterHostData: function () {
  1132. var hosts = this.getRegisteredHosts().filterProperty('isInstalled', false);
  1133. if (!hosts.length) {
  1134. return [];
  1135. }
  1136. return hosts.map(function (host) {
  1137. return {"Hosts": { "host_name": host.hostName}};
  1138. });
  1139. },
  1140. // TODO: review the code for add hosts / add services scenarios...
  1141. createAllHostComponents: function () {
  1142. var masterHosts = this.get('content.masterComponentHosts');
  1143. var slaveHosts = this.get('content.slaveComponentHosts');
  1144. var clients = this.get('content.clients');
  1145. // note: masterHosts has 'component' vs slaveHosts has 'componentName'
  1146. var masterComponents = masterHosts.mapProperty('component').uniq();
  1147. masterComponents.forEach(function (component) {
  1148. var hostNames = masterHosts.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  1149. this.registerHostsToComponent(hostNames, component);
  1150. }, this);
  1151. slaveHosts.forEach(function (_slave) {
  1152. if (_slave.componentName !== 'CLIENT') {
  1153. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  1154. this.registerHostsToComponent(hostNames, _slave.componentName);
  1155. } else {
  1156. clients.forEach(function (_client) {
  1157. var hostNames = _slave.hosts.mapProperty('hostName');
  1158. switch (_client.component_name) {
  1159. case 'HDFS_CLIENT':
  1160. // install HDFS_CLIENT on HBASE_MASTER, HBASE_REGIONSERVER, WEBHCAT_SERVER, HISTORYSERVER and OOZIE_SERVER hosts
  1161. masterHosts.filterProperty('component', 'HBASE_MASTER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1162. hostNames.pushObject(_masterHost.hostName);
  1163. }, this);
  1164. masterHosts.filterProperty('component', 'HBASE_REGIONSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1165. hostNames.pushObject(_masterHost.hostName);
  1166. }, this);
  1167. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1168. hostNames.pushObject(_masterHost.hostName);
  1169. }, this);
  1170. masterHosts.filterProperty('component', 'HISTORYSERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1171. hostNames.pushObject(_masterHost.hostName);
  1172. }, this);
  1173. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1174. hostNames.pushObject(_masterHost.hostName);
  1175. }, this);
  1176. break;
  1177. case 'MAPREDUCE_CLIENT':
  1178. // install MAPREDUCE_CLIENT on HIVE_SERVER, OOZIE_SERVER, NAGIOS_SERVER, and WEBHCAT_SERVER hosts
  1179. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1180. hostNames.pushObject(_masterHost.hostName);
  1181. }, this);
  1182. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1183. hostNames.pushObject(_masterHost.hostName);
  1184. }, this);
  1185. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1186. hostNames.pushObject(_masterHost.hostName);
  1187. }, this);
  1188. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1189. hostNames.pushObject(_masterHost.hostName);
  1190. }, this);
  1191. break;
  1192. case 'OOZIE_CLIENT':
  1193. // install OOZIE_CLIENT on NAGIOS_SERVER host
  1194. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1195. hostNames.pushObject(_masterHost.hostName);
  1196. }, this);
  1197. break;
  1198. case 'ZOOKEEPER_CLIENT':
  1199. // install ZOOKEEPER_CLIENT on WEBHCAT_SERVER host
  1200. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1201. hostNames.pushObject(_masterHost.hostName);
  1202. }, this);
  1203. break;
  1204. case 'HIVE_CLIENT':
  1205. //install HIVE client on NAGIOS_SERVER host
  1206. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1207. hostNames.pushObject(_masterHost.hostName);
  1208. }, this);
  1209. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1210. hostNames.pushObject(_masterHost.hostName);
  1211. }, this);
  1212. break;
  1213. case 'HCAT':
  1214. // install HCAT (client) on NAGIOS_SERVER host
  1215. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1216. hostNames.pushObject(_masterHost.hostName);
  1217. }, this);
  1218. break;
  1219. case 'YARN_CLIENT':
  1220. // install YARN_CLIENT on NAGIOS_SERVER,HIVE_SERVER,OOZIE_SERVER,WEBHCAT_SERVER host
  1221. masterHosts.filterProperty('component', 'NAGIOS_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1222. hostNames.pushObject(_masterHost.hostName);
  1223. }, this);
  1224. masterHosts.filterProperty('component', 'HIVE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1225. hostNames.pushObject(_masterHost.hostName);
  1226. }, this);
  1227. masterHosts.filterProperty('component', 'OOZIE_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1228. hostNames.pushObject(_masterHost.hostName);
  1229. }, this);
  1230. masterHosts.filterProperty('component', 'WEBHCAT_SERVER').filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1231. hostNames.pushObject(_masterHost.hostName);
  1232. }, this);
  1233. break;
  1234. }
  1235. hostNames = hostNames.uniq();
  1236. if (_client.isInstalled) {
  1237. //check whether clients are already installed on selected master hosts!!!
  1238. var installedHosts = _slave.hosts.filterProperty('isInstalled', true).mapProperty('hostName');
  1239. installedHosts.forEach(function (host) {
  1240. if (hostNames.contains(host)) {
  1241. hostNames.splice(hostNames.indexOf(host), 1);
  1242. }
  1243. }, this);
  1244. }
  1245. this.registerHostsToComponent(hostNames, _client.component_name);
  1246. }, this);
  1247. }
  1248. }, this);
  1249. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  1250. var gangliaService = this.get('content.services').filterProperty('isSelected', true).findProperty('serviceName', 'GANGLIA');
  1251. if (gangliaService) {
  1252. var hosts = this.getRegisteredHosts();
  1253. if (gangliaService.get('isInstalled')) {
  1254. hosts = hosts.filterProperty('isInstalled', false);
  1255. }
  1256. if (hosts.length) {
  1257. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  1258. }
  1259. }
  1260. // add MySQL Server if Hive is selected
  1261. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1262. if (hiveService) {
  1263. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  1264. if(hiveDb.value == "New MySQL Database") {
  1265. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1266. }
  1267. }
  1268. },
  1269. registerHostsToComponent: function (hostNames, componentName) {
  1270. if (hostNames.length == 0) {
  1271. return;
  1272. }
  1273. // currently we are specifying the predicate as a query string.
  1274. // this can hit a ~4000-character limit in Jetty server.
  1275. // chunk to multiple calls if needed
  1276. // var hostsPredicate = hostNames.map(function (hostName) {
  1277. // return 'Hosts/host_name=' + hostName;
  1278. // }).join('|');
  1279. var queryStrArr = [];
  1280. var queryStr = '';
  1281. hostNames.forEach(function (hostName) {
  1282. queryStr += 'Hosts/host_name=' + hostName + '|';
  1283. if (queryStr.length > 3500) {
  1284. queryStrArr.push(queryStr.slice(0, -1));
  1285. queryStr = '';
  1286. }
  1287. });
  1288. if (queryStr.length > 0) {
  1289. queryStrArr.push(queryStr.slice(0, -1));
  1290. }
  1291. queryStrArr.forEach(function (queryStr) {
  1292. // console.log('creating host components for ' + queryStr);
  1293. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts?' + queryStr;
  1294. var data = {
  1295. "host_components": [
  1296. {
  1297. "HostRoles": {
  1298. "component_name": componentName
  1299. }
  1300. }
  1301. ]
  1302. };
  1303. this.ajax({
  1304. type: 'POST',
  1305. url: url,
  1306. data: JSON.stringify(data)
  1307. });
  1308. }, this);
  1309. },
  1310. createConfigurations: function () {
  1311. var selectedServices = this.get('selectedServices');
  1312. if (this.get('content.controllerName') == 'installerController') {
  1313. this.get('serviceConfigTags').pushObject(this.createCoreSiteObj());
  1314. this.get('serviceConfigTags').pushObject(this.createHdfsSiteObj());
  1315. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HDFS'));
  1316. }
  1317. var globalSiteObj = this.createGlobalSiteObj();
  1318. if (this.get('content.controllerName') == 'addServiceController') {
  1319. globalSiteObj.tag = 'version' + (new Date).getTime();
  1320. }
  1321. this.get('serviceConfigTags').pushObject(globalSiteObj);
  1322. if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
  1323. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  1324. if (App.supports.capacitySchedulerUi) {
  1325. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  1326. this.get('serviceConfigTags').pushObject(this.createMapredQueueAcls());
  1327. }
  1328. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE'));
  1329. }
  1330. if (selectedServices.someProperty('serviceName', 'MAPREDUCE2')) {
  1331. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  1332. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE2'));
  1333. }
  1334. if (selectedServices.someProperty('serviceName', 'YARN')) {
  1335. this.get('serviceConfigTags').pushObject(this.createYarnSiteObj());
  1336. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  1337. this.get('serviceConfigTags').pushObject(this.createLog4jObj('YARN'));
  1338. }
  1339. if (selectedServices.someProperty('serviceName', 'HBASE')) {
  1340. this.get('serviceConfigTags').pushObject(this.createHbaseSiteObj());
  1341. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HBASE'));
  1342. }
  1343. if (selectedServices.someProperty('serviceName', 'OOZIE')) {
  1344. this.get('serviceConfigTags').pushObject(this.createOozieSiteObj('OOZIE'));
  1345. this.get('serviceConfigTags').pushObject(this.createLog4jObj('OOZIE'));
  1346. }
  1347. if (selectedServices.someProperty('serviceName', 'HIVE')) {
  1348. this.get('serviceConfigTags').pushObject(this.createHiveSiteObj('HIVE'));
  1349. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE'));
  1350. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE-EXEC'));
  1351. }
  1352. if (selectedServices.someProperty('serviceName', 'WEBHCAT')) {
  1353. this.get('serviceConfigTags').pushObject(this.createWebHCatSiteObj('WEBHCAT'));
  1354. }
  1355. if (selectedServices.someProperty('serviceName', 'HUE')) {
  1356. this.get('serviceConfigTags').pushObject(this.createHueSiteObj('HUE'));
  1357. }
  1358. if (selectedServices.someProperty('serviceName', 'PIG')) {
  1359. this.get('serviceConfigTags').pushObject(this.createLog4jObj('PIG'));
  1360. }
  1361. if (selectedServices.someProperty('serviceName', 'ZOOKEEPER')) {
  1362. this.get('serviceConfigTags').pushObject(this.createLog4jObj('ZOOKEEPER'));
  1363. }
  1364. this.applyConfigurationsToCluster();
  1365. },
  1366. applyConfigurationsToCluster: function() {
  1367. var clusterUrl = App.apiPrefix + '/clusters/' + this.get('clusterName');
  1368. var configData = [];
  1369. this.get('serviceConfigTags').forEach(function (_serviceConfig) {
  1370. var Clusters = {
  1371. Clusters: {
  1372. desired_config: {
  1373. type: _serviceConfig.type,
  1374. tag: _serviceConfig.tag,
  1375. properties: _serviceConfig.properties
  1376. }
  1377. }
  1378. };
  1379. configData.pushObject(JSON.stringify(Clusters));
  1380. }, this);
  1381. var data = {
  1382. configData: '[' + configData.toString() + ']'
  1383. };
  1384. console.debug("applyConfigurationsToCluster(Step8): Applying to URL", clusterUrl, " Data:", data.configData);
  1385. this.ajax({
  1386. type: 'PUT',
  1387. url: clusterUrl,
  1388. data: data.configData,
  1389. beforeSend: function () {
  1390. console.log("BeforeSend: Updating cluster config");
  1391. }
  1392. });
  1393. },
  1394. createConfigurationGroups: function () {
  1395. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1396. var clusterName = this.get('clusterName');
  1397. var sendData = [];
  1398. var updateData = [];
  1399. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1400. var timeTag = (new Date).getTime();
  1401. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1402. if (groupsToDelete && groupsToDelete.length > 0) {
  1403. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1404. }
  1405. configGroups.forEach(function (configGroup) {
  1406. var groupConfigs = [];
  1407. var groupData = {
  1408. "cluster_name": clusterName,
  1409. "group_name": configGroup.name,
  1410. "tag": configGroup.service.id,
  1411. "description": configGroup.description,
  1412. "hosts": [],
  1413. "desired_configs": []
  1414. };
  1415. configGroup.hosts.forEach(function (hostName) {
  1416. groupData.hosts.push({"host_name": hostName});
  1417. });
  1418. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1419. configGroup.properties.forEach(function (property) {
  1420. groupConfigs.push(Em.Object.create(property));
  1421. });
  1422. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1423. // check for group from installed service
  1424. if (configGroup.isForUpdate === true) {
  1425. // if group is a new one, create it
  1426. if (!configGroup.id) {
  1427. sendData.push({"ConfigGroup": groupData});
  1428. } else {
  1429. // update an existing group
  1430. groupData.id = configGroup.id;
  1431. updateData.push({"ConfigGroup": groupData});
  1432. }
  1433. } else {
  1434. sendData.push({"ConfigGroup": groupData});
  1435. }
  1436. //each group should have unique tag to prevent overriding configs from common sites
  1437. timeTag++;
  1438. }, this);
  1439. if (sendData.length > 0) {
  1440. this.applyConfigurationGroups(sendData);
  1441. }
  1442. if (updateData.length > 0) {
  1443. this.applyInstalledServicesConfigurationGroup(updateData);
  1444. }
  1445. },
  1446. applyConfigurationGroups: function (sendData) {
  1447. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/config_groups';
  1448. this.ajax({
  1449. type: 'POST',
  1450. url: url,
  1451. data: JSON.stringify(sendData)
  1452. });
  1453. },
  1454. applyInstalledServicesConfigurationGroup: function (updateData) {
  1455. updateData.forEach(function(item) {
  1456. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1457. });
  1458. },
  1459. removeInstalledServicesConfigurationGroups: function(groupsToDelete) {
  1460. groupsToDelete.forEach(function(item) {
  1461. App.config.deleteConfigGroup(Em.Object.create(item));
  1462. });
  1463. },
  1464. createGlobalSiteObj: function () {
  1465. var globalSiteProperties = {};
  1466. var globalSiteObj = this.get('globals');
  1467. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1468. // screen out the GLUSTERFS-specific global config entries when they are not required
  1469. if (!isGLUSTERFSSelected) {
  1470. globalSiteObj = globalSiteObj.filter(function(_config) {
  1471. return _config.name.indexOf("fs_glusterfs") < 0;
  1472. });
  1473. }
  1474. globalSiteObj.forEach(function (_globalSiteObj) {
  1475. var heapsizeException = ['hadoop_heapsize','yarn_heapsize','nodemanager_heapsize','resourcemanager_heapsize'];
  1476. // do not pass any globals whose name ends with _host or _hosts
  1477. if (_globalSiteObj.isRequiredByAgent !== false) {
  1478. // append "m" to JVM memory options except for hadoop_heapsize
  1479. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && !heapsizeException.contains(_globalSiteObj.name)) {
  1480. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value + "m";
  1481. } else {
  1482. globalSiteProperties[_globalSiteObj.name] = App.config.escapeXMLCharacters(_globalSiteObj.value);
  1483. }
  1484. }
  1485. this._recordHostOverrideFromObj(_globalSiteObj, 'global', 'version1', this);
  1486. }, this);
  1487. // we don't expose gmond_user to the user; it needs to be the same as gmetad_user
  1488. globalSiteProperties['gmond_user'] = globalSiteProperties['gmetad_user'];
  1489. return {"type": "global", "tag": "version1", "properties": globalSiteProperties};
  1490. },
  1491. createCoreSiteObj: function () {
  1492. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
  1493. var coreSiteProperties = {};
  1494. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  1495. var isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE');
  1496. var oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null;
  1497. var isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE');
  1498. var hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null;
  1499. var isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT');
  1500. var hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null;
  1501. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1502. // screen out the GLUSTERFS-specific core-site.xml entries when they are not needed
  1503. if (!isGLUSTERFSSelected) {
  1504. coreSiteObj = coreSiteObj.filter(function(_config) {
  1505. return _config.name.indexOf("fs.glusterfs") < 0;
  1506. });
  1507. }
  1508. coreSiteObj.forEach(function (_coreSiteObj) {
  1509. if ((isOozieSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.groups')) && (isHiveSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.groups')) && (isHcatSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.groups'))) {
  1510. coreSiteProperties[_coreSiteObj.name] = App.config.escapeXMLCharacters(_coreSiteObj.value);
  1511. this._recordHostOverrideFromObj(_coreSiteObj, 'core-site', 'version1', this);
  1512. }
  1513. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1514. coreSiteProperties[_coreSiteObj.name] = this.get('globals').someProperty('name', 'fs_glusterfs_default_name') ? App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'fs_glusterfs_default_name').value) : null;
  1515. }
  1516. console.log("STEP*: name of the property is: " + _coreSiteObj.name);
  1517. console.log("STEP8: value of the property is: " + _coreSiteObj.value);
  1518. }, this);
  1519. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1520. },
  1521. createHdfsSiteObj: function () {
  1522. var hdfsSiteObj = this.get('configs').filterProperty('filename', 'hdfs-site.xml');
  1523. var hdfsProperties = {};
  1524. hdfsSiteObj.forEach(function (_configProperty) {
  1525. hdfsProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1526. this._recordHostOverrideFromObj(_configProperty, 'hdfs-site', 'version1', this);
  1527. console.log("STEP*: name of the property is: " + _configProperty.name);
  1528. console.log("STEP8: value of the property is: " + _configProperty.value);
  1529. }, this);
  1530. return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
  1531. },
  1532. createLog4jObj: function (fileName) {
  1533. fileName = fileName.toLowerCase();
  1534. var Log4jObj = this.get('configs').filterProperty('filename', fileName + '-log4j.xml');
  1535. var Log4jProperties = {};
  1536. Log4jObj.forEach(function (_configProperty) {
  1537. Log4jProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1538. this._recordHostOverrideFromObj(_configProperty, fileName + '-log4j', 'version1', this);
  1539. console.log("STEP*: name of the property is: " + _configProperty.name);
  1540. console.log("STEP8: value of the property is: " + _configProperty.value);
  1541. }, this);
  1542. return {"type": fileName + "-log4j", "tag": "version1", "properties": Log4jProperties };
  1543. },
  1544. createHueSiteObj: function () {
  1545. var hueSiteObj = this.get('configs').filterProperty('filename', 'hue-site.xml');
  1546. var hueProperties = {};
  1547. hueSiteObj.forEach(function (_configProperty) {
  1548. hueProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1549. this._recordHostOverrideFromObj(_configProperty, 'hue-site', 'version1', this);
  1550. console.log("STEP*: name of the property is: " + _configProperty.name);
  1551. console.log("STEP8: value of the property is: " + _configProperty.value);
  1552. }, this);
  1553. return {"type": "hue-site", "tag": "version1", "properties": hueProperties };
  1554. },
  1555. createMrSiteObj: function () {
  1556. var configs = this.get('configs').filterProperty('filename', 'mapred-site.xml');
  1557. var mrProperties = {};
  1558. configs.forEach(function (_configProperty) {
  1559. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1560. this._recordHostOverrideFromObj(_configProperty, 'mapred-site', 'version1', this);
  1561. console.log("STEP*: name of the property is: " + _configProperty.name);
  1562. console.log("STEP8: value of the property is: " + _configProperty.value);
  1563. }, this);
  1564. return {type: 'mapred-site', tag: 'version1', properties: mrProperties};
  1565. },
  1566. createYarnSiteObj: function () {
  1567. var configs = this.get('configs').filterProperty('filename', 'yarn-site.xml');
  1568. var mrProperties = {};
  1569. configs.forEach(function (_configProperty) {
  1570. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1571. this._recordHostOverrideFromObj(_configProperty, 'yarn-site', 'version1', this);
  1572. console.log("STEP*: name of the property is: " + _configProperty.name);
  1573. console.log("STEP8: value of the property is: " + _configProperty.value);
  1574. }, this);
  1575. return {type: 'yarn-site', tag: 'version1', properties: mrProperties};
  1576. },
  1577. createCapacityScheduler: function () {
  1578. var configs = this.get('configs').filterProperty('filename', 'capacity-scheduler.xml');
  1579. var csProperties = {};
  1580. configs.forEach(function (_configProperty) {
  1581. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1582. this._recordHostOverrideFromObj(_configProperty, 'capacity-scheduler', 'version1', this);
  1583. console.log("STEP*: name of the property is: " + _configProperty.name);
  1584. console.log("STEP8: value of the property is: " + _configProperty.value);
  1585. }, this);
  1586. return {type: 'capacity-scheduler', tag: 'version1', properties: csProperties};
  1587. },
  1588. createMapredQueueAcls: function () {
  1589. var configs = this.get('configs').filterProperty('filename', 'mapred-queue-acls.xml');
  1590. var mqProperties = {};
  1591. configs.forEach(function (_configProperty) {
  1592. mqProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1593. this._recordHostOverrideFromObj(_configProperty, 'mapred-queue-acls', 'version1', this);
  1594. console.log("STEP*: name of the property is: " + _configProperty.name);
  1595. console.log("STEP8: value of the property is: " + _configProperty.value);
  1596. }, this);
  1597. return {type: 'mapred-queue-acls', tag: 'version1', properties: mqProperties};
  1598. },
  1599. createHbaseSiteObj: function () {
  1600. var configs = this.get('configs').filterProperty('filename', 'hbase-site.xml');
  1601. var hbaseProperties = {};
  1602. configs.forEach(function (_configProperty) {
  1603. hbaseProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1604. this._recordHostOverrideFromObj(_configProperty, 'hbase-site', 'version1', this);
  1605. }, this);
  1606. return {type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
  1607. },
  1608. createOozieSiteObj: function (serviceName) {
  1609. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1610. var oozieProperties = {};
  1611. configs.forEach(function (_configProperty) {
  1612. oozieProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1613. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1614. }, this);
  1615. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1616. if (globals.someProperty('name', 'oozie_database')) {
  1617. var oozieDb = globals.findProperty('name', 'oozie_database');
  1618. if (oozieDb.value === 'New Derby Database') {
  1619. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true";
  1620. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "org.apache.derby.jdbc.EmbeddedDriver";
  1621. } else if (oozieDb.value === 'Existing MySQL Database') {
  1622. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:mysql://" + oozieHost + "/" + oozieDbName;
  1623. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "com.mysql.jdbc.Driver";
  1624. } else { //existing oracle database
  1625. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:oracle:thin:@//" + oozieHost + ":1521/" + oozieDbName;
  1626. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "oracle.jdbc.driver.OracleDriver";
  1627. }
  1628. }
  1629. return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};
  1630. },
  1631. createHiveSiteObj: function (serviceName) {
  1632. var configs = this.get('configs').filterProperty('filename', 'hive-site.xml');
  1633. var hiveProperties = {};
  1634. configs.forEach(function (_configProperty) {
  1635. hiveProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1636. this._recordHostOverrideFromObj(_configProperty, 'hive-site', 'version1', this);
  1637. }, this);
  1638. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1639. if (globals.someProperty('name', 'hive_database')) {
  1640. var hiveDb = globals.findProperty('name', 'hive_database');
  1641. if (hiveDb.value === 'New MySQL Database') {
  1642. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "com.mysql.jdbc.Driver";
  1643. } else if (hiveDb.value === 'Existing MySQL Database'){
  1644. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "com.mysql.jdbc.Driver";
  1645. } else { //existing oracle database
  1646. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "oracle.jdbc.driver.OracleDriver";
  1647. }
  1648. }
  1649. return {type: 'hive-site', tag: 'version1', properties: hiveProperties};
  1650. },
  1651. createWebHCatSiteObj: function (serviceName) {
  1652. var configs = this.get('configs').filterProperty('filename', 'webhcat-site.xml');
  1653. var webHCatProperties = {};
  1654. configs.forEach(function (_configProperty) {
  1655. webHCatProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1656. this._recordHostOverrideFromObj(_configProperty, 'webhcat-site', 'version1', this);
  1657. }, this);
  1658. return {type: 'webhcat-site', tag: 'version1', properties: webHCatProperties};
  1659. },
  1660. ajaxQueueFinished: function () {
  1661. //do something
  1662. },
  1663. doNextAjaxCall: function () {
  1664. if (this.get('ajaxBusy')) {
  1665. return;
  1666. }
  1667. var queue = this.get('ajaxQueue');
  1668. if (!queue.length) {
  1669. this.ajaxQueueFinished();
  1670. return;
  1671. }
  1672. var first = queue[0];
  1673. this.set('ajaxQueue', queue.slice(1));
  1674. this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
  1675. this.set('ajaxBusy', true);
  1676. $.ajax(first);
  1677. },
  1678. /**
  1679. * Records all the host overrides per site/tag
  1680. */
  1681. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1682. var overrides = serviceConfigObj.overrides;
  1683. if(overrides && overrides.length>0){
  1684. overrides.forEach(function(override){
  1685. override.hosts.forEach(function(host){
  1686. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1687. self.savedHostToOverrideSiteToTagMap[host] = {};
  1688. }
  1689. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1690. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1691. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1692. }
  1693. var finalTag = tagName + '_' + host;
  1694. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.value+")");
  1695. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1696. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.value;
  1697. });
  1698. });
  1699. }
  1700. },
  1701. /**
  1702. * Creates host level overrides for service configuration.
  1703. *
  1704. */
  1705. createHostOverrideConfigurations: function () {
  1706. var singlePUTHostData = [];
  1707. var savedHostSiteArray = [];
  1708. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1709. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1710. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1711. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1712. savedHostSiteArray.push(host + "///" + siteName);
  1713. singlePUTHostData.push({
  1714. RequestInfo: {
  1715. query: 'Hosts/host_name='+host
  1716. },
  1717. Body: {
  1718. Hosts: {
  1719. desired_config: {
  1720. type: siteName,
  1721. tag: tagName,
  1722. properties: map
  1723. }
  1724. }
  1725. }
  1726. });
  1727. }
  1728. }
  1729. console.log("createHostOverrideConfigSites(): PUTting host-overrides. Data=", singlePUTHostData);
  1730. if(singlePUTHostData.length>0){
  1731. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1732. this.ajax({
  1733. type: 'PUT',
  1734. url: url,
  1735. data: JSON.stringify(singlePUTHostData),
  1736. dataType: 'text',
  1737. beforeSend: function () {
  1738. console.log("createHostOverrideConfigSites() PUT override=", singlePUTHostData);
  1739. }
  1740. });
  1741. }
  1742. },
  1743. /**
  1744. * We need to do a lot of ajax calls async in special order. To do this,
  1745. * generate array of ajax objects and then send requests step by step. All
  1746. * ajax objects are stored in <code>ajaxQueue</code>
  1747. *
  1748. * @param params
  1749. */
  1750. ajax: function (params) {
  1751. if (App.testMode) return;
  1752. var self = this;
  1753. params = jQuery.extend({
  1754. async: true,
  1755. dataType: 'text',
  1756. statusCode: require('data/statusCodes'),
  1757. timeout: App.timeout,
  1758. error: function (request, ajaxOptions, error) {
  1759. console.log('Step8: In Error ');
  1760. // console.log('Step8: Error message is: ' + request.responseText);
  1761. },
  1762. success: function (data) {
  1763. console.log("TRACE: STep8 -> In success function");
  1764. }
  1765. }, params);
  1766. var success = params.success;
  1767. var error = params.error;
  1768. params.success = function () {
  1769. if (success) {
  1770. success();
  1771. }
  1772. self.set('ajaxBusy', false);
  1773. self.doNextAjaxCall();
  1774. }
  1775. params.error = function (xhr, status, error) {
  1776. var responseText = JSON.parse(xhr.responseText);
  1777. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1778. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1779. self.set('hasErrorOccurred', true);
  1780. // an error will break the ajax call chain and allow submission again
  1781. self.set('isSubmitDisabled', false);
  1782. self.set('isBackBtnDisabled', false);
  1783. App.router.get(self.get('content.controllerName')).setStepsEnable();
  1784. self.get('ajaxQueue').clear();
  1785. self.set('ajaxBusy', false);
  1786. }
  1787. this.get('ajaxQueue').pushObject(params);
  1788. }
  1789. });