step8_controller.js 69 KB

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