step8_controller.js 69 KB

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