step8_controller.js 68 KB

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