step8_controller.js 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896
  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. beforeSend: function () {
  1262. console.log('BeforeSend: registerHostsToComponent for ' + queryStr + ' and component ' + componentName);
  1263. }
  1264. });
  1265. }, this);
  1266. },
  1267. createConfigurations: function () {
  1268. var selectedServices = this.get('selectedServices');
  1269. if (this.get('content.controllerName') == 'installerController') {
  1270. this.get('serviceConfigTags').pushObject(this.createGlobalSiteObj());
  1271. this.get('serviceConfigTags').pushObject(this.createCoreSiteObj());
  1272. this.get('serviceConfigTags').pushObject(this.createHdfsSiteObj());
  1273. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HDFS'));
  1274. }
  1275. if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
  1276. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  1277. if (App.supports.capacitySchedulerUi) {
  1278. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  1279. this.get('serviceConfigTags').pushObject(this.createMapredQueueAcls());
  1280. }
  1281. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE'));
  1282. }
  1283. if (selectedServices.someProperty('serviceName', 'MAPREDUCE2')) {
  1284. this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
  1285. this.get('serviceConfigTags').pushObject(this.createLog4jObj('MAPREDUCE2'));
  1286. }
  1287. if (selectedServices.someProperty('serviceName', 'YARN')) {
  1288. this.get('serviceConfigTags').pushObject(this.createYarnSiteObj());
  1289. this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
  1290. }
  1291. if (selectedServices.someProperty('serviceName', 'HBASE')) {
  1292. this.get('serviceConfigTags').pushObject(this.createHbaseSiteObj());
  1293. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HBASE'));
  1294. }
  1295. if (selectedServices.someProperty('serviceName', 'OOZIE')) {
  1296. this.get('serviceConfigTags').pushObject(this.createOozieSiteObj('OOZIE'));
  1297. this.get('serviceConfigTags').pushObject(this.createLog4jObj('OOZIE'));
  1298. }
  1299. if (selectedServices.someProperty('serviceName', 'HIVE')) {
  1300. this.get('serviceConfigTags').pushObject(this.createHiveSiteObj('HIVE'));
  1301. this.get('serviceConfigTags').pushObject(this.createLog4jObj('HIVE'));
  1302. }
  1303. if (selectedServices.someProperty('serviceName', 'WEBHCAT')) {
  1304. this.get('serviceConfigTags').pushObject(this.createWebHCatSiteObj('WEBHCAT'));
  1305. }
  1306. if (selectedServices.someProperty('serviceName', 'HUE')) {
  1307. this.get('serviceConfigTags').pushObject(this.createHueSiteObj('HUE'));
  1308. }
  1309. if (selectedServices.someProperty('serviceName', 'PIG')) {
  1310. this.get('serviceConfigTags').pushObject(this.createLog4jObj('PIG'));
  1311. }
  1312. if (selectedServices.someProperty('serviceName', 'ZOOKEEPER')) {
  1313. this.get('serviceConfigTags').pushObject(this.createLog4jObj('ZOOKEEPER'));
  1314. }
  1315. this.applyConfigurationsToCluster();
  1316. },
  1317. applyConfigurationsToCluster: function() {
  1318. var clusterUrl = App.apiPrefix + '/clusters/' + this.get('clusterName');
  1319. var configData = [];
  1320. this.get('serviceConfigTags').forEach(function (_serviceConfig) {
  1321. var Clusters = {
  1322. Clusters: {
  1323. desired_config: {
  1324. type: _serviceConfig.type,
  1325. tag: _serviceConfig.tag,
  1326. properties: _serviceConfig.properties
  1327. }
  1328. }
  1329. };
  1330. configData.pushObject(JSON.stringify(Clusters));
  1331. }, this);
  1332. var data = {
  1333. configData: '[' + configData.toString() + ']'
  1334. };
  1335. console.debug("applyConfigurationsToCluster(Step8): Applying to URL", clusterUrl, " Data:", data.configData);
  1336. this.ajax({
  1337. type: 'PUT',
  1338. url: clusterUrl,
  1339. data: data.configData,
  1340. beforeSend: function () {
  1341. console.log("BeforeSend: Updating cluster config");
  1342. }
  1343. });
  1344. },
  1345. createConfigurationGroups: function () {
  1346. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1347. var clusterName = this.get('clusterName');
  1348. var sendData = [];
  1349. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1350. configGroups.forEach(function (configGroup) {
  1351. var groupConfigs = [];
  1352. var groupData = {
  1353. "cluster_name": clusterName,
  1354. "group_name": configGroup.name,
  1355. "tag": configGroup.service.id,
  1356. "description": configGroup.description,
  1357. "hosts": [],
  1358. "desired_configs": []
  1359. };
  1360. configGroup.hosts.forEach(function (hostName) {
  1361. groupData.hosts.push({"host_name": hostName});
  1362. });
  1363. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1364. configGroup.properties.forEach(function (property) {
  1365. groupConfigs.push(Em.Object.create(property));
  1366. });
  1367. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs);
  1368. sendData.push({"ConfigGroup": groupData});
  1369. }, this);
  1370. if (sendData.length > 0) {
  1371. this.applyConfigurationGroups(sendData);
  1372. }
  1373. },
  1374. applyConfigurationGroups: function (sendData) {
  1375. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/config_groups';
  1376. this.ajax({
  1377. type: 'POST',
  1378. url: url,
  1379. data: JSON.stringify(sendData)
  1380. });
  1381. },
  1382. createGlobalSiteObj: function () {
  1383. var globalSiteProperties = {};
  1384. var globalSiteObj = this.get('globals');
  1385. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1386. // screen out the GLUSTERFS-specific global config entries when they are not required
  1387. if (!isGLUSTERFSSelected) {
  1388. globalSiteObj = globalSiteObj.filter(function(_config) {
  1389. return _config.name.indexOf("fs_glusterfs") < 0;
  1390. });
  1391. }
  1392. globalSiteObj.forEach(function (_globalSiteObj) {
  1393. var heapsizeException = ['hadoop_heapsize','yarn_heapsize','nodemanager_heapsize','resourcemanager_heapsize'];
  1394. // do not pass any globals whose name ends with _host or _hosts
  1395. if (_globalSiteObj.isRequiredByAgent === true) {
  1396. // append "m" to JVM memory options except for hadoop_heapsize
  1397. if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && !heapsizeException.contains(_globalSiteObj.name)) {
  1398. globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value + "m";
  1399. } else {
  1400. globalSiteProperties[_globalSiteObj.name] = App.config.escapeXMLCharacters(_globalSiteObj.value);
  1401. }
  1402. if (_globalSiteObj.name == 'java64_home') {
  1403. globalSiteProperties['java64_home'] = this.get('content.installOptions.javaHome');
  1404. }
  1405. }
  1406. this._recordHostOverrideFromObj(_globalSiteObj, 'global', 'version1', this);
  1407. }, this);
  1408. // we don't expose gmond_user to the user; it needs to be the same as gmetad_user
  1409. globalSiteProperties['gmond_user'] = globalSiteProperties['gmetad_user'];
  1410. return {"type": "global", "tag": "version1", "properties": globalSiteProperties};
  1411. },
  1412. createCoreSiteObj: function () {
  1413. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml');
  1414. var coreSiteProperties = {};
  1415. // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
  1416. var isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE');
  1417. var oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null;
  1418. var isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE');
  1419. var hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null;
  1420. var isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT');
  1421. var hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null;
  1422. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1423. // screen out the GLUSTERFS-specific core-site.xml entries when they are not needed
  1424. if (!isGLUSTERFSSelected) {
  1425. coreSiteObj = coreSiteObj.filter(function(_config) {
  1426. return _config.name.indexOf("fs.glusterfs") < 0;
  1427. });
  1428. }
  1429. coreSiteObj.forEach(function (_coreSiteObj) {
  1430. 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'))) {
  1431. coreSiteProperties[_coreSiteObj.name] = App.config.escapeXMLCharacters(_coreSiteObj.value);
  1432. this._recordHostOverrideFromObj(_coreSiteObj, 'core-site', 'version1', this);
  1433. }
  1434. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1435. 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;
  1436. }
  1437. console.log("STEP*: name of the property is: " + _coreSiteObj.name);
  1438. console.log("STEP8: value of the property is: " + _coreSiteObj.value);
  1439. }, this);
  1440. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1441. },
  1442. createHdfsSiteObj: function () {
  1443. var hdfsSiteObj = this.get('configs').filterProperty('filename', 'hdfs-site.xml');
  1444. var hdfsProperties = {};
  1445. hdfsSiteObj.forEach(function (_configProperty) {
  1446. hdfsProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1447. this._recordHostOverrideFromObj(_configProperty, 'hdfs-site', 'version1', this);
  1448. console.log("STEP*: name of the property is: " + _configProperty.name);
  1449. console.log("STEP8: value of the property is: " + _configProperty.value);
  1450. }, this);
  1451. return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
  1452. },
  1453. createLog4jObj: function (serviceName) {
  1454. serviceName = serviceName.toLowerCase();
  1455. var file = '';
  1456. switch(serviceName) {
  1457. case 'zookeeper':
  1458. file = 'zoo';
  1459. break;
  1460. case 'mapreduce':
  1461. case 'mapreduce2':
  1462. file = 'mapred';
  1463. break;
  1464. default:
  1465. file = serviceName;
  1466. }
  1467. var Log4jObj = this.get('configs').filterProperty('filename', serviceName + '-log4j.xml');
  1468. var Log4jProperties = {};
  1469. Log4jObj.forEach(function (_configProperty) {
  1470. Log4jProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1471. this._recordHostOverrideFromObj(_configProperty, serviceName + '-log4j', 'version1', this);
  1472. console.log("STEP*: name of the property is: " + _configProperty.name);
  1473. console.log("STEP8: value of the property is: " + _configProperty.value);
  1474. }, this);
  1475. return {"type": serviceName + "-log4j", "tag": "version1", "properties": Log4jProperties };
  1476. },
  1477. createHueSiteObj: function () {
  1478. var hueSiteObj = this.get('configs').filterProperty('filename', 'hue-site.xml');
  1479. var hueProperties = {};
  1480. hueSiteObj.forEach(function (_configProperty) {
  1481. hueProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1482. this._recordHostOverrideFromObj(_configProperty, 'hue-site', 'version1', this);
  1483. console.log("STEP*: name of the property is: " + _configProperty.name);
  1484. console.log("STEP8: value of the property is: " + _configProperty.value);
  1485. }, this);
  1486. return {"type": "hue-site", "tag": "version1", "properties": hueProperties };
  1487. },
  1488. createMrSiteObj: function () {
  1489. var configs = this.get('configs').filterProperty('filename', 'mapred-site.xml');
  1490. var mrProperties = {};
  1491. configs.forEach(function (_configProperty) {
  1492. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1493. this._recordHostOverrideFromObj(_configProperty, 'mapred-site', 'version1', this);
  1494. console.log("STEP*: name of the property is: " + _configProperty.name);
  1495. console.log("STEP8: value of the property is: " + _configProperty.value);
  1496. }, this);
  1497. return {type: 'mapred-site', tag: 'version1', properties: mrProperties};
  1498. },
  1499. createYarnSiteObj: function () {
  1500. var configs = this.get('configs').filterProperty('filename', 'yarn-site.xml');
  1501. var mrProperties = {};
  1502. configs.forEach(function (_configProperty) {
  1503. mrProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1504. this._recordHostOverrideFromObj(_configProperty, 'yarn-site', 'version1', this);
  1505. console.log("STEP*: name of the property is: " + _configProperty.name);
  1506. console.log("STEP8: value of the property is: " + _configProperty.value);
  1507. }, this);
  1508. return {type: 'yarn-site', tag: 'version1', properties: mrProperties};
  1509. },
  1510. createCapacityScheduler: function () {
  1511. var configs = this.get('configs').filterProperty('filename', 'capacity-scheduler.xml');
  1512. var csProperties = {};
  1513. configs.forEach(function (_configProperty) {
  1514. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1515. this._recordHostOverrideFromObj(_configProperty, 'capacity-scheduler', 'version1', this);
  1516. console.log("STEP*: name of the property is: " + _configProperty.name);
  1517. console.log("STEP8: value of the property is: " + _configProperty.value);
  1518. }, this);
  1519. return {type: 'capacity-scheduler', tag: 'version1', properties: csProperties};
  1520. },
  1521. createMapredQueueAcls: function () {
  1522. var configs = this.get('configs').filterProperty('filename', 'mapred-queue-acls.xml');
  1523. var mqProperties = {};
  1524. configs.forEach(function (_configProperty) {
  1525. mqProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1526. this._recordHostOverrideFromObj(_configProperty, 'mapred-queue-acls', 'version1', this);
  1527. console.log("STEP*: name of the property is: " + _configProperty.name);
  1528. console.log("STEP8: value of the property is: " + _configProperty.value);
  1529. }, this);
  1530. return {type: 'mapred-queue-acls', tag: 'version1', properties: mqProperties};
  1531. },
  1532. createHbaseSiteObj: function () {
  1533. var configs = this.get('configs').filterProperty('filename', 'hbase-site.xml');
  1534. var hbaseProperties = {};
  1535. configs.forEach(function (_configProperty) {
  1536. hbaseProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1537. this._recordHostOverrideFromObj(_configProperty, 'hbase-site', 'version1', this);
  1538. }, this);
  1539. return {type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
  1540. },
  1541. createOozieSiteObj: function (serviceName) {
  1542. var configs = this.get('configs').filterProperty('filename', 'oozie-site.xml');
  1543. var oozieProperties = {};
  1544. configs.forEach(function (_configProperty) {
  1545. oozieProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1546. this._recordHostOverrideFromObj(_configProperty, 'oozie-site', 'version1', this);
  1547. }, this);
  1548. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1549. if (globals.someProperty('name', 'oozie_database')) {
  1550. var oozieDb = globals.findProperty('name', 'oozie_database');
  1551. if (oozieDb.value === 'New Derby Database') {
  1552. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true";
  1553. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "org.apache.derby.jdbc.EmbeddedDriver";
  1554. } else if (oozieDb.value === 'Existing MySQL Database') {
  1555. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:mysql://" + oozieHost + "/" + oozieDbName;
  1556. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "com.mysql.jdbc.Driver";
  1557. } else { //existing oracle database
  1558. // oozieProperties["oozie.service.JPAService.jdbc.url"] = "jdbc:oracle:thin:@//" + oozieHost + ":1521/" + oozieDbName;
  1559. oozieProperties["oozie.service.JPAService.jdbc.driver"] = "oracle.jdbc.driver.OracleDriver";
  1560. }
  1561. }
  1562. return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};
  1563. },
  1564. createHiveSiteObj: function (serviceName) {
  1565. var configs = this.get('configs').filterProperty('filename', 'hive-site.xml');
  1566. var hiveProperties = {};
  1567. configs.forEach(function (_configProperty) {
  1568. hiveProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1569. this._recordHostOverrideFromObj(_configProperty, 'hive-site', 'version1', this);
  1570. }, this);
  1571. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  1572. if (globals.someProperty('name', 'hive_database')) {
  1573. var hiveDb = globals.findProperty('name', 'hive_database');
  1574. if (hiveDb.value === 'New MySQL Database') {
  1575. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "com.mysql.jdbc.Driver";
  1576. } else if (hiveDb.value === 'Existing MySQL Database'){
  1577. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "com.mysql.jdbc.Driver";
  1578. } else { //existing oracle database
  1579. hiveProperties["javax.jdo.option.ConnectionDriverName"] = "oracle.jdbc.driver.OracleDriver";
  1580. }
  1581. }
  1582. return {type: 'hive-site', tag: 'version1', properties: hiveProperties};
  1583. },
  1584. createWebHCatSiteObj: function (serviceName) {
  1585. var configs = this.get('configs').filterProperty('filename', 'webhcat-site.xml');
  1586. var webHCatProperties = {};
  1587. configs.forEach(function (_configProperty) {
  1588. webHCatProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1589. this._recordHostOverrideFromObj(_configProperty, 'webhcat-site', 'version1', this);
  1590. }, this);
  1591. return {type: 'webhcat-site', tag: 'version1', properties: webHCatProperties};
  1592. },
  1593. ajaxQueueFinished: function () {
  1594. //do something
  1595. },
  1596. doNextAjaxCall: function () {
  1597. if (this.get('ajaxBusy')) {
  1598. return;
  1599. }
  1600. var queue = this.get('ajaxQueue');
  1601. if (!queue.length) {
  1602. this.ajaxQueueFinished();
  1603. return;
  1604. }
  1605. var first = queue[0];
  1606. this.set('ajaxQueue', queue.slice(1));
  1607. this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
  1608. this.set('ajaxBusy', true);
  1609. console.log('AJAX send ' + first.url);
  1610. $.ajax(first);
  1611. },
  1612. /**
  1613. * Records all the host overrides per site/tag
  1614. */
  1615. _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
  1616. var overrides = serviceConfigObj.overrides;
  1617. if(overrides && overrides.length>0){
  1618. overrides.forEach(function(override){
  1619. override.hosts.forEach(function(host){
  1620. if(!(host in self.savedHostToOverrideSiteToTagMap)){
  1621. self.savedHostToOverrideSiteToTagMap[host] = {};
  1622. }
  1623. if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
  1624. self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
  1625. self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
  1626. }
  1627. var finalTag = tagName + '_' + host;
  1628. console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.value+")");
  1629. self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
  1630. self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.value;
  1631. });
  1632. });
  1633. }
  1634. },
  1635. /**
  1636. * Creates host level overrides for service configuration.
  1637. *
  1638. */
  1639. createHostOverrideConfigurations: function () {
  1640. var singlePUTHostData = [];
  1641. var savedHostSiteArray = [];
  1642. for ( var host in this.savedHostToOverrideSiteToTagMap) {
  1643. for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
  1644. var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
  1645. var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
  1646. savedHostSiteArray.push(host + "///" + siteName);
  1647. singlePUTHostData.push({
  1648. RequestInfo: {
  1649. query: 'Hosts/host_name='+host
  1650. },
  1651. Body: {
  1652. Hosts: {
  1653. desired_config: {
  1654. type: siteName,
  1655. tag: tagName,
  1656. properties: map
  1657. }
  1658. }
  1659. }
  1660. });
  1661. }
  1662. }
  1663. console.log("createHostOverrideConfigSites(): PUTting host-overrides. Data=", singlePUTHostData);
  1664. if(singlePUTHostData.length>0){
  1665. var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
  1666. this.ajax({
  1667. type: 'PUT',
  1668. url: url,
  1669. data: JSON.stringify(singlePUTHostData),
  1670. dataType: 'text',
  1671. beforeSend: function () {
  1672. console.log("createHostOverrideConfigSites() PUT override=", singlePUTHostData);
  1673. }
  1674. });
  1675. }
  1676. },
  1677. /**
  1678. * We need to do a lot of ajax calls async in special order. To do this,
  1679. * generate array of ajax objects and then send requests step by step. All
  1680. * ajax objects are stored in <code>ajaxQueue</code>
  1681. *
  1682. * @param params
  1683. */
  1684. ajax: function (params) {
  1685. if (App.testMode) return;
  1686. var self = this;
  1687. params = jQuery.extend({
  1688. async: true,
  1689. dataType: 'text',
  1690. statusCode: require('data/statusCodes'),
  1691. timeout: App.timeout,
  1692. error: function (request, ajaxOptions, error) {
  1693. console.log('Step8: In Error ');
  1694. // console.log('Step8: Error message is: ' + request.responseText);
  1695. },
  1696. success: function (data) {
  1697. var jsonData = jQuery.parseJSON(data);
  1698. console.log("TRACE: STep8 -> In success function");
  1699. console.log("TRACE: STep8 -> value of the url is: " + params.url);
  1700. console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
  1701. }
  1702. }, params);
  1703. var success = params.success;
  1704. var error = params.error;
  1705. params.success = function () {
  1706. if (success) {
  1707. success();
  1708. }
  1709. self.set('ajaxBusy', false);
  1710. self.doNextAjaxCall();
  1711. }
  1712. params.error = function (xhr, status, error) {
  1713. var responseText = JSON.parse(xhr.responseText);
  1714. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1715. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1716. self.set('hasErrorOccurred', true);
  1717. // an error will break the ajax call chain and allow submission again
  1718. self.set('isSubmitDisabled', false);
  1719. self.set('isBackBtnDisabled', false);
  1720. App.router.get(self.get('content.controllerName')).setStepsEnable();
  1721. self.get('ajaxQueue').clear();
  1722. self.set('ajaxBusy', false);
  1723. }
  1724. this.get('ajaxQueue').pushObject(params);
  1725. }
  1726. });