step8_controller.js 74 KB

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