step8_controller.js 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742
  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. this.get('serviceConfigTags').pushObject(this.createMapredQueueAcls());
  1196. }
  1197. if (selectedServices.someProperty('serviceName', 'YARN')) {
  1198. this.get('serviceConfigTags').pushObject(this.createYarnSiteObj());
  1199. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  1200. }
  1201. if (selectedServices.someProperty('serviceName', 'HBASE')) {
  1202. this.get('serviceConfigTags').pushObject(this.createHbaseSiteObj());
  1203. }
  1204. if (selectedServices.someProperty('serviceName', 'OOZIE')) {
  1205. this.get('serviceConfigTags').pushObject(this.createOozieSiteObj('OOZIE'));
  1206. }
  1207. if (selectedServices.someProperty('serviceName', 'HIVE')) {
  1208. this.get('serviceConfigTags').pushObject(this.createHiveSiteObj('HIVE'));
  1209. }
  1210. if (selectedServices.someProperty('serviceName', 'WEBHCAT')) {
  1211. this.get('serviceConfigTags').pushObject(this.createWebHCatSiteObj('WEBHCAT'));
  1212. }
  1213. if (selectedServices.someProperty('serviceName', 'HUE')) {
  1214. this.get('serviceConfigTags').pushObject(this.createHueSiteObj('HUE'));
  1215. }
  1216. this.applyConfigurationsToCluster();
  1217. },
  1218. applyConfigurationsToCluster: function() {
  1219. var clusterUrl = App.apiPrefix + '/clusters/' + this.get('clusterName');
  1220. var configData = [];
  1221. this.get('serviceConfigTags').forEach(function (_serviceConfig) {
  1222. var Clusters = {
  1223. Clusters: {
  1224. desired_config: {
  1225. type: _serviceConfig.type,
  1226. tag: _serviceConfig.tag,
  1227. properties: _serviceConfig.properties
  1228. }
  1229. }
  1230. };
  1231. configData.pushObject(JSON.stringify(Clusters));
  1232. }, this);
  1233. var data = {
  1234. configData: '[' + configData.toString() + ']'
  1235. };
  1236. console.debug("applyConfigurationsToCluster(Step8): Applying to URL", clusterUrl, " Data:", data.configData);
  1237. this.ajax({
  1238. type: 'PUT',
  1239. url: clusterUrl,
  1240. data: data.configData,
  1241. beforeSend: function () {
  1242. console.log("BeforeSend: Updating cluster config");
  1243. }
  1244. });
  1245. },
  1246. createGlobalSiteObj: function () {
  1247. var globalSiteProperties = {};
  1248. var globalSiteObj = this.get('globals');
  1249. var isHCFSSelected = this.get('selectedServices').someProperty('serviceName', 'HCFS');
  1250. // screen out the HCFS-specific global config entries when they are not required
  1251. if (!isHCFSSelected) {
  1252. globalSiteObj = globalSiteObj.filter(function(_config) {
  1253. return _config.name.indexOf("fs_glusterfs") < 0;
  1254. });
  1255. }
  1256. globalSiteObj.forEach(function (_globalSiteObj) {
  1257. var heapsizeException = ['hadoop_heapsize','yarn_heapsize','nodemanager_heapsize','resourcemanager_heapsize'];
  1258. // do not pass any globals whose name ends with _host or _hosts
  1259. if (!/_hosts?$/.test(_globalSiteObj.name)) {
  1260. // append "m" to JVM memory options except for hadoop_heapsize
  1261. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && !heapsizeException.contains(_globalSiteObj.name)) {
  1262. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value + "m";
  1263. } else {
  1264. globalSiteProperties[_globalSiteObj.name] = App.config.escapeXMLCharacters(_globalSiteObj.value);
  1265. }
  1266. console.log("STEP8: name of the global property is: " + _globalSiteObj.name);
  1267. console.log("STEP8: value of the global property is: " + _globalSiteObj.value);
  1268. }
  1269. if (_globalSiteObj.name == 'java64_home') {
  1270. globalSiteProperties['java64_home'] = this.get('content.installOptions.javaHome');
  1271. }
  1272. this._recordHostOverrideFromObj(_globalSiteObj, 'global', 'version1', this);
  1273. }, this);
  1274. // we don't expose gmond_user to the user; it needs to be the same as gmetad_user
  1275. globalSiteProperties['gmond_user'] = globalSiteProperties['gmetad_user'];
  1276. return {"type": "global", "tag": "version1", "properties": globalSiteProperties};
  1277. },
  1278. createCoreSiteObj: function () {
  1279. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
  1280. var coreSiteProperties = {};
  1281. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  1282. var isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE');
  1283. var oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null;
  1284. var isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE');
  1285. var hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null;
  1286. var isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT');
  1287. var hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null;
  1288. var isHCFSSelected = this.get('selectedServices').someProperty('serviceName', 'HCFS');
  1289. // screen out the HCFS-specific core-site.xml entries when they are not needed
  1290. if (!isHCFSSelected) {
  1291. coreSiteObj = coreSiteObj.filter(function(_config) {
  1292. return _config.name.indexOf("fs.glusterfs") < 0;
  1293. });
  1294. }
  1295. coreSiteObj.forEach(function (_coreSiteObj) {
  1296. 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'))) {
  1297. coreSiteProperties[_coreSiteObj.name] = App.config.escapeXMLCharacters(_coreSiteObj.value);
  1298. this._recordHostOverrideFromObj(_coreSiteObj, 'core-site', 'version1', this);
  1299. }
  1300. if (isHCFSSelected && _coreSiteObj.name == "fs.default.name") {
  1301. 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;
  1302. }
  1303. console.log("STEP*: name of the property is: " + _coreSiteObj.name);
  1304. console.log("STEP8: value of the property is: " + _coreSiteObj.value);
  1305. }, this);
  1306. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1307. },
  1308. createHdfsSiteObj: function () {
  1309. var hdfsSiteObj = this.get('configs').filterProperty('filename', 'hdfs-site.xml');
  1310. var hdfsProperties = {};
  1311. hdfsSiteObj.forEach(function (_configProperty) {
  1312. hdfsProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1313. this._recordHostOverrideFromObj(_configProperty, 'hdfs-site', 'version1', this);
  1314. console.log("STEP*: name of the property is: " + _configProperty.name);
  1315. console.log("STEP8: value of the property is: " + _configProperty.value);
  1316. }, this);
  1317. return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
  1318. },
  1319. createHueSiteObj: function () {
  1320. var hueSiteObj = this.get('configs').filterProperty('filename', 'hue-site.xml');
  1321. var hueProperties = {};
  1322. hueSiteObj.forEach(function (_configProperty) {
  1323. hueProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1324. this._recordHostOverrideFromObj(_configProperty, 'hue-site', 'version1', this);
  1325. console.log("STEP*: name of the property is: " + _configProperty.name);
  1326. console.log("STEP8: value of the property is: " + _configProperty.value);
  1327. }, this);
  1328. return {"type": "hue-site", "tag": "version1", "properties": hueProperties };
  1329. },
  1330. createMrSiteObj: function () {
  1331. var configs = this.get('configs').filterProperty('filename', 'mapred-site.xml');
  1332. var mrProperties = {};
  1333. configs.forEach(function (_configProperty) {
  1334. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1335. this._recordHostOverrideFromObj(_configProperty, 'mapred-site', 'version1', this);
  1336. console.log("STEP*: name of the property is: " + _configProperty.name);
  1337. console.log("STEP8: value of the property is: " + _configProperty.value);
  1338. }, this);
  1339. return {type: 'mapred-site', tag: 'version1', properties: mrProperties};
  1340. },
  1341. createYarnSiteObj: function () {
  1342. var configs = this.get('configs').filterProperty('filename', 'yarn-site.xml');
  1343. var mrProperties = {};
  1344. configs.forEach(function (_configProperty) {
  1345. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1346. this._recordHostOverrideFromObj(_configProperty, 'yarn-site', 'version1', this);
  1347. console.log("STEP*: name of the property is: " + _configProperty.name);
  1348. console.log("STEP8: value of the property is: " + _configProperty.value);
  1349. }, this);
  1350. return {type: 'yarn-site', tag: 'version1', properties: mrProperties};
  1351. },
  1352. createCapacityScheduler: function () {
  1353. var configs = this.get('configs').filterProperty('filename', 'capacity-scheduler.xml');
  1354. var csProperties = {};
  1355. configs.forEach(function (_configProperty) {
  1356. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1357. this._recordHostOverrideFromObj(_configProperty, 'capacity-scheduler', 'version1', this);
  1358. console.log("STEP*: name of the property is: " + _configProperty.name);
  1359. console.log("STEP8: value of the property is: " + _configProperty.value);
  1360. }, this);
  1361. return {type: 'capacity-scheduler', tag: 'version1', properties: csProperties};
  1362. },
  1363. createMapredQueueAcls: function () {
  1364. var configs = this.get('configs').filterProperty('filename', 'mapred-queue-acls.xml');
  1365. var mqProperties = {};
  1366. configs.forEach(function (_configProperty) {
  1367. mqProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1368. this._recordHostOverrideFromObj(_configProperty, 'mapred-queue-acls', 'version1', this);
  1369. console.log("STEP*: name of the property is: " + _configProperty.name);
  1370. console.log("STEP8: value of the property is: " + _configProperty.value);
  1371. }, this);
  1372. return {type: 'mapred-queue-acls', tag: 'version1', properties: mqProperties};
  1373. },
  1374. createHbaseSiteObj: function () {
  1375. var configs = this.get('configs').filterProperty('filename', 'hbase-site.xml');
  1376. var hbaseProperties = {};
  1377. configs.forEach(function (_configProperty) {
  1378. hbaseProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1379. this._recordHostOverrideFromObj(_configProperty, 'hbase-site', 'version1', this);
  1380. }, this);
  1381. return {type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
  1382. },
  1383. createOozieSiteObj: function (serviceName) {
  1384. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1385. var oozieProperties = {};
  1386. configs.forEach(function (_configProperty) {
  1387. oozieProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1388. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1389. }, this);
  1390. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1391. if (globals.someProperty('name', 'oozie_database')) {
  1392. var oozieDb = globals.findProperty('name', 'oozie_database');
  1393. var oozieHost = globals.findProperty('name', 'oozie_hostname').value;
  1394. var oozieDbName = globals.findProperty('name', 'oozie_database_name').value;
  1395. if (oozieDb.value === 'New Derby Database') {
  1396. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true";
  1397. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "org.apache.derby.jdbc.EmbeddedDriver";
  1398. } else if (oozieDb.value === 'Existing MySQL Database') {
  1399. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:mysql://" + oozieHost + "/" + oozieDbName;
  1400. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "com.mysql.jdbc.Driver";
  1401. } else { //existing oracle database
  1402. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:oracle:thin:@//" + oozieHost + ":1521/" + oozieDbName;
  1403. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "oracle.jdbc.driver.OracleDriver";
  1404. }
  1405. //set oozie username and password
  1406. oozieProperties["oozie.service.JPAService.jdbc.username"] = globals.findProperty('name', 'oozie_metastore_user_name').value;
  1407. oozieProperties["oozie.service.JPAService.jdbc.password"] = globals.findProperty('name', 'oozie_metastore_user_passwd').value;
  1408. }
  1409. return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};
  1410. },
  1411. createHiveSiteObj: function (serviceName) {
  1412. var configs = this.get('configs').filterProperty('filename', 'hive-site.xml');
  1413. var hiveProperties = {};
  1414. configs.forEach(function (_configProperty) {
  1415. hiveProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1416. this._recordHostOverrideFromObj(_configProperty, 'hive-site', 'version1', this);
  1417. }, this);
  1418. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1419. if (globals.someProperty('name', 'hive_database')) {
  1420. var hiveDb = globals.findProperty('name', 'hive_database');
  1421. var hiveHost = globals.findProperty('name', 'hive_hostname').value;
  1422. var hiveDbName = globals.findProperty('name', 'hive_database_name').value;
  1423. if (hiveDb.value === 'New MySQL Database') {
  1424. // hiveProperties["javax.jdo.option.ConnectionURL"] = "jdbc:mysql://"+ hiveHost + "/" + hiveDbName + "?createDatabaseIfNotExist=true";
  1425. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "com.mysql.jdbc.Driver";
  1426. } else if (hiveDb.value === 'Existing 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 { //existing oracle database
  1430. // hiveProperties["javax.jdo.option.ConnectionURL"] = "jdbc:oracle:thin:@//"+ hiveHost + ":1521/" + hiveDbName;
  1431. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "oracle.jdbc.driver.OracleDriver";
  1432. }
  1433. }
  1434. return {type: 'hive-site', tag: 'version1', properties: hiveProperties};
  1435. },
  1436. createWebHCatSiteObj: function (serviceName) {
  1437. var configs = this.get('configs').filterProperty('filename', 'webhcat-site.xml');
  1438. var webHCatProperties = {};
  1439. configs.forEach(function (_configProperty) {
  1440. webHCatProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1441. this._recordHostOverrideFromObj(_configProperty, 'webhcat-site', 'version1', this);
  1442. }, this);
  1443. return {type: 'webhcat-site', tag: 'version1', properties: webHCatProperties};
  1444. },
  1445. ajaxQueueFinished: function () {
  1446. //do something
  1447. },
  1448. doNextAjaxCall: function () {
  1449. if (this.get('ajaxBusy')) {
  1450. return;
  1451. }
  1452. var queue = this.get('ajaxQueue');
  1453. if (!queue.length) {
  1454. this.ajaxQueueFinished();
  1455. return;
  1456. }
  1457. var first = queue[0];
  1458. this.set('ajaxQueue', queue.slice(1));
  1459. this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
  1460. this.set('ajaxBusy', true);
  1461. console.log('AJAX send ' + first.url);
  1462. $.ajax(first);
  1463. },
  1464. /**
  1465. * Records all the host overrides per site/tag
  1466. */
  1467. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1468. var overrides = serviceConfigObj.overrides;
  1469. if(overrides && overrides.length>0){
  1470. overrides.forEach(function(override){
  1471. override.hosts.forEach(function(host){
  1472. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1473. self.savedHostToOverrideSiteToTagMap[host] = {};
  1474. }
  1475. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1476. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1477. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1478. }
  1479. var finalTag = tagName + '_' + host;
  1480. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.value+")");
  1481. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1482. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.value;
  1483. });
  1484. });
  1485. }
  1486. },
  1487. /**
  1488. * Creates host level overrides for service configuration.
  1489. *
  1490. */
  1491. createHostOverrideConfigurations: function () {
  1492. var singlePUTHostData = [];
  1493. var savedHostSiteArray = [];
  1494. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1495. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1496. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1497. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1498. savedHostSiteArray.push(host + "///" + siteName);
  1499. singlePUTHostData.push({
  1500. RequestInfo: {
  1501. query: 'Hosts/host_name='+host
  1502. },
  1503. Body: {
  1504. Hosts: {
  1505. desired_config: {
  1506. type: siteName,
  1507. tag: tagName,
  1508. properties: map
  1509. }
  1510. }
  1511. }
  1512. });
  1513. }
  1514. }
  1515. console.log("createHostOverrideConfigSites(): PUTting host-overrides. Data=", singlePUTHostData);
  1516. if(singlePUTHostData.length>0){
  1517. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1518. this.ajax({
  1519. type: 'PUT',
  1520. url: url,
  1521. data: JSON.stringify(singlePUTHostData),
  1522. dataType: 'text',
  1523. beforeSend: function () {
  1524. console.log("createHostOverrideConfigSites() PUT override=", singlePUTHostData);
  1525. }
  1526. });
  1527. }
  1528. },
  1529. /**
  1530. * We need to do a lot of ajax calls async in special order. To do this,
  1531. * generate array of ajax objects and then send requests step by step. All
  1532. * ajax objects are stored in <code>ajaxQueue</code>
  1533. *
  1534. * @param params
  1535. */
  1536. ajax: function (params) {
  1537. if (App.testMode) return;
  1538. var self = this;
  1539. params = jQuery.extend({
  1540. async: true,
  1541. dataType: 'text',
  1542. statusCode: require('data/statusCodes'),
  1543. timeout: App.timeout,
  1544. error: function (request, ajaxOptions, error) {
  1545. console.log('Step8: In Error ');
  1546. // console.log('Step8: Error message is: ' + request.responseText);
  1547. },
  1548. success: function (data) {
  1549. var jsonData = jQuery.parseJSON(data);
  1550. console.log("TRACE: STep8 -> In success function");
  1551. console.log("TRACE: STep8 -> value of the url is: " + params.url);
  1552. console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
  1553. }
  1554. }, params);
  1555. var success = params.success;
  1556. var error = params.error;
  1557. params.success = function () {
  1558. if (success) {
  1559. success();
  1560. }
  1561. self.set('ajaxBusy', false);
  1562. self.doNextAjaxCall();
  1563. }
  1564. params.error = function (xhr, status, error) {
  1565. var responseText = JSON.parse(xhr.responseText);
  1566. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1567. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1568. self.set('hasErrorOccurred', true);
  1569. // an error will break the ajax call chain and allow submission again
  1570. self.set('isSubmitDisabled', false);
  1571. self.set('isBackBtnDisabled', false);
  1572. App.router.get(self.get('content.controllerName')).setStepsEnable();
  1573. self.get('ajaxQueue').clear();
  1574. self.set('ajaxBusy', false);
  1575. }
  1576. this.get('ajaxQueue').pushObject(params);
  1577. }
  1578. });