step8_controller.js 67 KB

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