step8_controller.js 73 KB

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