step8_controller.js 70 KB

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