step8_controller.js 68 KB

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