step8_controller.js 69 KB

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