step8_controller.js 68 KB

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