step8_controller.js 75 KB

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