step8_controller.js 74 KB

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